:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --bg-light: #f4f7f6;
    --border-color: #ddd;
    --text-color: #333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header & Tabs */
header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 10;
}

h1 {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.tabs {
    display: flex;
    gap: 10px;
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #777;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab:hover {
    color: var(--accent-color);
    background-color: rgba(52, 152, 219, 0.05);
}

.tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* Layout Principal */
main {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: #fff;
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.sidebar.is-hidden {
    display: none;
}

.panel {
    background: #fff;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 8px;
}

.panel h3 {
    margin-bottom: 15px;
    font-size: 1rem;
    color: var(--primary-color);
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

.pos-select-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 8px;
}

.pos-autocomplete {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(0,0,0,0.18);
    overflow: hidden;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
}

.pos-autocomplete[hidden] {
    display: none !important;
}

.pos-autocomplete .pos-ac-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-size: 0.85rem;
}

.pos-autocomplete .pos-ac-row:last-child {
    border-bottom: 0;
}

.pos-autocomplete .pos-ac-row:hover,
.pos-autocomplete .pos-ac-row.is-active {
    background: rgba(52, 152, 219, 0.10);
}

.pos-autocomplete .pos-ac-code {
    font-weight: 800;
    color: rgba(0,0,0,0.85);
}

.pos-autocomplete .pos-ac-meta {
    font-weight: 700;
    color: rgba(0,0,0,0.45);
    font-size: 0.8em;
}

.pos-autocomplete .pos-ac-match {
    background: rgba(241, 196, 15, 0.35);
    border-radius: 6px;
    padding: 0 4px;
}

.pos-autocomplete .pos-ac-empty {
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(0,0,0,0.6);
}

.parsley-errors-list {
    margin: 4px 0 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.75rem;
    color: #e74c3c;
}

.parsley-errors-list li {
    line-height: 1.1;
}

.search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-row input {
    flex: 1;
}

.btn-secondary {
    padding: 8px 10px;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary:hover {
    border-color: rgba(52, 152, 219, 0.55);
    color: var(--accent-color);
}

.view-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 10px;
    backdrop-filter: blur(6px);
}

.view-toolbar-3d {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 14px;
}

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
}

.toolbar-search label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(0,0,0,0.62);
    white-space: nowrap;
}

.toolbar-search input {
    width: clamp(190px, 26vw, 320px);
    min-width: 190px;
}

.radio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 6px;
    background: rgba(255,255,255,0.9);
    cursor: pointer;
    user-select: none;
}

.radio-option input {
    width: auto;
    padding: 0;
}

.radio-option span {
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-primary {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.info-box {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #555;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
    min-height: 80px;
}

.info-celda-head {
    display: grid;
    gap: 2px;
    margin-bottom: 8px;
}

.info-celda-list {
    display: grid;
    gap: 10px;
}

.info-celda-item {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    padding: 8px 9px;
    display: grid;
    gap: 2px;
    font-size: 0.85rem;
}

.info-celda-empty {
    font-style: italic;
    color: rgba(0,0,0,0.55);
}

.info-box details > summary {
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.list-row:last-child {
    border-bottom: none;
}

.list-main {
    min-width: 0;
    flex: 1;
}

.list-title {
    font-weight: 600;
    color: #222;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-sub {
    font-size: 0.82rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-sub-wrap {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
}

.list-empty {
    color: #888;
    font-style: italic;
    padding: 6px 0;
}

.btn-icon-delete {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.9);
    color: #c0392b;
    cursor: pointer;
    font-size: 18px;
    line-height: 22px;
    padding: 0;
}

.btn-icon-delete:hover {
    background: rgba(231, 76, 60, 0.10);
    border-color: rgba(231, 76, 60, 0.25);
}

.zone-swatch {
    width: 10px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.06);
    flex: 0 0 auto;
    margin-top: 2px;
}

.item-details {
    width: 100%;
}

.item-details-inline {
    width: calc(100% - 26px);
}

.item-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    outline: none;
}

.item-summary::-webkit-details-marker {
    display: none;
}

.item-body {
    padding: 6px 0 8px 0;
    color: #444;
    font-size: 0.85rem;
    line-height: 1.35;
}

/* Área de Contenido (Vistas) */
.content-area {
    flex: 1;
    position: relative;
    background-color: #e0e0e0;
    overflow: hidden;
}

.view-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Oculto por defecto */
}

.view-content.active {
    display: block;
}

/* Vista Configuración */
#configuracion-patio {
    overflow: auto;
    padding: 20px;
    background: #f4f6f8;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}

.config-card {
    width: 100%;
    height: fit-content;
}

.config-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

#configuracion-patio .panel {
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 10px 24px rgba(0,0,0,0.06);
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(6px);
}

@media (max-width: 1180px) {
    .config-grid {
        grid-template-columns: repeat(2, minmax(280px, 1fr));
    }
}

@media (max-width: 820px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* Vista 2D */
#vista-2d {
    overflow: hidden;
    padding: 12px;
}

.view-content.active#vista-2d {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.canvas-wrapper {
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background: white;
    padding: 10px;
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
}

canvas#canvas2D {
    cursor: grab;
    width: 100%;
    height: 100%;
    display: block;
}

.hud-2d {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: #111;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
    white-space: nowrap;
}

/* Vista 3D */
#vista-3d {
    position: relative;
    padding: 12px;
}

.view-content.active#vista-3d {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#view3D {
    width: 100%;
    flex: 1;
    min-height: 0;
    min-height: 400px;
    position: relative;
}

.btn-3d-reset {
    padding: 8px 10px;
    background-color: rgba(52, 152, 219, 0.95);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-3d-reset:hover {
    background-color: rgba(41, 128, 185, 0.98);
}

.hud-3d {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: #111;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}

.hud-3d .hud-metrics {
    white-space: nowrap;
}

.hud-3d .hud-blocks {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.hud-3d .hud-block-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-3d .hud-swatch {
    width: 10px;
    height: 10px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.12);
    flex: 0 0 auto;
}

.hud-3d .hud-block-text {
    font-weight: 700;
    color: #111;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-clear-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.input-clear-wrap input {
    padding-right: 28px;
}

.input-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 6px;
    background: rgba(0,0,0,0.08);
    color: rgba(0,0,0,0.65);
    font-weight: 800;
    line-height: 18px;
    cursor: pointer;
    padding: 0;
}

.input-clear-btn:hover {
    background: rgba(0,0,0,0.12);
    color: rgba(0,0,0,0.8);
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 18px;
    margin-left: 8px;
}

.loading-dots[hidden] {
    display: none !important;
}

.loading-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    animation: loadingDots 1s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes loadingDots {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-3px); opacity: 0.9; }
}

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(20, 20, 20, 0.92);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.10);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-error {
    background: rgba(231, 76, 60, 0.92);
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal-card {
    width: min(340px, calc(100% - 24px));
    border-radius: 12px;
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 16px 40px rgba(0,0,0,0.25);
    padding: 12px 12px 10px 12px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-title {
    font-weight: 900;
    color: #111;
    font-size: 13px;
}

.modal-close {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 8px;
    background: rgba(0,0,0,0.08);
    color: rgba(0,0,0,0.7);
    font-weight: 900;
    cursor: pointer;
    line-height: 22px;
    padding: 0;
}

.modal-body {
    font-size: 12px;
    color: rgba(0,0,0,0.78);
    font-weight: 700;
}

.modal-body ul {
    margin: 8px 0 0 16px;
    padding: 0;
}

.pos-cards {
    display: grid;
    gap: 10px;
}

.pos-card {
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 10px;
    background: rgba(255,255,255,0.9);
    overflow: hidden;
}

.pos-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.pos-card-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #111;
}

.pos-grid {
    display: grid;
    gap: 6px;
    padding: 10px;
    overflow-x: auto;
    max-width: 100%;
}

.pos-grid-row {
    display: grid;
    gap: 6px;
    width: max-content;
    min-width: 100%;
}

.pos-cell {
    position: relative;
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 8px;
    background: rgba(255,255,255,0.92);
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(0,0,0,0.82);
}

.pos-cell small {
    font-weight: 700;
    color: rgba(0,0,0,0.55);
}

.pos-cell .btn-icon-delete {
    pointer-events: auto;
    margin-left: auto;
}

.tooltip-3d,
.tooltip-2d {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-9999px, -9999px);
    pointer-events: none;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-line;
}
