/* ============================================================
   ESmont Dashboard — Layout
   Header, nav, tabs, containers, grids, cameras, mobile menu.
   ============================================================ */

/* ---- Header ---- */

header#header {
    padding: 14px 16px;
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.16);
    justify-content: space-between;
}
header .flex { gap: 10px; }

/* ---- Logo ---- */

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.logo svg   { width: 32px; height: 32px; fill: var(--brand); }
.logo h1    { font-size: 20px; font-weight: 600; color: var(--brand); }

/* SVG logo asset colours */
.logo-image .logocls-1,
.logo-image .logocls-3 { fill: #2d364a; }
.logo-image .logocls-1 { fill-rule: evenodd; }
.logo-image .logocls-2 { fill: #9c3; }
.logo-image .logocls-4 { fill: #9c3; stroke: #2d364a; stroke-width: 5px; }
.logo-image svg { max-width: 100%; }

/* Gradient heading (hero h1 inside .container) */
.container h1 {
    background: linear-gradient(90deg, var(--status-in-progress) 0%, var(--status-done) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-fill-color: transparent;
    font-weight: 900;
    display: inline-block;
}

/* ---- Navigation ---- */

nav { display: flex; gap: 8px; align-items: center; }

.nav-button {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background-color: var(--border);
    color: var(--brand);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
    font-family: "Source Sans 3", sans-serif;
}
.nav-button:hover {
    background-color: var(--border-subtle);
    transform: translateY(-1px);
}
.nav-button.active {
    background: linear-gradient(195deg, #66BB6A, #43A047);
    color: white;
    box-shadow: 0 4px 20px 0 rgba(0,0,0,.14), 0 7px 10px -5px rgba(76,175,80,.4);
}

/* ---- Tabs (job board status filter) ---- */

.tab {
    padding: 10px 14px;
    border-radius: 10px;
    background-color: var(--border);
    border-color: var(--border);
    box-shadow: 0 8px 14px -8px hsla(0,0%,90%,.3), 0 3px 18px 0 hsla(0,0%,90%,.1), 0 7px 8px -4px hsla(0,0%,90%,.18);
    cursor: pointer;
    color: var(--brand);
    font-weight: 400;
    font-size: 14px;
    font-family: "Source Sans 3", sans-serif;
    border: none;
    transition: all .2s;
}
.tab.active {
    background: var(--primary);
    background-image: linear-gradient(195deg, #66bb6a, #43a047);
    color: #fff;
}
.tab:hover {
    color: rgba(58,65,111,.8);
    box-shadow: 0 8px 14px -8px hsla(0,0%,45%,.3), 0 3px 18px 0 hsla(0,0%,45%,.1), 0 7px 8px -4px hsla(0,0%,45%,.18);
}
.tab.active:hover { color: #fff; }

/* ---- Containers ---- */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}
.container-fluid {
    margin: 20px;
    max-width: 100%;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}
.container-bg {
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-top: 20px;
}

/* ---- Job board grid ---- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: var(--layout-gap);
    padding: var(--layout-gap);
}

/* ---- Dashboard module grid ---- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-top: 24px;
}
/* Last tile spans full row on wide screens */
.dashboard-grid > :last-child { grid-column: span 3; }

/* ---- Stats bar (production totals) ---- */

.stats-grid { display: flex; margin: 20px 0; }
.stats-grid > * { width: 100%; padding: 10px; border: 1px solid var(--card); }
.stat-label { font-weight: bold; }
.section-header { display: flex; justify-content: space-between; margin: 20px 0; }

/* ---- Camera grid ---- */

.cameras-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--layout-gap);
    padding: var(--layout-gap);
}
.camera-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.camera-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--muted);
}
.camera-stream {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 */
    position: relative;
    background: #000;
}
.camera-stream img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
}
.camera-error {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--destructive);
    text-align: center;
    padding: 20px;
}

/* ---- Mobile sidebar menu ---- */

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--foreground);
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

.mobile-menu {
    position: fixed;
    top: 0; left: -100%;
    width: 280px;
    height: 100vh;
    background: var(--card);
    z-index: 1000;
    transition: left .3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,.1);
    overflow-y: auto;
}
.mobile-menu.active { left: 0; }

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.mobile-menu-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--foreground);
}
.mobile-menu-close svg { width: 24px; height: 24px; }

.mobile-menu-content { padding: 20px 0; }

.mobile-menu-section { margin-bottom: 30px; }
.mobile-menu-section h3 {
    padding: 0 20px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted-foreground);
    letter-spacing: .5px;
}
.mobile-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--muted);
    text-align: left;
    cursor: pointer;
    transition: background .2s;
    color: var(--foreground);
    font-size: 15px;
    text-decoration: none;
    box-shadow: none;
}
.mobile-menu-item:hover,
.mobile-menu-item:active { background: var(--muted); transform: none; }
.mobile-menu-item.active { background: #e3f2fd; color: #1976d2; font-weight: 600; }
.mobile-menu-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.mobile-menu-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    background: rgba(0,0,0,.5);
    z-index: 999;
    display: none;
}
.mobile-menu-overlay.active { display: block; }

/* ---- Sub-module utilities ---- */

.footer {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}
.filters select { padding: 10px; border: 1px solid var(--border-subtle); border-radius: 4px; font-size: 14px; width: 100%; }
.filters button { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; }
.filters button:hover { background: #0056b3; }
.table-wrapper { overflow-x: auto; }

/* Component inventory colour groups */
.group-dira     { background: #e3f2fd; }
.group-sroub    { background: #fff3e0; }
.group-valecek  { background: #f3e5f5; }
[class^="group-"] { text-align: center; }
#tableContainer th, #tableContainer td { font-size: 11px; padding: 6px; }
#tableContainer td:last-child { white-space: nowrap; }
.temp-group     { background: #e3f2fd; text-align: center; }
.pressure-group { background: #fff3e0; text-align: center; }

/* G-code viewer */
.gcode-section  { margin-top: 30px; }
.gcode-header   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.gcode-output {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: var(--radius-sm);
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    min-height: 400px; max-height: 600px; overflow-y: auto;
}
.gcode-output.empty { display: flex; align-items: center; justify-content: center; color: #666; font-style: italic; }

/* Selector rows (ski length etc.) */
.selector-section { margin-bottom: 30px; padding: 20px; background: var(--muted); border-radius: var(--radius-sm); }
.selector-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; margin-bottom: 15px; }
.selector-row:last-child { margin-bottom: 0; }
.selector-section label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--foreground); font-size: 14px; }
.selector-section select { width: 100%; padding: 10px; border: 1px solid var(--border-subtle); border-radius: 4px; font-size: 14px; background: var(--card); }

/* Desktop hamburger */
button#desktopMenuBtn { padding: 0; }
button#desktopMenuBtn svg { width: 50px; height: 50px; }

/* ---- Responsive ---- */

@media (max-width: 768px) {
    header#header {
        padding: 12px 16px;
        gap: 12px;
    }
    header#header .flex.order-3 .tab { display: none; }
    header#header .flex.order-3 .btn { display: none; }
    header#header .flex.order-2 > * { display: none !important; }
    header#header .flex.order-2 .logo-image.mobile-only { display: block !important; }

    nav { flex-wrap: wrap; justify-content: center; }
    .dashboard-grid  { grid-template-columns: 1fr; }
    .production-grid { grid-template-columns: 1fr; }
    .cameras-grid    { grid-template-columns: 1fr; }
    .grid            { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
    .container       { padding: 16px; }

    .modal .modal-dialog,
    .modal .modal-content { max-height: 96vh; margin: 0; }
    .modal .body { display: flex; flex-direction: column; max-height: 70vh; }
    .modal header { font-size: .7rem; }

    #newCatalog  .itemline,
    #catalogList .itemline,
    #selectedList .itemline { font-size: .7rem; }

    #searchCustomer { display: none; }
    .order-1 { order: 1; }
    .order-2 { order: 2; }
    .order-3 { order: 3; }
    .mobile-only    { display: block; }
    .desktop-only   { display: none !important; }
    .mobile-hide    { display: none !important; }
    .mobile-menu-btn { display: block; }

    .flex.order-2 button { font-size: .9rem; padding: 10px 14px; }

    /* module pages: six stacked filter selects eat the screen — two columns */
    .filters { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (max-width: 480px) {
    .logo h1         { font-size: 16px; }
    .nav-button, .tab { padding: 8px 16px; font-size: 13px; }
    button           { padding: 8px 16px; font-size: 13px; }
}

@media (max-width: 720px) {
    .dashboard-grid > :last-child { grid-column: auto; }
}


.customer-dropdown {
   background: var(--card);
   border: 1px solid var(--border);
   color: var(--foreground);

   position: absolute;
   top: 100%;
   left: 0;
   right: 0;
   z-index: 20;
   margin-top: 4px;
   border-radius: 10px;
   max-height: 300px;
   overflow: auto;
   box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.customer-dropdown .item {
   border-bottom: 1px solid var(--border-subtle);
}

.customer-dropdown .item:hover,
.customer-dropdown .item[aria-selected="true"] {
   background: var(--muted);
}

textarea,
input[type="text"],
input[type="search"] {
   background: var(--muted);
   color: var(--foreground);
   border: 1px solid var(--border);
}

textarea {
   width: 100%;
}