/* GLOBAL DESIGN SYSTEM - DfX-Nesting */
:root {
    --primary: #ff6600;
    --bg-dark: #050505;
    --bg-surface: #0a0a0a;
    --bg-header: #000;
    --text-main: #fff;
    --text-dim: #ccc;
    --text-muted: #555;
    --border-dim: #111;
    --border-main: #222;
    --accent-red: #ff3333;
    --accent-green: #2ecc71;
    --accent-purple: #9b59b6;
    --accent-orange: #f39c12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    background: var(--bg-dark); 
    color: var(--text-main); 
    font-family: 'Inter', 'Roboto', sans-serif; 
    font-size: 14px; /* Compact base */
    line-height: 1.4;
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

h1, h2, h3 { text-transform: uppercase; letter-spacing: 1.5px; color: var(--primary); }
h1 { font-size: 18px; margin-bottom: 20px; }
h2 { font-size: 15px; margin-bottom: 15px; }

a { color: inherit; text-decoration: none; transition: 0.2s; }
a:hover { color: var(--primary); }

/* HEADER & AUTH WIDGET */
.main-header { 
    background: var(--bg-header); 
    border-bottom: 2px solid #ff4d4d; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0;
    height: 100px;
    overflow: visible;
}

.header-controls { display: flex; align-items: center; gap: 20px; }
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 8px; color: var(--text-muted); font-weight: bold; }
.input-group select { background: #111; border: 1px solid #333; color: #fff; padding: 5px; font-size: 12px; border-radius: 4px; }

.account-widget {
    background: #111;
    border: 1px solid #333;
    padding: 8px 15px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: 0.3s;
}
.account-widget:hover { border-color: var(--primary); background: #1a1a1a; }
.account-widget.logged-in { border-color: #2ecc7155; }
.widget-icon { color: var(--primary); font-size: 18px; }
.widget-info { display: flex; flex-direction: column; }
.widget-label { font-size: 9px; color: var(--text-muted); font-weight: 800; }
.widget-email { font-size: 11px; font-weight: 900; color: #fff; }
.link-logout { font-size: 10px; color: var(--accent-red); font-weight: bold; margin-left: 10px; }

/* MAIN LAYOUT */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
    padding-bottom: 50px;
}

.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    padding: 18px 25px; /* Reduced padding */
}

/* TABS */
.sub-tabs { 
    display: flex; 
    gap: 15px; 
    border-bottom: 2px solid var(--border-main); 
    margin-bottom: 15px; 
    padding-bottom: 8px; 
    flex-shrink: 0;
}
.sub-tab-btn { 
    background: none; 
    border: none; 
    color: var(--text-muted); 
    font-weight: 800; 
    cursor: pointer; 
    text-transform: uppercase; 
    transition: 0.3s; 
    font-size: 11px; 
    padding: 5px 0;
}
.sub-tab-btn.active { color: var(--primary); }
.sub-tab-btn:hover { color: var(--primary); }

/* TABLES - INDUSTRIAL COMPACT */
.cairo-table-container, .admin-table-container { 
    background: var(--bg-header); 
    border: 1px solid #333; 
    border-radius: 4px; 
    overflow: hidden; 
}
table { width: 100%; border-collapse: collapse; }
th { 
    background: #111; 
    color: var(--primary); 
    padding: 10px 10px; 
    border: 1px solid var(--border-main); 
    font-size: 11px; 
    text-transform: uppercase; 
    text-align: left; 
    position: sticky; 
    top: 0; 
    white-space: nowrap; 
}
td { 
    padding: 6px 10px; 
    border: 1px solid var(--border-main); 
    font-size: 12px; 
    white-space: nowrap; 
    color: var(--text-dim);
}
tr:hover td { background: #0a0a0a; }

/* BADGES & STATUSES */
.status-badge, .role-badge { 
    padding: 2px 7px; 
    border-radius: 4px; 
    font-size: 10px; 
    font-weight: 900; 
    text-transform: uppercase; 
    display: inline-block;
}
.st-new { background: var(--accent-orange); color: #000; }
.st-sypcut { background: var(--accent-purple); color: #fff; }
.st-done { background: var(--accent-green); color: #000; }
.role-admin { background: var(--accent-red); color: #000; }
.role-user { background: #333; color: #fff; }

/* BUTTONS */
.btn-admin { 
    background: var(--primary); 
    border: none; 
    color: #000; 
    font-weight: 900; 
    padding: 8px 16px; 
    border-radius: 4px; 
    cursor: pointer; 
    text-transform: uppercase; 
    font-size: 10px; 
    transition: 0.2s;
}
.btn-admin:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(255,102,0,0.3); }
.btn-admin:disabled { background: #333; color: #555; cursor: not-allowed; }

/* SPECIFIC PANELS */
.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* [SPEC] JOURNAL SUMMARY */
.journal-summary { 
    background: #111; 
    border: 1px solid #333; 
    padding: 8px 18px; 
    border-radius: 4px; 
    display: flex; 
    gap: 25px; 
    margin-bottom: 12px; 
    align-items: center; 
    border-left: 5px solid var(--primary); 
}
.summary-item { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.summary-label { color: var(--text-muted); font-size: 10px; margin-right: 5px; }

/* [SPEC] BATCH CARDS */
.batch-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.batch-card { 
    background: var(--bg-dark); 
    border: 1px solid var(--border-dim); 
    border-radius: 8px; 
    padding: 20px; 
    transition: 0.3s; 
    border-left: 4px solid var(--border-dim);
    max-width: 1000px; 
    margin: 0 auto 20px auto;
    max-height: 60vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
}
.batch-card:hover { border-color: #444; border-left-color: var(--primary); }

/* [SPEC] SHEET CARDS & PARTS TRAY */
.parts-tray {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 10px 5px;
    margin-top: 15px;
    border-top: 1px solid var(--border-main);
    scrollbar-width: thin;
    scrollbar-color: #333 #000;
}
.parts-tray::-webkit-scrollbar { height: 6px; }
.parts-tray::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

.part-thumb {
    flex: 0 0 90px;
    height: 100px;
    background: var(--bg-dark);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px;
}
.part-thumb:hover { border-color: var(--primary); background: #0a0a0a; transform: translateY(-3px); }
.part-thumb-icon { font-size: 24px; color: var(--primary); margin-bottom: 6px; }
.part-thumb-name { font-size: 9px; color: #777; text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
.part-thumb-qty { font-size: 10px; color: #fff; background: #222; padding: 2px 6px; border-radius: 10px; margin-top: 5px; }

.layout-preview-box {
    width: 100%;
    aspect-ratio: 2 / 1;
    border-radius: 8px; 
    overflow: hidden; 
    border: 1px solid #333; 
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    position: relative;
    transition: 0.3s;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.8);
}
.layout-preview-box:hover { border-color: var(--primary); }
.sheet-img-static { width: 100%; height: 100%; object-fit: contain; image-rendering: crisp-edges; cursor: pointer; }

/* [SPEC] INTERACTIVE VIEWPORT CONTROLS */
.viewport-controls {
    position: absolute;
    top: 10px; right: 10px;
    display: flex; flex-direction: column; gap: 5px;
    z-index: 10; opacity: 0.3; transition: 0.3s;
}
.layout-preview-box:hover .viewport-controls { opacity: 1; }
.v-btn {
    width: 28px; height: 28px; background: rgba(0,0,0,0.8); border: 1px solid #444; 
    color: #fff; border-radius: 4px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; font-weight: bold; border: 1px solid #ff660044;
}
.v-btn:hover { background: var(--primary); color: #000; border-color: var(--primary); }

/* [SPEC] COMPACT VERTICAL LASER BED */
.batch-card-layout { display: grid; grid-template-columns: 280px 1fr; gap: 30px; align-items: stretch; }
.preview-column { display: flex; flex-direction: column; width: 100%; max-width: 280px; }
.preview-area-row { 
    display: flex; gap: 0; 
    border: 1px solid var(--border-dim); border-radius: 4px; overflow: hidden; 
    margin-top: 5px; align-items: stretch; 
    aspect-ratio: 1 / 2; width: 100%; background: #000;
    max-height: 50vh;
}
.thermometer-wrapper { display: flex; flex-direction: column; width: 10px; height: 100%; }
.thermometer-track { 
    width: 10px; height: 100%;
    background: #050505; border-left: 1px solid #1a1a1a; 
    overflow: hidden; position: relative; display: flex; flex-direction: column-reverse;
}
.thermometer-fill { width: 100%; transition: height 1s; box-shadow: 0 0 10px currentColor; }

/* [SPEC] BATCH STATS & MANIFEST */
.manifest-container {
    margin-top: 5px;
    max-height: 600px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 4px;
    border: 1px solid #1a1a1a;
    background: #000;
}
.manifest-table { width: 100%; border-collapse: collapse; }
.manifest-table th { background: #111; color: var(--primary); font-size: 11px; padding: 12px 10px !important; border-bottom: 1px solid var(--border-main); }
.manifest-table td { padding: 8px 10px !important; border-bottom: 1px solid #111; font-size: 12px; line-height: 1.2; color: #ccc; }

.batch-stats-cluster {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-main);
}
.dash-stat { display: flex; flex-direction: column; gap: 4px; }
.dash-label { font-size: 8px; color: var(--text-muted); text-transform: uppercase; font-weight: bold; }
.dash-value { font-size: 14px; font-weight: 900; color: #fff; }

.batch-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.batch-title { font-weight: 900; color: #fff; font-size: 16px; letter-spacing: 1px; }
.batch-meta { font-size: 13px; color: var(--primary); font-weight: 900; text-transform: uppercase; }

/* UTIL */
.align-items-center { align-items: center; }
.text-center { text-align: center; }
[contenteditable="true"] { 
    background: #222; border: 1px dashed #444; padding: 4px; 
    border-radius: 4px; outline: none; transition: 0.2s;
}
[contenteditable="true"]:focus { background: #333; border-color: var(--primary); box-shadow: 0 0 5px rgba(255,102,0,0.3); }


/* CALCULATOR COMPONENTS */
#main-calculator { background: var(--bg-surface); border: 1px solid var(--border-main); border-radius: 8px; padding: 30px; margin-bottom: 40px; position: relative; }
.table-section { margin-bottom: 25px; overflow-x: auto; min-height: 200px; background: #080808; border: 1px solid #222; }
#overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 9999;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    color: var(--primary); font-weight: 800; font-size: 18px; text-transform: uppercase;
}
.progress-wrapper { width: 60%; background: #222; height: 8px; border-radius: 4px; margin: 20px 0; overflow: hidden; }
#progress-bar { width: 0%; height: 100%; background: var(--primary); transition: width 0.3s; box-shadow: 0 0 10px var(--primary); }
.summary-bar { background: #111; padding: 20px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.grand-total { font-size: 20px; font-weight: 900; color: var(--primary); }
.grand-weight { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.preview-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 30px; }
.preview-container { background: #000; border: 1px solid #222; border-radius: 6px; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.preview-header { font-size: 10px; color: var(--text-muted); font-weight: 800; border-bottom: 1px solid #1a1a1a; padding-bottom: 5px; }
.preview-box { height: 320px; background: #050505; border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; padding: 0 !important; }
.preview-box img, .preview-box model-viewer, .preview-box canvas { width: 100% !important; height: 100% !important; object-fit: contain !important; margin: 0 !important; }
.control-panel { display: flex; justify-content: space-between; border-top: 1px solid #222; padding-top: 25px; }
.btn-load { background: var(--primary); color: #000; border: none; padding: 12px 25px; border-radius: 4px; font-weight: 900; font-size: 13px; cursor: pointer; text-transform: uppercase; }
.btn-order { background: #2ecc71; color: #000; border: none; padding: 12px 25px; border-radius: 4px; font-weight: 900; font-size: 13px; cursor: pointer; text-transform: uppercase; margin-left: 10px; }
.btn-order:disabled { background: #333; color: #555; cursor: not-allowed; }


.logo-container { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* LOGO REDESIGN */
.header-logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px;
    margin-left: 20px;
}

.header-logo-section img {
    width: auto;
    height: 70px;
    display: block;
}

.logo-text {
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    margin-top: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header-menu-section {
    display: flex;
    align-items: center;
    margin-right: 20px;
    margin-left: auto;
}

.header-menu-section select {
    font-size: 13px !important;
    padding: 6px 12px !important;
    height: auto;
    min-width: 150px;
}
.header-menu-section .form-group label, 
.header-menu-section label {
    font-size: 13px !important;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.header-menu-section .user-auth-area span,
.header-menu-section .user-auth-area b,
.header-menu-section .btn,
.header-menu-section a {
    font-size: 13px !important;
}

.header-user-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
.header-user-label {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 3px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.header-user-email {
    font-size: 13px !important;
    padding-top: 6px;
    color: #fff;
}

/* ORDER STATUS BADGES */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.2);
}
.status-default { color: #aaa; }
.status-draft { color: #6c757d; }
.status-awaiting { color: #ff4d4d; background: rgba(255, 77, 77, 0.1); }
.status-paid { color: #00a8ff; background: rgba(0, 168, 255, 0.1); }
.status-production { color: #ff9f43; background: rgba(255, 159, 67, 0.1); }
.status-ready { color: #2ed573; background: rgba(46, 213, 115, 0.1); }
.status-shipped { color: #20bf6b; background: rgba(32, 191, 107, 0.1); opacity: 0.8; }
.status-delivery-done { color: #9b59b6; background: rgba(155, 89, 182, 0.1); }

.col-filename {
    max-width: 180px; /* Restrict width by ~1/3 */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}
.col-thickness, .col-metal {
    width: 70px; /* Keep tight */
    white-space: nowrap;
}
.col-preview {
    width: 100px;
}
.dashboard-preview-img {
    width: 80px; /* Increased from default */
    height: 80px;
    object-fit: contain;
    background-color: #1a1c23; /* Dark background for contrast */
    border-radius: 4px;
    transition: transform 0.2s ease;
}
.preview-link:hover .dashboard-preview-img {
    transform: scale(1.05); /* Slight zoom on hover to indicate clickability */
    border: 1px solid #ff4d4d;
}

/* DELIVERY MODAL & BUTTON */
.btn-delivery {
    background: transparent;
    color: #ff9f43;
    border: 1px solid #ff9f43;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.2s;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
}
.btn-delivery:hover {
    background: rgba(255, 159, 67, 0.1);
}
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}
.modal-content {
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 25px;
    width: 100%;
    max-width: 450px;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
