/* ============================================================
   style-13-operations.css — Operations Analytics (FEAT-025)
   Prefix: ops-*
   Supports both light and dark themes.
   ============================================================ */

/* ── Page layout ──────────────────────────────────────────── */
.ops-page {
    padding: 24px;
    min-height: 100vh;
    background: var(--bg-primary, #0e1117);
    color: var(--text-primary, #e8eaf0);
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

.ops-header {
    margin-bottom: 20px;
}

.ops-page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #e8eaf0;
    margin: 0;
}

/* ── Date bar ─────────────────────────────────────────────── */
.ops-date-bar {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 16px;
    background: #1e2130;
    border-radius: 8px;
}

.ops-date-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ops-period-b-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ops-period-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ops-period-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #adb5bd;
    white-space: nowrap;
}

/* ── Shortcut buttons ─────────────────────────────────────── */
.ops-shortcut-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ops-sh-btn {
    padding: 4px 10px;
    font-size: 0.78rem;
    background: transparent;
    border: 1px solid #2a2f45;
    border-radius: 4px;
    color: #adb5bd;
    cursor: pointer;
    transition: all 0.15s;
}

.ops-sh-btn:hover {
    border-color: #e8734a;
    color: #e8734a;
}

.ops-sh-active,
.ops-sh-btn.ops-sh-active {
    border-color: #e8734a;
    color: #e8734a;
    background: rgba(232, 115, 74, 0.1);
}

/* ── Compare toggle ───────────────────────────────────────── */
.ops-compare-btn {
    align-self: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    background: transparent;
    border: 2px solid #e8734a;
    border-radius: 6px;
    color: #e8734a;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.ops-compare-btn:hover {
    background: rgba(232, 115, 74, 0.15);
}

.ops-compare-btn.ops-compare-active {
    background: #e8734a;
    color: #fff;
}

/* ── Tab bar (desktop) ────────────────────────────────────── */
.ops-tabs-desktop {
    margin-bottom: 20px;
}

.ops-tab-bar {
    display: flex !important;
    border-bottom: 2px solid #2a2f45;
    margin-bottom: 0;
}

.ops-tab {
    background: transparent !important;
    border: none !important;
    color: #adb5bd !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    border-bottom: 3px solid transparent !important;
    transition: all 0.15s !important;
}

.ops-tab:hover {
    color: #e8734a !important;
}

.ops-tab-selected {
    color: #f4a724 !important;
    border-bottom: 3px solid #f4a724 !important;
    font-weight: 600 !important;
}

/* Dash internal tab overrides */
.ops-tab-bar .tab.tab--selected {
    background: transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 3px solid #f4a724 !important;
    color: #f4a724 !important;
    font-weight: 600 !important;
}

.ops-tab-bar .tab {
    background: transparent !important;
    border: none !important;
    border-bottom: 3px solid transparent !important;
    color: #adb5bd !important;
}

.ops-tab-bar .tab:hover {
    color: #e8734a !important;
}

/* ── Mobile dropdown ──────────────────────────────────────── */
.ops-tabs-mobile {
    display: none;
    margin-bottom: 16px;
}

.ops-tab-drop .Select-control {
    background: #1e2130;
    border-color: #2a2f45;
    color: #e8eaf0;
}

/* ── Tab content area ─────────────────────────────────────── */
.ops-tab-content {
    margin-top: 4px;
}

/* ── KPI cards ────────────────────────────────────────────── */
.ops-kpi-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.ops-kpi-card {
    flex: 1;
    min-width: 110px;
    max-width: 200px;
    background: #1e2130;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
    border: 1px solid #2a2f45;
    transition: border-color 0.15s;
}

.ops-kpi-card:hover {
    border-color: #e8734a;
}

.ops-kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #e8734a;
    line-height: 1.2;
}

.ops-kpi-label {
    font-size: 0.75rem;
    color: #adb5bd;
    margin-top: 4px;
}

/* ── Compare mode KPI layout ──────────────────────────────── */
.ops-compare-kpi-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.ops-compare-half {
    flex: 1;
    padding: 12px;
    background: #161b2a;
    border-radius: 8px;
    border: 1px solid #2a2f45;
}

.ops-compare-period-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e8734a;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Status chips ─────────────────────────────────────────── */
.ops-status-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.ops-chip {
    padding: 4px 12px;
    font-size: 0.8rem;
    border: 1px solid #2a2f45;
    border-radius: 20px;
    background: transparent;
    color: #adb5bd;
    cursor: pointer;
    transition: all 0.15s;
}

.ops-chip:hover {
    border-color: #e8734a;
    color: #e8734a;
}

.ops-chip-active {
    background: #e8734a;
    border-color: #e8734a;
    color: #fff;
    font-weight: 600;
}

/* ── Data table ───────────────────────────────────────────── */
.ops-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #2a2f45;
}

.ops-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ops-data-table thead th {
    background: #161b2a;
    color: #adb5bd;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    border-bottom: 2px solid #2a2f45;
    white-space: nowrap;
}

.ops-data-table tbody tr {
    border-bottom: 1px solid #1a2038;
    transition: background 0.1s;
}

.ops-data-table tbody tr:hover {
    background: rgba(232, 115, 74, 0.05);
}

.ops-data-table tbody td {
    padding: 10px 12px;
    color: #c9d1d9;
    vertical-align: middle;
}

/* Alternating row shade */
.ops-data-table tbody tr:nth-child(even) {
    background: #111622;
}

.ops-data-table tbody tr:nth-child(even):hover {
    background: rgba(232, 115, 74, 0.07);
}

/* ── Driver row — expand/collapse ─────────────────────────── */
.ops-driver-row {
    cursor: pointer;
}

.ops-driver-row-expanded {
    background: #1a1f30 !important;
}

.ops-expand-th,
.ops-expand-col {
    width: 24px;
    min-width: 24px;
    text-align: center;
    color: #adb5bd;
    font-size: 0.8rem;
}

/* ── Status badge ─────────────────────────────────────────── */
.ops-status-badge {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.ops-badge-text {
    font-size: 0.85rem;
    font-weight: 500;
}

.ops-lateness {
    font-size: 0.78rem;
    color: #adb5bd;
    margin-left: 4px;
}

/* ── Route link button ────────────────────────────────────── */
.ops-route-link {
    background: none;
    border: none;
    padding: 0;
    color: #e8734a;
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.15s;
}

.ops-route-link:hover {
    text-decoration-color: #e8734a;
}

/* ── Breadcrumb (route filter active) ─────────────────────── */
.ops-breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(232, 115, 74, 0.08);
    border-left: 3px solid #e8734a;
    border-radius: 4px;
}

.ops-back-btn {
    background: none;
    border: none;
    color: #e8734a;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0;
    font-weight: 600;
}

.ops-back-btn:hover {
    text-decoration: underline;
}

.ops-breadcrumb-label {
    color: #adb5bd;
    font-size: 0.875rem;
}

/* ── Drill-down sub-table ─────────────────────────────────── */
.ops-drilldown-row td {
    padding: 0 !important;
    background: #0e1117;
}

.ops-drilldown-container {
    padding: 16px 20px;
    background: #131825;
    border-top: 2px solid #e8734a;
    border-bottom: 1px solid #2a2f45;
}

.ops-drilldown-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e8734a;
    margin-bottom: 12px;
}

.ops-drilldown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.ops-drilldown-table th {
    color: #6c757d;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-bottom: 1px solid #1a2038;
}

.ops-drilldown-table td {
    padding: 7px 10px;
    color: #adb5bd;
    border-bottom: 1px solid #1a1f30;
}

.ops-drilldown-table tr:nth-child(even) td {
    background: #1a1f30;
}

.ops-drilldown-empty {
    padding: 12px 16px;
    color: #6c757d;
    font-style: italic;
    font-size: 0.85rem;
}

/* ── Pagination ───────────────────────────────────────────── */
.ops-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid #2a2f45;
}

.ops-page-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    background: #1e2130;
    border: 1px solid #2a2f45;
    border-radius: 5px;
    color: #e8eaf0;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;          /* touch-friendly */
    min-width: 44px;
}

.ops-page-btn:hover:not(:disabled) {
    border-color: #e8734a;
    color: #e8734a;
}

.ops-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.ops-page-info {
    color: #adb5bd;
    font-size: 0.875rem;
}

/* ── Info / warning banner ────────────────────────────────── */
.ops-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    background: #1e2130;
    border-left: 3px solid #adb5bd;
    border-radius: 4px;
    margin-bottom: 16px;
}

.ops-info-banner-warning {
    border-left-color: #ffc107 !important;
    background: rgba(255, 193, 7, 0.07);
}

.ops-banner-icon {
    font-size: 1rem;
    flex-shrink: 0;
    padding-top: 1px;
}

.ops-banner-text {
    color: #adb5bd;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ── Error banner ─────────────────────────────────────────── */
.ops-error-banner {
    padding: 12px 16px;
    background: rgba(232, 115, 74, 0.12);
    border: 1px solid rgba(232, 115, 74, 0.4);
    border-radius: 6px;
    color: #e8734a;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

/* ── Empty state ──────────────────────────────────────────── */
.ops-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.ops-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.ops-empty-msg {
    font-size: 1rem;
    color: #adb5bd;
    margin-bottom: 6px;
}

.ops-empty-sub {
    font-size: 0.85rem;
    color: #6c757d;
}

/* ── Loading skeleton ─────────────────────────────────────── */
.ops-loading-skeleton {
    padding: 10px 0;
}

.ops-skeleton-kpi-row {
    height: 80px;
    background: linear-gradient(90deg, #1e2130 25%, #232840 50%, #1e2130 75%);
    background-size: 200% 100%;
    animation: ops-shimmer 1.4s infinite;
    border-radius: 8px;
    margin-bottom: 16px;
}

.ops-skeleton-table {
    height: 200px;
    background: linear-gradient(90deg, #1e2130 25%, #232840 50%, #1e2130 75%);
    background-size: 200% 100%;
    animation: ops-shimmer 1.4s infinite;
    border-radius: 8px;
}

@keyframes ops-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ══════════════════════════════════════════════════════════════ */
body[data-theme="light"] .ops-page {
    background: #f5f6fa;
    color: #1a1a2e;
}

body[data-theme="light"] .ops-page-title {
    color: #1a1a2e;
}

body[data-theme="light"] .ops-date-bar,
body[data-theme="light"] .ops-kpi-card,
body[data-theme="light"] .ops-compare-half {
    background: #ffffff;
    border-color: #dee2e6;
}

body[data-theme="light"] .ops-data-table thead th {
    background: #f8f9fa;
    color: #495057;
}

body[data-theme="light"] .ops-data-table tbody td {
    color: #343a40;
}

body[data-theme="light"] .ops-data-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

body[data-theme="light"] .ops-info-banner {
    background: #f8f9fa;
}

body[data-theme="light"] .ops-info-banner-warning {
    background: rgba(255, 193, 7, 0.1);
}

body[data-theme="light"] .ops-drilldown-container {
    background: #f0f1f5;
}

body[data-theme="light"] .ops-drilldown-table td {
    color: #495057;
}

body[data-theme="light"] .ops-drilldown-table tr:nth-child(even) td {
    background: #e9ecef;
}

body[data-theme="light"] .ops-table-wrap {
    border-color: #dee2e6;
}

body[data-theme="light"] .ops-chip {
    border-color: #dee2e6;
    color: #495057;
}

body[data-theme="light"] .ops-page-btn {
    background: #ffffff;
    border-color: #dee2e6;
    color: #343a40;
}

body[data-theme="light"] .ops-kpi-label {
    color: #6c757d;
}

body[data-theme="light"] .ops-tab-bar .tab {
    color: #495057 !important;
}

body[data-theme="light"] .ops-skeleton-kpi-row,
body[data-theme="light"] .ops-skeleton-table {
    background: linear-gradient(90deg, #e9ecef 25%, #dee2e6 50%, #e9ecef 75%);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤768px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    .ops-page {
        padding: 12px;
    }

    /* Tabs → dropdown */
    .ops-tabs-desktop {
        display: none;
    }

    .ops-tabs-mobile {
        display: block;
    }

    /* Date bar stacks vertically */
    .ops-date-bar {
        flex-direction: column;
        gap: 12px;
    }

    .ops-period-b-wrap {
        /* stacks below Period A */
    }

    .ops-compare-btn {
        align-self: stretch;
        text-align: center;
    }

    /* KPI cards: 2 per row */
    .ops-kpi-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* 5th KPI card on Dispatch: centred on its own row */
    .ops-kpi-card:last-child:nth-child(5) {
        grid-column: 1 / -1;
        max-width: calc(50% - 5px);
        margin: 0 auto;
    }

    .ops-kpi-card {
        max-width: none;
    }

    /* Compare mode: stacked */
    .ops-compare-kpi-row {
        flex-direction: column;
    }

    /* Tables: horizontal scroll */
    .ops-table-wrap {
        overflow-x: auto;
    }

    .ops-data-table td,
    .ops-data-table th {
        min-width: 80px;
        white-space: nowrap;
    }

    .ops-data-table td:first-child,
    .ops-data-table th:first-child {
        position: sticky;
        left: 0;
        background: #0e1117;
        z-index: 1;
    }

    body[data-theme="light"] .ops-data-table td:first-child,
    body[data-theme="light"] .ops-data-table th:first-child {
        background: #f5f6fa;
    }

    /* Status min-width */
    .ops-status-badge {
        min-width: 90px;
    }

    /* Pagination: touch-friendly */
    .ops-page-btn {
        min-height: 44px;
        min-width: 60px;
    }
}
