/* ============================================================
   CONFIGURADOR MODULAR — STYLE SYSTEM
   Inspired by ModularClosets.com
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Design Tokens ── */
:root {
    --navy: #1B2A4A;
    --navy-light: #2D4A7A;
    --coral: #E86C3A;
    --coral-hover: #D45A2B;
    --bg: #FFFFFF;
    --bg-alt: #F7F8FA;
    --bg-viewport: #EDEDED;
    --border: #E5E7EB;
    --border-light: #F0F1F3;
    --text: #1A1A1A;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --panel-width: 460px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body, html {
    width: 100%; height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-viewport);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── App Layout ── */
.app {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ============================================================
   CONFIG PANEL (Left Side)
   ============================================================ */
.config-panel {
    width: var(--panel-width);
    flex-shrink: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 20px rgba(0,0,0,0.04);
    z-index: 10;
}

/* ── Header ── */
.config-header {
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--border);
}
.config-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.header-tools-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}
.add-tower-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid var(--navy);
    color: var(--navy);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.01em;
}
.add-tower-btn:hover {
    background: var(--navy);
    color: #fff;
}
.add-tower-btn:disabled {
    border-color: var(--border);
    color: var(--text-muted);
    background: var(--bg-alt);
    cursor: not-allowed;
    box-shadow: none;
}
.add-tower-btn:disabled:hover {
    background: var(--bg-alt);
    color: var(--text-muted);
}
.plus-icon {
    font-size: 1.1em;
    font-weight: 800;
}

/* ── Color Toggle ── */
.color-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 250px;
}
.color-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
}
.color-name {
    width: auto;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0;
    margin-left: 4px;
    white-space: nowrap;
}
.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.color-dot.white { background: #f6f5f1; }
.color-dot.snow  { background: #eceee9; }
.color-dot.cotton { background: #e7ddd0; }
.color-dot.dark  { background: #b9b1a4; }
.color-dot:hover { transform: scale(1.1); }
.color-dot.active {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.15);
}
.height-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-alt);
}
.height-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 2px;
}
.height-pill {
    min-width: 44px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    padding: 0 12px;
}
.height-pill:hover {
    border-color: var(--navy-light);
    color: var(--navy);
}
.height-pill.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* ── Towers Scroll Area ── */
.towers-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.towers-scroll::-webkit-scrollbar { width: 5px; }
.towers-scroll::-webkit-scrollbar-track { background: transparent; }
.towers-scroll::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

/* ── Tower Card ── */
.tower-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    overflow: hidden;
    transition: box-shadow var(--transition);
    background: var(--bg);
}
.tower-card:hover {
    box-shadow: var(--shadow-sm);
}

.tower-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-alt);
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}
.tower-card.expanded .tower-header {
    border-bottom-color: var(--border);
}
.tower-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tower-toggle {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.tower-name {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text);
}
.tower-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.tower-delete-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--transition);
}
.tower-delete-btn:hover {
    color: #EF4444;
    background: #FEF2F2;
    border-color: #FECACA;
}

/* ── Tower Body ── */
.tower-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.tower-card.expanded .tower-body {
    max-height: 800px;
}

/* ── Sections (Width, Top, Bottom, Door) ── */
.tower-section {
    border-bottom: 1px solid var(--border-light);
}
.tower-section:last-child { border-bottom: none; }

.section-header {
    display: flex;
    align-items: center;
    padding: 9px 13px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}
.section-header:hover {
    background: var(--bg-alt);
}
.section-title {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    min-width: 112px;
}
.section-value {
    flex: 1;
    font-size: 0.765rem;
    font-weight: 600;
    color: var(--coral);
}
.section-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition);
    margin-left: 8px;
}
.tower-section.open .section-chevron {
    transform: rotate(180deg);
}

/* ── Section Body ── */
.section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tower-section.open .section-body {
    max-height: 300px;
}
.section-body-inner {
    padding: 6px 13px 12px;
}

/* ── Width Pills ── */
.width-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pill {
    min-width: 42px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}
.pill:hover {
    border-color: var(--navy-light);
    background: var(--bg-alt);
}
.pill.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* ── Option List (Top / Bottom / Door) ── */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.option-item:hover {
    border-color: var(--navy-light);
    background: var(--bg-alt);
}
.option-item.active {
    border-color: var(--coral);
    background: #FFF5F0;
    color: var(--coral);
    font-weight: 700;
}
.option-item .option-radio {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: var(--transition);
}
.option-item.active .option-radio {
    border-color: var(--coral);
}
.option-item.active .option-radio::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--coral);
}

/* ============================================================
   HARDWARE OPTIONS (Bottom Left)
   ============================================================ */
.hardware-card {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    margin: 0;
}
.hardware-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
}
.hardware-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: 0.02em;
}
.hardware-body {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 20px 16px;
}
.hardware-body.collapsed {
    max-height: 0;
    padding-bottom: 0;
}
.hardware-row {
    display: flex;
    align-items: center;
    margin-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.hardware-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.hardware-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 80px;
    letter-spacing: 0.05em;
}
.hardware-options {
    display: flex;
    gap: 16px;
}
.hw-radio {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hw-colors {
    display: flex;
    gap: 10px;
}
.hw-color-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.hw-color-btn.chrome { background: #e2e8f0; }
.hw-color-btn.black { background: #1a1a1a; }
.hw-color-btn.gold { background: #cfb53b; }
.hw-color-btn.active {
    border-color: var(--coral);
    box-shadow: 0 0 0 2px rgba(232, 108, 58, 0.2);
}

/* ============================================================
   CONFIG FOOTER
   ============================================================ */
.config-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.footer-total {
    display: flex;
    flex-direction: column;
}
.total-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.total-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: -0.02em;
}
.cta-btn {
    padding: 14px 28px;
    background: var(--coral);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.cta-btn:hover {
    background: var(--coral-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ============================================================
   3D VIEWPORT (Right Side)
   ============================================================ */
.viewport {
    flex: 1;
    position: relative;
    background: var(--bg-viewport);
}
.viewport-logo {
    position: absolute;
    top: 24px;
    left: 2px;
    z-index: 5;
    width: 390px;
    height: auto;
    opacity: 0.9;
}
#c {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
}

/* ── Viewport Controls ── */
.viewport-controls {
    position: absolute;
    top: 24px;
    right: 32px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
.vp-action-btn {
    width: 168px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 14px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-size: 0.875rem;
    font-weight: 600;
}
.vp-action-btn:hover {
    background: #fff;
    color: var(--text);
}
.vp-action-btn.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.vp-action-btn svg {
    flex: 0 0 auto;
}

/* ── Annotation Labels (3D overlay) ── */
.annotation-label {
    background: rgba(27, 42, 74, 0.85);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.internal-annotation-label {
    background: rgba(40, 40, 40, 0.65);
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}
.empty-state-text {
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tower-card {
    animation: fadeIn 0.3s ease forwards;
}

/* ============================================================
   RESPONSIVE LAYOUT (Mobile)
   ============================================================ */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    .config-panel {
        width: 100%;
        flex: 1;
        height: 60vh;
        border-right: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        z-index: 20;
    }
    .viewport {
        width: 100%;
        height: 40vh;
        flex: none;
    }
    .viewport-logo {
        top: 16px;
        left: 2px;
        width: 116px;
    }
    .viewport-controls {
        top: 12px;
        right: 12px;
        gap: 8px;
    }
    .vp-action-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        padding: 0;
        justify-content: center;
        gap: 0;
        border-radius: 50%;
    }
    .vp-action-btn span {
        display: none;
    }
    .vp-action-btn svg {
        width: 16px;
        height: 16px;
    }
    .config-header {
        padding: 12px;
    }
    .config-title {
        font-size: 1.05rem;
        margin-bottom: 10px;
    }
    .header-row {
        gap: 8px;
        align-items: center;
    }
    .add-tower-btn {
        padding: 6px 10px;
        font-size: 0.72rem;
    }
    .color-toggle {
        gap: 4px;
        max-width: none;
        flex: 1;
    }
    .color-label {
        font-size: 0.75rem;
        margin-right: 2px;
    }
    .color-dot {
        width: 20px;
        height: 20px;
    }
    .color-name {
        font-size: 0.66rem;
        margin-left: 2px;
    }
    .header-tools-row {
        justify-content: flex-end;
        margin-top: 8px;
    }
    .height-toggle {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        padding: 4px 6px;
        gap: 5px;
    }
    .height-label {
        font-size: 0.72rem;
    }
    .height-pill {
        min-width: 40px;
        height: 26px;
        font-size: 0.72rem;
        padding: 0 10px;
    }
    .towers-scroll {
        padding: 10px 12px;
    }
    .tower-card {
        margin-bottom: 10px;
    }
    .tower-header {
        padding: 11px 12px;
    }
    .tower-name {
        font-size: 0.875rem;
    }
    .section-header {
        padding: 10px 12px;
    }
    .section-title {
        min-width: 104px;
        font-size: 0.625rem;
    }
    .section-value {
        font-size: 0.76rem;
    }
    .section-body-inner {
        padding: 6px 12px 12px;
    }
    .width-pills {
        gap: 6px;
    }
    .pill {
        min-width: 42px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    .option-item {
        padding: 8px 12px;
        font-size: 0.76rem;
    }
    .config-footer {
        padding: 12px 16px;
    }
    .total-price {
        font-size: 1.25rem;
    }
    .cta-btn {
        padding: 10px 20px;
        font-size: 0.875rem;
    }
}
