/*this is a test 4-22-26*/


/* Light mode overrides */
body.light-mode {
    background-color: #f5f5f5;
    color: #212529;
}

/* Table */
body.light-mode .table-dark {
    --bs-table-color: #212529;
    --bs-table-bg: #fff;
    --bs-table-border-color: #ccc;
    --bs-table-striped-bg: #f2f2f2;
    --bs-table-hover-bg: #e8e8e8;
    --bs-table-hover-color: #212529;
    --bs-table-active-bg: #e0e0e0;
    color: #212529;
}
body.light-mode .machine-table thead th {
    background-color: #e0e0e0;
    color: #212529;
    border-color: #ccc;
}
body.light-mode .machine-lastupdate { color: #555; }
body.light-mode .shift-count-small  { color: #444; }
body.light-mode .orderno-cell        { color: #212529; }
body.light-mode .customer-cell       { color: #444; }

/* Tab buttons */
body.light-mode .btn-tab             { color: #444; }
body.light-mode .btn-tab:hover       { background-color: #ddd; color: #212529; }

/* Dialogs */
body.light-mode .modal-content {
    background-color: #f5f5f5 !important;
    color: #212529 !important;
    border-color: #ccc !important;
}
body.light-mode .modal-content .text-light  { color: #212529 !important; }
body.light-mode .modal-content .text-muted  { color: #666 !important; }
body.light-mode .modal-content .border-secondary { border-color: #ccc !important; }
body.light-mode .modal-content .bg-dark     { background-color: #e8e8e8 !important; }
body.light-mode .modal-content [style*="background:#1a1a1a"] { background-color: #e8e8e8 !important; }
body.light-mode .modal-content [style*="background:#1e1e1e"] { background-color: #efefef !important; }
body.light-mode .modal-content [style*="background:#222"]    { background-color: #e8e8e8 !important; }
body.light-mode .modal-content [style*="background:#191919"] { background-color: #e4e4e4 !important; }
body.light-mode .modal-content [style*="background:#2a2a2a"] { background-color: #ddd !important; }
body.light-mode .modal-content .form-control,
body.light-mode .modal-content .form-select {
    background-color: #fff !important;
    color: #212529 !important;
    border-color: #aaa !important;
}
body.light-mode .modal-content .dropdown-menu {
    background-color: #fff !important;
    color: #212529 !important;
    border-color: #ccc !important;
}
body.light-mode .modal-content .dropdown-item { color: #212529 !important; }
body.light-mode .modal-content .btn-close-white { filter: none !important; }

.machine-table tbody td.last-update-cell {
    font-size: 0.92rem;
    font-weight: 400;
    color: #bdbdbd;
}

/* Nested Stop Min / Order No */
.order-nested-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.order-nested-header .header-main {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.05;
}
.order-nested-header .header-sub {
    font-size: 0.85rem;
    color: #cfcfcf;
    margin-top: 0;
    opacity: 0.95;
}
.stopmin-order-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 3.2em;
}
.stopmin-cell, .orderno-cell {
    width: 100%;
    text-align: center;
    font-size: inherit;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.08rem 0.06rem;
    overflow: hidden;
    white-space: nowrap;
}
.orderno-cell {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e0e0e0;
    opacity: 0.95;
}
.customer-cell {
    width: 100%;
    text-align: center;
    font-size: inherit;
    font-weight: 400;
    color: #cfcfcf;
    line-height: 1.2;
    padding: 0.08rem 0.06rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Dark theme matching WinForms black panels */
.navbar {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    min-height: 0;
}

.navbar .navbar-brand {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    font-size: 0.75rem;
}

.navbar .nav-link {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    font-size: 0.75rem;
}

/* Dropdown menus */
.dropdown-menu {
    background-color: #2a2a2a;
    border-color: #555;
    min-width: 14rem;
    padding: 0.2rem 0;
}

.dropdown-item {
    font-size: 0.8rem;
    padding: 0.25rem 1rem;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    white-space: nowrap;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #0d6efd;
    color: #fff;
}

.dropdown-divider {
    border-color: #555;
    margin: 0.2rem 0;
}

/* Resource number visibility toggle */
.resource-no-text {
    display: none;
    width: 100%;
    text-align: center;
    font-weight: 400;
    color: #aaaaaa;
    overflow: hidden;
    white-space: nowrap;
}

body.show-resource-numbers .resource-no-text {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
}

body {
    background-color: #1a1a1a;
    color: #f0f0f0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Content wrapper only — not the navbar's inner container-fluid */
body > .container-fluid {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#tabBar {
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
}

#f3Bar {
    margin: 0 !important;
    padding: 0 !important;
}

.machines-container {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    flex: 1 1 0;
    overflow: hidden;
    min-height: 0;
}

.machine-table-wrap {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.machine-table-wrap .machine-table {
    width: 100%;
    table-layout: fixed;
}

.machine-table-wrap .machine-table th,
.machine-table-wrap .machine-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.machine-table-wrap .machine-table th:nth-child(1),
.machine-table-wrap .machine-table td:nth-child(1) { width: 15%; }
.machine-table-wrap .machine-table th:nth-child(2),
.machine-table-wrap .machine-table td:nth-child(2) { width: 42%; padding: 0 !important; }
.machine-table-wrap .machine-table th:nth-child(3),
.machine-table-wrap .machine-table td:nth-child(3) { width: 19%; }
.machine-table-wrap .machine-table th:nth-child(4),
.machine-table-wrap .machine-table td:nth-child(4) { width: 24%; padding: 0 !important; }

/* Tab buttons */
.btn-tab {
    background-color: transparent;
    color: #aaa;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    transition: background-color 0.15s, color 0.15s;
}

.btn-tab:hover {
    background-color: #2a2a2a;
    color: #fff;
}

.btn-tab.active {
    background-color: #0d6efd;
    color: #fff;
}


/* Machine table - large bold fonts matching 20-34pt WinForms */
.machine-table {
    font-size: 1.18rem;
    height: auto !important;
    max-height: none !important;
}

.machine-table thead th {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
    background-color: #2a2a2a;
    border-color: #444;
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 0;
    padding-bottom: 0;
}


/* Nested header for Rate Now / Shift Count */
.nested-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.nested-header .header-main {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.05;
}
.nested-header .header-sub {
    font-size: 0.7rem;
    color: #cfcfcf;
    margin-top: 0;
    opacity: 0.95;
}

/* OEE cell full-height wrapper */
.oee-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 3.2em;
    width: 100%;
}

/* Rate Now and Shift Count: same height, same font, no border */
.rate-shift-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: stretch;
    height: 100%;
    min-height: 3.2em;
    width: 100%;
}
.rate-now, .shift-count-small {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50%;
    width: 100%;
}
.rate-now, .shift-count-small {
    width: 100%;
    text-align: center;
    font-size: inherit;
    font-weight: 700;
    line-height: 1.2;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
    background: none;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}
.shift-count-small {
    color: #e0e0e0;
}

/* Remove all table borders */
.machine-table, .machine-table th, .machine-table td {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.machine-table {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background-clip: padding-box;
}

.machine-table tbody td {
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
    padding: 0 0.4em;
    border: none !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

.machine-table tbody td:first-child {
    text-align: center;
    font-size: 1.03em;
    padding-left: 0.6em;
    vertical-align: middle;
}

.machine-name-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-height: 3.2em;
}

.machine-name-text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.machine-lastupdate {
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 400;
    color: #bdbdbd;
    overflow: hidden;
    white-space: nowrap;
}

/* Color utility classes for cell backgrounds */
.cell-lime {
    background-color: #00ff00 !important;
    color: #000 !important;
}

.cell-yellow {
    background-color: #ffff00 !important;
    color: #000 !important;
}

.cell-red {
    background-color: #ff0000 !important;
    color: #fff !important;
}

.cell-purple {
    background-color: #800080 !important;
    color: #fff !important;
}

.cell-blue {
    background-color: #1565c0 !important;
    color: #fff !important;
}

.cell-stop-warn-a {
    background-color: #e9967a !important;
    color: #000 !important;
}

.cell-stop-warn-b {
    background-color: #ff0000 !important;
    color: #fff !important;
}

.cell-white {
    background-color: #ffffff !important;
    color: #000 !important;
}

/* Overspeed: lime background, red text flashing */
.cell-overspeed {
    background-color: #00ff00 !important;
    font-weight: 900;
    animation: overspeed-flash 0.6s step-end infinite;
}

@keyframes overspeed-flash {
    0%, 100% { color: #ff0000; }
    50%       { color: transparent; }
}

/* Check sensor blink */
.check-sensor {
    color: #ff0000;
    font-weight: 900;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Drag and drop row reordering */
.machine-table tbody tr { cursor: grab; }
.machine-table tbody tr.row-dragging { opacity: 0.35; cursor: grabbing; }
.machine-table tbody tr.row-drag-over { outline: 2px solid #0d6efd; outline-offset: -2px; }
.hidden-bar { display: none !important; }

/* Responsive mobile layout — replaces manual F3 mode */
@media (max-width: 768px) {
    /* Single scrollable table */
    #machinesContainer {
        overflow-y: scroll;
        align-items: flex-start;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 4rem);
    }
    #machinesContainer::-webkit-scrollbar { display: none; }

    /* Navigation */
    #tabBar { display: none !important; }
    #f3NavArea { display: flex !important; }
    .navbar .navbar-nav { display: none !important; }
    #statusStrip { margin-left: auto; }

    /* Hide summary row; disable drag cursor on touch */
    #tabSummaryRow { display: none !important; }
    .machine-table tbody tr { cursor: default; }
}

/* Status badge */
#statusBadge {
    font-size: 0.8rem;
}

/* Auto-cycle interval slider */
.form-range {
    accent-color: #0d6efd;
}

/* Card styling for export page */
.card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Responsive: scale down font on smaller screens */
@media (max-width: 1200px) {
    .machine-table {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .machine-table {
        font-size: 0.95rem;
    }

    .machine-table tbody td {
        padding: 0 0.3rem;
    }

    .btn-tab {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Crew History Modal */
#crewHistoryTable thead th {
    background: #1a1a2e;
    font-size: 0.78rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
#crewHistoryTable td {
    font-size: 0.78rem;
    white-space: nowrap;
}
.crew-history-group-hdr td {
    background: #1e3a5f !important;
    color: #7ec8e3;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
}
.crew-duration {
    font-variant-numeric: tabular-nums;
}

/* Crew History Modal — mobile fit (≤576px) */
@media (max-width: 576px) {
    /* Full screen height */
    #crewHistoryModal .modal-dialog {
        height: 100% !important;
        max-height: 100% !important;
    }
    #crewHistoryModal .modal-content {
        height: 100% !important;
        overflow-x: hidden;
    }
    #crewHistoryModal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }
    /* Header: line 1 = title+close, line 2 = buttons */
    #crewHistoryModal .modal-header {
        flex-wrap: wrap;
        padding: 0.4rem 0.5rem;
        row-gap: 0.3rem;
        align-items: center;
    }
    /* Title div (with nav arrows) stretches to fill line 1 beside close button */
    #crewHistoryModal .modal-header > .d-flex:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }
    /* Close button: visually after title, right-aligned on line 1 */
    #crewHistoryModal .modal-header > .btn-close {
        order: 1;
        margin-left: auto;
    }
    /* Button strip: full-width line 2, single row, no wrapping */
    #crewHistoryModal .modal-header .ms-3 {
        order: 2;
        margin-left: 0 !important;
        width: 100%;
        flex-wrap: nowrap;
        gap: 0.2rem !important;
        align-items: center;
    }
    /* "Group by:" label: shrink */
    #crewHistoryModal .modal-header .ms-3 > small {
        font-size: 0.6rem !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
    /* All 4 group-by buttons share the row equally */
    #crewHistoryModal .modal-header .ms-3 .btn-sm {
        flex: 1 1 0;
        min-width: 0;
        font-size: 0.6rem !important;
        padding: 0.06rem 0.15rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Remove the fixed height cap on the table wrapper — modal-body scrolls instead */
    #crewTableWrapper {
        max-height: none !important;
        overflow: visible !important;
    }
    /* Headers: no wrap; data cells: wrap */
    #crewHistoryTable thead th {
        white-space: nowrap;
        font-size: 0.68rem;
        padding: 0.15rem 0.2rem;
    }
    #crewHistoryTable td {
        white-space: normal;
        word-break: break-word;
        font-size: 0.68rem;
        padding: 0.15rem 0.2rem;
    }
    .crew-history-group-hdr td {
        font-size: 0.68rem !important;
        padding: 0.15rem 0.4rem;
    }
}

/* Fix table formatting on EC2 filling margins with no border */

.machine-table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}
 
.machine-table tbody td {
    padding: 0 !important;
}
 
/* Force rate-shift-wrap to fill td completely */
.machine-table tbody td {
    padding: 0 !important;
    height: 1px !important;
}
.rate-shift-wrap {
    height: 100% !important;
}