/* ==========================================================================
   CỬA NHÔM 3D STUDIO - SHOWROOM CSS
   Phong cách hiện đại, kính mờ (Glassmorphism), tối ưu trải nghiệm tương tác 3D
   ========================================================================== */

:root {
    --bg-dark: #0f1117;
    --panel-bg: rgba(22, 27, 34, 0.85);
    --panel-border: rgba(255, 255, 255, 0.08);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --surface: #1e2430;
    --surface-hover: #2d3748;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
}

/* 3D Canvas Viewport */
#viewport-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

canvas#webgl-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Main Sidebar Controls */
.sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    width: 380px;
    background: var(--panel-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    z-index: 10;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed {
    transform: translateX(calc(-100% - 32px));
}

.sidebar-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-title h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.brand-title p {
    font-size: 11px;
    color: var(--text-muted);
}

/* Toggle Collapse Button */
.btn-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-toggle-sidebar:hover {
    color: #fff;
    background: var(--surface);
}

/* Scrollable Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-content::-webkit-scrollbar {
    width: 5px;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Section Styling */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title span.badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

/* Catalog Door Grid */
.catalog-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.door-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.door-card:hover {
    background: var(--surface-hover);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.door-card.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.door-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.door-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.door-system {
    font-size: 11px;
    color: var(--text-muted);
}

.door-type-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

/* Door Open/Close Control Box */
.anim-box {
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.anim-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.anim-status {
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
}

.btn-open-toggle {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-open-toggle:hover {
    background: var(--accent-hover);
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #374151;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent);
}

/* Color Swatches Grid */
.swatches-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.swatch-item {
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.swatch-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.swatch-item.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
}

.swatch-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.swatch-name {
    font-size: 10px;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Glass Selector */
.glass-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.glass-item {
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.glass-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.glass-item.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
}

.glass-sample {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-name {
    font-size: 11px;
    color: var(--text-main);
}

/* Dimension Sliders */
.dimension-box {
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dim-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dim-row-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.dim-val {
    color: #60a5fa;
    font-weight: 600;
}

.checkbox-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
}

/* Actions Section */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-action {
    background: var(--surface);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-action.primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #3b82f6;
    grid-column: span 2;
    font-weight: 600;
}
.btn-action.primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

/* Floating Top Controls (Camera / View presets) */
.top-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    display: flex;
    gap: 8px;
}

.btn-icon-float {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-icon-float:hover {
    background: var(--surface-hover);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-icon-float.active {
    background: var(--accent);
    color: #fff;
}

/* Floating open sidebar button when collapsed */
.btn-uncollapse {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 9;
    display: none;
}
.sidebar.collapsed ~ .btn-uncollapse {
    display: flex;
}

/* Bottom Helper Bar */
.bottom-helper {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 30px;
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-muted);
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 16px;
}

.bottom-helper b {
    color: #e2e8f0;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1e293b;
    border: 1px solid #3b82f6;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 100;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .sidebar {
        width: calc(100% - 32px);
        max-height: 55vh;
        top: auto;
        bottom: 16px;
    }
    .bottom-helper {
        display: none;
    }
}

/* Modal Bảng Dự Toán & Bóc Tách (BOM) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #181d26;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title h2 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title p {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}

.bom-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.bom-stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.bom-stat-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
}

.bom-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #38bdf8;
    margin-top: 4px;
}

.bom-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.bom-table th, .bom-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bom-table th {
    background: rgba(255, 255, 255, 0.03);
    color: #94a3b8;
    font-weight: 600;
    font-size: 12px;
}

.bom-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.bom-total-row {
    font-weight: 700;
    font-size: 15px;
    color: #4ade80;
    border-top: 2px solid rgba(255, 255, 255, 0.15);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

