/* =========================================================================
   packaging/js.css
   DACDORA CAD - MASTER STYLES (Desktop Right-Panel + Perfect Mobile)
   ========================================================================= */

:root {
    /* -- Brand Colors (Cyber Dark) -- */
    --bg-app: #020617;          /* Deepest Background (Canvas) */
    --bg-sidebar: #0f172a;      /* Slate Panel (Sidebar/Tools) */
    --bg-glass: rgba(15, 23, 42, 0.85); /* Glass HUD */
    
    --border: rgba(255, 255, 255, 0.1); 
    --border-hover: rgba(255, 255, 255, 0.2);
    
    --accent: #ff3366;          /* Neon Pink */
    --accent-blue: #00ADEF;     /* Cyan Blue */
    
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    
    --input-bg: rgba(0, 0, 0, 0.2);
    
    /* CAD Colors */
    --cut-color: #00ADEF;
    --crease-color: #ff3366;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    margin: 0; padding: 0;
    height: 100vh; width: 100vw; 
    overflow: hidden; 
    background: var(--bg-app); 
    color: var(--text-main);
    font-size: 13px;
    display: flex; 
}

/* =========================================
   1. LAYOUT STRUCTURE
   ========================================= */
.app-container { 
    display: flex; 
    width: 100%; 
    height: 100%; 
    flex-direction: row; /* Default: Desktop Row */
}

/* --- LEFT SIDEBAR --- */
.sidebar { 
    width: 340px; 
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0;
    z-index: 20;
    height: 100%; 
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

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

.brand { 
    font-weight: 800; font-size: 16px; color: #fff;
    display: flex; align-items: center; gap: 10px; 
    letter-spacing: 0.5px;
    font-family: 'Geom', sans-serif;
}

/* Scrollable Content */
.scroll-area { 
    flex: 1; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    padding: 0;
}
.scroll-area::-webkit-scrollbar { width: 6px; background: var(--bg-app); }
.scroll-area::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Details/Accordion Styling */
details { border-bottom: 1px solid var(--border); }
summary { 
    padding: 18px 20px; 
    cursor: pointer; 
    font-weight: 600; 
    background: var(--bg-sidebar); 
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px; letter-spacing: 1px;
    display: flex; justify-content: space-between; align-items: center;
    list-style: none;
    transition: 0.2s;
}
summary:hover { color: #fff; background: rgba(255,255,255,0.02); }
.details-body { padding: 20px; background: rgba(0,0,0,0.2); }

/* =========================================
   2. UI COMPONENTS (Inputs, Toggles)
   ========================================= */
/* Unit Toggle */
.unit-toggle { 
    background: rgba(255,255,255,0.05); padding: 3px; border-radius: 6px; 
    display: flex; border: 1px solid var(--border);
}
.unit-btn { 
    padding: 4px 10px; font-size: 11px; font-weight: 600; 
    color: var(--text-muted); cursor: pointer; border-radius: 4px; border: none; background: transparent;
}
.unit-btn.active { background: var(--accent); color: #fff; }

/* Input Fields */
.input-row { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.label { font-size: 12px; font-weight: 500; color: var(--text-muted); }

.input-wrapper { 
    display: flex; align-items: center; 
    background: var(--input-bg); border: 1px solid var(--border); 
    border-radius: 6px; height: 38px; width: 140px; padding: 0 10px; 
    transition: 0.2s;
}
.input-wrapper:focus-within { 
    border-color: var(--accent); 
    background: rgba(255,255,255,0.05); 
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.2);
}
.input-wrapper input { 
    width: 100%; background: transparent; border: none; outline: none; 
    text-align: right; font-weight: 600; font-size: 14px; color: #fff; 
    font-family: monospace;
}
.unit-suffix { font-size: 11px; color: var(--text-muted); margin-left: 6px; }

/* Dropdowns */
select.std-select { 
    width: 100%; padding: 10px; border: 1px solid var(--border); 
    border-radius: 6px; background: var(--input-bg); color: #fff; 
    font-size: 12px; margin-top: 5px; cursor: pointer;
}
select.std-select option { background: var(--bg-sidebar); }

/* Toggle Switches */
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toggle-switch { position: relative; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { 
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; 
    background-color: #334155; transition: .3s; border-radius: 20px; 
}
.slider:before { 
    position: absolute; content: ""; height: 18px; width: 18px; left: 2px; bottom: 2px; 
    background-color: #fff; transition: .3s; border-radius: 50%; 
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(18px); }

/* Export Button */
.export-btn { 
    width: 100%; background-image: linear-gradient(to right, #ff3366, #ff1149);
    color: #fff; padding: 12px; border: none; border-radius: 6px; 
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; 
    font-size: 11px; cursor: pointer; margin-top: 15px; 
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.3);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: 0.2s;
}
.export-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255, 51, 102, 0.5); }

/* =========================================
   3. RIGHT SIDE PANELS (Desktop Layout)
   ========================================= */

/* --- A. TOOLS PANEL (Top Right) --- */
#tools-panel {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 220px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    z-index: 40;
    box-shadow: -5px 5px 20px rgba(0,0,0,0.3);
}

#tools-panel .panel-header {
    font-size: 10px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border); letter-spacing: 1px;
}

/* --- B. 3D WINDOW (Bottom Right) --- */
#pip-window { 
    position: absolute; 
    bottom: 30px; 
    right: 30px; 
    width: 320px; height: 360px; 
    background: var(--bg-sidebar); border: 1px solid var(--border); 
    border-radius: 16px; box-shadow: -10px -10px 40px rgba(0,0,0,0.5); 
    display: flex; flex-direction: column; overflow: hidden; z-index: 50; 
}

#pip-header { 
    padding: 12px 16px; background: rgba(255,255,255,0.02); 
    border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; 
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px;
}
#pip-canvas { flex: 1; background: #020617; cursor: grab; }
#pip-canvas:active { cursor: grabbing; }

#pip-controls { 
    padding: 16px; background: rgba(255,255,255,0.02); 
    border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; 
}
input[type=range].control-slider { 
    -webkit-appearance: none; flex: 1; height: 4px; background: #334155; 
    border-radius: 2px; outline: none; 
}
input[type=range].control-slider::-webkit-slider-thumb { 
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; 
    background: var(--accent); cursor: pointer; box-shadow: 0 0 10px var(--accent);
    border: 2px solid #fff;
}

/* =========================================
   4. MAIN VIEWPORT (Canvas & HUDs)
   ========================================= */
.main-view { 
    flex: 1; position: relative; background-color: var(--bg-app); 
    background-image: 
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px), 
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px); 
    background-size: 40px 40px; 
    overflow: hidden; 
}
.canvas-wrapper { width: 100%; height: 100%; cursor: default; }

/* Top HUD (Stats) */
.hud-top { 
    position: absolute; top: 24px; left: 50%; transform: translateX(-50%); 
    background: var(--bg-glass); backdrop-filter: blur(10px); 
    padding: 10px 30px; border-radius: 50px; border: 1px solid var(--border); 
    display: flex; gap: 40px; align-items: center; z-index: 10;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.hud-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; display: block; text-align: center; }
.hud-val { font-weight: 700; color: #fff; font-family: monospace; font-size: 16px; display: block; text-align: center; }

/* Bottom HUD (Zoom Tools) */
.hud-bottom { 
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); 
    background: var(--bg-glass); padding: 8px 16px; border-radius: 12px; 
    display: flex; gap: 12px; z-index: 20; border: 1px solid var(--border); 
    backdrop-filter: blur(10px);
}
.tool-btn { 
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; 
    border-radius: 8px; color: var(--text-muted); cursor: pointer; background: rgba(255,255,255,0.05);
    transition: 0.2s;
}
.tool-btn:hover { background: var(--accent); color: #fff; transform: translateY(-2px); }
.sep { width: 1px; background: rgba(255,255,255,0.1); margin: 0 4px; }

/* SVG Drawing Styles */
.cut { fill: none; stroke: var(--cut-color); stroke-width: 1.5px; }
.crease { fill: none; stroke: var(--crease-color); stroke-width: 1.5px; stroke-dasharray: 6,4; }
.dim-text { font-family: sans-serif; font-size: 14px; font-weight: 700; fill: #fff; stroke: var(--bg-app); stroke-width: 3px; paint-order: stroke; }
.dim-arrow { stroke: var(--accent-blue); stroke-width: 1px; }

/* =========================================
   5. MOBILE RESPONSIVE (Max Width 900px)
   ========================================= */
@media (max-width: 900px) {
    /* A. Vertical Stack */
    .app-container { flex-direction: column; }

    /* B. Main View (Top 45%) */
    .main-view {
        order: 1; width: 100%; height: 45vh;
        border-bottom: 1px solid var(--border);
    }

    /* C. Sidebar (Bottom 55%) */
    .sidebar {
        order: 2; width: 100%; height: 55vh;
        border-right: none;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }
    .header { padding: 10px 15px; min-height: 50px; }
    
    /* D. Tools Panel (Moves INSIDE Sidebar) */
    #tools-panel {
        position: relative;
        top: auto; right: auto; left: auto; bottom: auto;
        width: 100%;
        background: transparent; border: none; border-top: 1px solid var(--border);
        border-radius: 0; box-shadow: none; padding: 20px; z-index: 1;
        margin-top: auto; /* Push to bottom */
    }
    #tools-panel .panel-header { display: none; } /* Hide header */
    
    /* E. 3D Window (Mini floating on Top Right) */
    #pip-window {
        top: auto !important; left: auto !important;
        bottom: 10px !important; /* Above sidebar */
        right: 10px !important;
        width: 130px; height: 150px;
        border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }
    #pip-header { display: none; }
    #pip-controls { padding: 5px; }
    
    /* F. Compact HUDs */
    .hud-top { top: 10px; padding: 4px 12px; gap: 15px; }
    .hud-label { font-size: 8px; }
    .hud-val { font-size: 11px; }

    .hud-bottom {
        bottom: 10px; left: 20px; transform: none; /* Left corner */
        padding: 4px; gap: 6px;
    }
    .tool-btn { width: 30px; height: 30px; }
}