/* studio.css — ScreenerKing Equipment Builder */

:root {
    --gold: #00538C;
    --gold-light: #0F5586;
    --gold-bg: rgba(0, 83, 140, 0.08);
    --dark: #00538C;
    --bg: #f5f5f0;
    --bg-light: #fafaf5;
    --text: #333;
    --text-light: #666;
    --border: #ddd;
    --border-light: #eee;
    --sidebar-width: 220px;
    --right-panel-width: 320px;
    --header-height: 52px;
    --footer-height: 40px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
}

/* --- HEADER --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    background: var(--dark);
    color: #fff;
    padding: 0 16px;
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-back {
    color: var(--gold);
    text-decoration: none;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-back:hover {
    color: var(--gold-light);
}

.header-back .arrow {
    font-size: 20px;
}

.header-title {
    font-size: 16px;
    font-weight: 500;
    color: #ccc;
    margin-left: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-subtitle {
    color: var(--gold);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* --- MAIN LAYOUT --- */
.main-layout {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow: hidden;
}

/* --- LEFT SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 10px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.sidebar-section {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-section label {
    display: block;
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 4px;
    font-weight: 500;
}

.sidebar-section select,
.sidebar-section input[type="number"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.deck-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}

.deck-controls button {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.deck-controls button:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
}

.deck-controls .deck-count {
    font-weight: 600;
    font-size: 16px;
    padding: 0 8px;
    color: var(--gold);
}

/* Component Palette */
.palette-category {
    border-bottom: 1px solid var(--border-light);
}

.palette-category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
    user-select: none;
}

.palette-category-header:hover {
    background: var(--gold-bg);
}

.palette-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.palette-arrow {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-light);
}

.palette-items {
    padding: 0 12px 8px;
}

.palette-item {
    padding: 5px 8px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: default;
    border: 1px solid transparent;
}

.palette-item:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
}

.palette-item-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
}

.palette-item-info {
    display: block;
    font-size: 10px;
    color: var(--text-light);
}

/* --- CENTER CANVAS --- */
.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

#crossSectionView,
#topDownView {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.canvas-area canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Navigation Controls */
.nav-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.nav-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.nav-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-btn:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
}

.zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 10;
}

.zoom-level {
    font-size: 11px;
    color: var(--text-light);
    padding: 0 6px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    line-height: 32px;
}

/* Component Config Panel (overlay on canvas) */
#configPanel {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 260px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 20;
    display: none;
    max-height: calc(100% - 20px);
    overflow-y: auto;
}

.config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--dark);
    color: #fff;
    border-radius: 7px 7px 0 0;
}

.config-header h3 {
    font-size: 13px;
    font-weight: 600;
}

.config-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}

.config-close:hover {
    color: var(--gold);
}

.config-body {
    padding: 12px 14px;
}

.config-body label {
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
}

.config-body select,
.config-body input[type="number"] {
    display: block;
    width: 100%;
    padding: 5px 8px;
    margin-top: 3px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.config-body input[type="range"] {
    display: block;
    width: calc(100% - 50px);
    margin-top: 3px;
    vertical-align: middle;
}

.config-value {
    display: inline-block;
    width: 45px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    color: var(--gold);
    vertical-align: middle;
}

.config-info {
    color: var(--text-light);
    font-size: 12px;
    font-style: italic;
}

/* --- RIGHT PANEL --- */
.right-panel {
    width: var(--right-panel-width);
    min-width: var(--right-panel-width);
    background: #fff;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.right-panel-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}

.right-panel-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* Spec Sheet */
.spec-group {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
}

.spec-label {
    font-size: 12px;
    color: var(--text-light);
}

.spec-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.spec-deck-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
    margin-top: 8px;
    padding: 4px 0;
    border-bottom: 2px solid var(--gold);
}

/* BOM Table */
.bom {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.bom th {
    background: var(--bg);
    padding: 5px 6px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-light);
}

.bom td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light);
}

.bom tr:hover {
    background: var(--gold-bg);
}

/* Action Buttons */
.action-buttons {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: all 0.15s;
}

.btn:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
}

.btn-primary {
    background: var(--gold);
    color: #fff;
    border-color: var(--gold);
    font-weight: 600;
}

.btn-primary:hover {
    background: #003d66;
}

.btn-row {
    display: flex;
    gap: 6px;
}

.btn-row .btn {
    flex: 1;
}

/* --- FOOTER --- */
.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--footer-height);
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 0 16px;
}

.view-toggle {
    display: flex;
    gap: 12px;
    align-items: center;
}

.view-toggle label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-light);
}

.view-toggle input[type="radio"]:checked + span {
    color: var(--gold);
    font-weight: 600;
}

.footer-brand {
    font-size: 11px;
    color: var(--text-light);
}

.footer-brand a {
    color: var(--gold);
    text-decoration: none;
}

/* --- MODAL --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--dark);
    color: #fff;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    font-size: 15px;
}

.modal-body {
    padding: 16px 20px;
}

.modal-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    font-size: 11px;
    font-family: 'SF Mono', Menlo, monospace;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.modal-footer {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: #fff;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    z-index: 2000;
    transition: bottom 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    letter-spacing: 0.3px;
}

.toast.show {
    bottom: 60px;
}

/* --- RESPONSIVE (TABLET) --- */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 180px;
        --right-panel-width: 260px;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 0px;
        --right-panel-width: 100%;
    }

    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .canvas-area {
        height: 50vh;
    }

    .right-panel {
        width: 100%;
        min-width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    #configPanel {
        width: 220px;
        max-height: 50%;
    }
}

@media (max-width: 600px) {
    .header-title {
        display: none;
    }
}

/* --- INTERACTIVE SIDEBAR --- */
.sb-section {
    border-bottom: 1px solid var(--border-light);
}

.sb-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
    user-select: none;
}

.sb-section-header:hover {
    background: var(--gold-bg);
}

.sb-deck-header {
    background: rgba(0, 83, 140, 0.04);
}

.sb-section-title {
    flex: 1;
}

.sb-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sb-status-dot.sb-active {
    background: #4caf50;
}

.sb-status-dot.sb-inactive {
    background: #ccc;
}

.sb-section-body {
    padding: 4px 12px 8px;
}

.sb-summary {
    font-size: 10px;
    color: var(--text-light);
    padding: 2px 0 6px;
    line-height: 1.4;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 4px;
}

.sb-component-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 6px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    margin: 1px -6px;
}

.sb-component-row:hover {
    background: var(--gold-bg);
}

.sb-component-row:hover .sb-btn-sm {
    background: var(--gold-bg);
    border-color: var(--gold);
    color: var(--gold);
}

.sb-comp-label {
    font-weight: 500;
    color: var(--text);
    min-width: 65px;
    flex-shrink: 0;
}

.sb-comp-detail {
    flex: 1;
    color: var(--text-light);
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-btn-sm {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-light);
}

.sb-btn-sm:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
    color: var(--gold);
}

.sb-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.sb-btn {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.sb-btn:hover {
    background: var(--gold-bg);
    border-color: var(--gold);
}

.sb-btn.sb-configure {
    background: var(--gold);
    color: #fff;
    border-color: var(--gold);
}

.sb-btn.sb-configure:hover {
    background: #003d66;
}

.sb-btn.sb-highlight:hover {
    background: var(--gold-bg);
}

/* Hidden file input */
#uploadInput {
    display: none;
}

/* --- PRINT STYLES --- */
@media print {
    .sidebar, .right-panel, .footer, .nav-controls, .zoom-controls, #configPanel {
        display: none !important;
    }
    .main-layout {
        display: block;
    }
    .canvas-area {
        height: auto;
    }
    .header {
        background: #fff;
        color: var(--dark);
        border-bottom: 3px solid var(--gold);
    }
    .header-back {
        color: var(--dark);
    }
}
