/* ============================================================
   LAYOUT STUDIO – Production CSS (Modular)
   ============================================================ */

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#layout-studio-app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ---------- Toolbar (header) ---------- */
header {
    background: #1e293b;
    color: #e2e8f0;
    padding: 6px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;                /* Above main-layout */
    pointer-events: auto;
}
header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
header .brand h1 {
    font-size: 1.2rem;
    margin: 0;
    color: #fff;
}
header .brand p {
    font-size: 0.7rem;
    color: #888;
    margin: 0;
}
header .toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
/* Make header links/buttons clickable */
header a, header button, .header a, .header button {
    position: relative;
    z-index: 11;
    pointer-events: auto;
}

/* ---------- Buttons ---------- */
.back-btn {
    background: #1e1e1e;
    color: #00ffcc;
    border: 1px solid #00ffcc;
    border-radius: 4px;
    padding: 6px 12px;
    font-family: monospace;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.back-btn:hover { background: #2a2a2a; }
@media (max-width: 768px) { .back-btn span { display: none; } }

.preview-btn {
    background: #1e1e1e;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 6px 14px;
    font-family: monospace;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}
.preview-btn:hover { background: #2a2a2a; border-color: #666; }
.preview-btn.active {
    background: #00ffcc;
    color: #0a0a12;
    border-color: #00ffcc;
}
.preview-btn.active:hover { background: #00e6b8; }

.cad-btn {
    background: #2a2a3a;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
}
.cad-btn:hover { background: #3a3a4a; }
.cad-btn.delete-btn {
    background: #b91c1c;
    color: #fff;
    margin-top: 12px;
    width: 100%;
}
.cad-btn.delete-btn:hover { background: #991b1b; }

/* ---------- Main Layout ---------- */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;                 /* Lower than header */
}

/* ---------- Left Panel ---------- */
#left-panel {
    width: 280px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    overflow-y: auto;
    flex-shrink: 0;
}
#left-panel .panel-header {
    padding: 10px 12px;
    background: #1e293b;
    font-weight: 600;
    border-bottom: 1px solid #334155;
    font-size: 0.9rem;
}
#left-panel .scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#left-panel .asset-card {
    background: #1e293b;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid #334155;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
#left-panel .asset-card:hover {
    background: #2a3a4a;
    transform: translateY(-2px);
    border-color: #3b82f6;
}
#left-panel .asset-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #f1f5f9;
}
#left-panel .asset-sub {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
}
#left-panel .cad-select {
    width: 100%;
    padding: 8px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-top: 8px;
}

/* ---------- Right Panel ---------- */
#right-panel {
    width: 300px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #334155;
    overflow-y: auto;
    flex-shrink: 0;
}
#right-panel .panel-header {
    padding: 10px 12px;
    background: #1e293b;
    font-weight: 600;
    border-bottom: 1px solid #334155;
    font-size: 0.85rem;
}
#right-panel .scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
#right-panel .guest-group {
    background: #1e293b;
    border-radius: 8px;
    padding: 8px 10px;
    border: 1px solid #334155;
}
#right-panel .guest-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#right-panel .guest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f172a;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    border: 1px solid #2a3a4a;
    font-size: 0.75rem;
}
#right-panel .guest-item .guest-name { font-weight: 500; }
#right-panel .guest-item .guest-rsvp {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-left: 6px;
}
#right-panel .seat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f172a;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    border: 1px solid #2a3a4a;
    font-size: 0.75rem;
}
#right-panel .empty-note {
    color: #64748b;
    font-size: 0.7rem;
    text-align: center;
    padding: 8px 0;
}
#right-panel .property-box {
    background: #1e293b;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #334155;
}
#right-panel .property-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 8px;
}
#right-panel .field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.75rem;
}
#right-panel .field label {
    width: 100px;
    color: #cbd5e1;
}
#right-panel .field input,
#right-panel .field select {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}
#right-panel .field input[type="color"] {
    height: 40px;
    padding: 2px;
    cursor: pointer;
}
#right-panel .field .range-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
#right-panel .field .range-row input[type="range"] {
    flex: 1;
    background: transparent;
}
#right-panel .btn-icon {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
}
#right-panel .btn-icon:hover { color: #e2e8f0; }

/* ---------- Viewport & Canvas ---------- */
#viewport {
    flex: 1;
    position: relative;
    background: #0a0a12;
    overflow: hidden;
    width: 100%;
    height: 100%;
    z-index: 1;                 /* Keep canvas below header */
}
#three-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* ---------- Stats Overlay ---------- */
.stats-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    color: #fff;
    font-size: 0.8rem;
}
.stat-badge {
    background: rgba(0,0,0,0.5);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 4px;
    backdrop-filter: blur(4px);
}
.accent { color: #00ffcc; }

/* ---------- Footer ---------- */
footer {
    flex-shrink: 0;
    height: 40px;
    background: #0a0a12;
    border-top: 1px solid #1a1a2a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: #666;
    font-size: 0.7rem;
}
footer .pulse {
    width: 8px;
    height: 8px;
    background: #00ffcc;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.3; transform: scale(0.8); }
}

/* ---------- Preview Mode ---------- */
.preview-mode #left-panel,
.preview-mode #right-panel { display: none !important; }
.preview-mode header { display: none !important; }
.preview-mode #viewport {
    width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 9999 !important;
    background: #0a0a0a !important;
}
.preview-mode #three-canvas { width: 100% !important; height: 100% !important; }
.preview-mode footer { display: none !important; }
.preview-mode .stats-overlay { top: 80px !important; z-index: 10001 !important; }
.preview-mode .stats-overlay .stat-badge {
    background: rgba(0,0,0,0.5) !important;
    backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    font-size: 0.7rem !important;
    padding: 0.2rem 0.8rem !important;
}

/* ---------- Preview Floating UI ---------- */
.preview-toolbar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    background: rgba(20,20,30,0.7);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 60px;
    padding: 0.5rem 1.2rem;
    display: none;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    pointer-events: auto;
}
.preview-mode .preview-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}
.preview-toolbar .toolbar-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.6);
    padding: 0.4rem 0.8rem;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.preview-toolbar .toolbar-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.preview-toolbar .toolbar-btn.active {
    background: rgba(255,255,255,0.12);
    color: #f5af19;
}
.preview-toolbar .divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.08);
}
.preview-toolbar .toolbar-btn i {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .preview-toolbar {
        bottom: 16px;
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
        border-radius: 40px;
        flex-wrap: nowrap;
        max-width: 95%;
        justify-content: center;
        background: rgba(20,20,30,0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255,255,255,0.06);
    }
    .preview-toolbar .toolbar-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.6rem;
        gap: 0.2rem;
        flex-shrink: 0;
    }
    .preview-toolbar .toolbar-btn i {
        font-size: 0.9rem;
    }
    .preview-toolbar .toolbar-btn span {
        display: none;
    }
    .preview-toolbar .divider {
        height: 18px;
        margin: 0 0.1rem;
        flex-shrink: 0;
    }
}
@media (max-width: 480px) {
    .preview-toolbar {
        padding: 0.3rem 0.4rem;
        gap: 0.15rem;
        bottom: 12px;
        border-radius: 32px;
    }
    .preview-toolbar .toolbar-btn {
        padding: 0.2rem 0.35rem;
        font-size: 0.5rem;
    }
    .preview-toolbar .toolbar-btn i {
        font-size: 0.8rem;
    }
    .preview-toolbar .divider {
        height: 14px;
    }
}

/* ---------- Preview Header ---------- */
.preview-header {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002;
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;
}
.preview-mode .preview-header {
    display: flex;
}
.preview-header .room-info {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 500;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    text-align: right;
}
.preview-header .room-info .room-name {
    font-weight: 700;
    color: #fff;
}
.preview-header .room-info .property-name {
    color: rgba(255,255,255,0.5);
}
@media (max-width: 768px) {
    .preview-header {
        top: 12px;
        right: 12px;
    }
    .preview-header .room-info {
        font-size: 0.75rem;
    }
}

/* ---------- Loading Spinner ---------- */
.preview-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10003;
    color: #fff;
    text-align: center;
    display: none;
    pointer-events: none;
}
.preview-mode .preview-loading {
    display: block;
}
.preview-loading .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top: 3px solid #f5af19;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.preview-loading .loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.7);
}
.preview-loading .loading-sub {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    margin-top: 0.3rem;
}
@media (max-width: 768px) {
    .preview-loading .loading-text { font-size: 1rem; }
    .preview-loading .spinner { width: 36px; height: 36px; }
}

/* ---------- Collapsible Sidebar ---------- */
.collapse-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #334155;
    background: rgba(255,255,255,0.03);
    user-select: none;
}
.collapse-header:hover {
    background: rgba(255,255,255,0.08);
}
.collapse-header i:first-child {
    width: 24px;
    text-align: center;
    color: #94a3b8;
}
.collapse-header .chevron {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}
.collapse-header .chevron.collapsed {
    transform: rotate(-90deg);
}
.collapse-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 12px;
}
.collapse-body.show {
    max-height: 2000px;
    padding: 8px 12px;
}

/* ---------- Modals ---------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-card {
    background: #1e1e2a;
    border-radius: 8px;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #334155;
}
.modal-card .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: #e2e8f0;
    font-weight: 600;
}
.modal-card .modal-body {
    margin-bottom: 16px;
}
.modal-card .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.btn-icon {
    background: transparent;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 1rem;
}
.btn-icon:hover { color: #fff; }

/* ---------- Toast ---------- */
.toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #00ffcc;
    color: #000;
    padding: 6px 12px;
    border-radius: 4px;
    z-index: 200;
    font-size: 0.8rem;
}


.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,255,204,0.2);
    border-top: 2px solid #00ffcc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    #left-panel { width: 200px; }
    #right-panel { width: 200px; }
}
@media (max-width: 480px) {
    #left-panel {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid #334155;
    }
    #right-panel {
        width: 100%;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid #334155;
    }
    .main-layout {
        flex-direction: column;
    }
    #viewport {
        flex: 1;
        min-height: 40vh;
    }
}