/**
 * OLAMI Attendance Matrix — Premium Styles
 * Replaces the old .om-matrix-* block from admin-common.css
 * Uses design tokens exclusively — no hardcoded hex values.
 */

/* ── Entrance animation ─────────────────────────────────── */
@keyframes omSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Wrap ────────────────────────────────────────────────── */
.om-matrix-wrap {
    font-family: var(--font-sans);
    animation: omSlideUp 0.3s ease-out;
}

/* ── Card — clip overflow so table scroll stays inside rounded corners ── */
.om-matrix-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;          /* clips scroll content to rounded corners */
    margin-bottom: 20px;
}

/* ── Header ──────────────────────────────────────────────── */
.om-matrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 8px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-hover) 100%);
}

.om-matrix-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.om-matrix-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.om-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.om-stat-num {
    font-weight: 600;
    color: var(--text);
    background: var(--surface-active);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
}

.om-stat-male   { color: var(--info); background: var(--info-bg); }
.om-stat-female  { color: #ec4899; background: #fce7f3; }
.om-stat-latino  { color: var(--warning); background: var(--warning-bg); }
.om-stat-na      { color: #0f766e; background: #ccfbf1; }

/* Trip option breakdown — below the main stats row */
.om-matrix-trip-stats {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
    font-size: 11px;
    color: var(--text-secondary);
}
.om-trip-stats-label {
    font-weight: 600;
    color: var(--text);
    margin-right: 2px;
}
.om-trip-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #ecfeff;
    color: #0e7490;
    border: 1px solid #a5f3fc;
    border-radius: var(--radius-full);
    font-size: 11px;
    white-space: nowrap;
}
.om-trip-stat strong {
    font-weight: 700;
    color: #0c4a6e;
}
.om-trip-stat--other {
    background: #f5f3ff;
    color: #6d28d9;
    border-color: #ddd6fe;
}
.om-trip-stat--other strong { color: #4c1d95; }
.om-trip-stat--empty {
    background: var(--surface-hover);
    color: var(--text-muted);
    border-color: var(--border-light);
    font-style: italic;
}
.om-trip-stat--empty strong { color: var(--text-secondary); }

/* ── Toolbar (search + export) ───────────────────────────── */
.om-matrix-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface);
    flex-wrap: wrap;
}

.om-search-input {
    flex: 1;
    min-width: 140px;
    max-width: 280px;
    padding: 6px 10px 6px 30px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2386868b' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 10px center;
    outline: none;
    transition: border-color 0.2s;
}

.om-search-input:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px var(--info-soft);
}

.om-search-input::placeholder {
    color: var(--text-muted);
}

.om-csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.om-csv-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text);
}

/* ── Table wrapper — scroll stays inside card rounded corners ── */
.om-table-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    position: relative;
}

/* ── Table ────────────────────────────────────────────────── */
.om-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    min-width: 400px;
}

/* ── Sticky thead ─────────────────────────────────────────── */
.om-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 6px 6px;
    text-align: left;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

/* Session header pills */
.om-table th.session {
    text-align: center;
    min-width: 40px;
    padding: 5px 3px;
}

.om-table th.session .om-session-pill {
    display: inline-block;
    background: var(--info-soft);
    color: var(--info);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 600;
    line-height: 1.3;
}

.om-table th.session .om-session-date {
    display: block;
    font-weight: 400;
    font-size: 8px;
    color: var(--text-muted);
    text-transform: none;
    margin-top: 1px;
}

.om-table th.total-col {
    background: var(--surface-active);
    text-align: center;
    cursor: pointer;
    user-select: none;
    min-width: 52px;
}

.om-table th.total-col:hover {
    color: var(--text);
}

.om-table th.status-col {
    background: var(--surface-active);
    text-align: center;
    min-width: 68px;
}

/* ── Sticky first column (student name) ───────────────────── */
.om-table th:first-child,
.om-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    max-width: 150px;
    width: 150px;
}

.om-table thead th:first-child {
    z-index: 4;
    background: var(--surface-hover);
}

/* ── Table body — compact rows, no heavy borders ──────────── */
.om-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    vertical-align: middle;
    font-size: 12px;
}

.om-table tbody tr:last-child td { border-bottom: none; }

.om-table tbody tr:hover td {
    background: var(--surface-hover);
}

/* ── Student cell — compact, not greedy ───────────────────── */
.om-student {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 150px;
}

.om-student-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.om-gender-tag {
    font-size: 8px;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    font-weight: 600;
    flex-shrink: 0;
}

.om-gender-tag.m       { background: var(--info-bg); color: var(--info-text); }
.om-gender-tag.f       { background: var(--danger-bg); color: var(--danger-text); }
.om-gender-tag.unknown { background: var(--surface-active); color: var(--text-secondary); }

.om-latino-tag {
    font-size: 8px;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    font-weight: 500;
    background: var(--warning-bg);
    color: var(--warning-text);
    flex-shrink: 0;
}

/* ── Attendance icon badges ───────────────────────────────── */
.om-table td.session { text-align: center; }

.om-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.om-miss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.om-future {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface-active);
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1;
}

/* ── Total column + progress bar ──────────────────────────── */
.om-table td.total-col {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
    background: var(--surface-hover);
    font-variant-numeric: tabular-nums;
}

.om-total-bar {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--surface-active);
    border-radius: 2px;
    margin-top: 2px;
    overflow: hidden;
}

.om-total-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--success);
    transition: width 0.3s ease;
}

.om-total-fill.at-risk { background: var(--warning); }
.om-total-fill.behind  { background: var(--danger); }

/* ── Status column ────────────────────────────────────────── */
.om-table td.status-col {
    text-align: center;
    background: var(--surface-hover);
}

.om-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
}

.om-status.eligible { background: var(--success-bg); color: var(--success-text); }
.om-status.at-risk  { background: var(--warning-bg); color: var(--warning-text); }
.om-status.behind   { background: var(--danger-bg); color: var(--danger); }

/* ── Row eligibility tinting (soft left accent, no heavy bg) ─ */
.om-row-eligible td:first-child {
    border-left: 3px solid var(--success);
    background: rgba(52, 199, 89, 0.04);
}
.om-row-eligible:hover td:first-child {
    background: rgba(52, 199, 89, 0.08);
}

.om-row-risk td:first-child {
    border-left: 3px solid var(--warning);
    background: rgba(255, 149, 0, 0.04);
}
.om-row-risk:hover td:first-child {
    background: rgba(255, 149, 0, 0.08);
}

.om-row-behind td:first-child {
    border-left: 3px solid var(--danger);
    background: rgba(255, 59, 48, 0.04);
}
.om-row-behind:hover td:first-child {
    background: rgba(255, 59, 48, 0.08);
}

/* ── Trip cell ────────────────────────────────────────────── */
.om-trip-cell {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Footer summary row ───────────────────────────────────── */
.om-table tfoot td {
    padding: 6px 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-hover);
    border-top: 1px solid var(--border-light);
    text-align: center;
    white-space: nowrap;
}

.om-table tfoot td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface-hover);
}

/* ── Empty state ──────────────────────────────────────────── */
.om-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ── Modal chrome improvements ────────────────────────────── */
#oc-program-matrix-modal .oc-modal {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.om-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-hover) 100%);
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}

.om-modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.om-modal-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: var(--surface-active);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.om-modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Eligibility banner ───────────────────────────────────── */
.om-eligibility-banner {
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--info-bg);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--info);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

/* ── Responsive — mobile ──────────────────────────────────── */
@media (max-width: 768px) {
    .om-matrix-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    .om-matrix-title { font-size: 13px; gap: 6px; }
    .om-matrix-stats { gap: 5px; }
    .om-stat { font-size: 10px; }
    .om-stat-num { font-size: 10px; padding: 2px 6px; }
    .om-matrix-trip-stats { font-size: 10px; gap: 4px; margin-top: 6px; padding-top: 6px; }
    .om-trip-stat { padding: 1px 6px; font-size: 10px; }

    .om-matrix-toolbar {
        padding: 6px 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .om-search-input {
        max-width: 100%;
        font-size: 13px;
        padding: 8px 10px 8px 30px;
    }

    .om-csv-btn {
        align-self: flex-end;
    }

    .om-csv-btn span.om-csv-label { display: none; }

    /* Smaller table content on mobile */
    .om-table thead th {
        padding: 4px 4px;
        font-size: 9px;
    }

    .om-table td {
        padding: 3px 4px;
        font-size: 11px;
    }

    .om-table th:first-child,
    .om-table td:first-child {
        max-width: 110px;
        width: 110px;
    }

    .om-student {
        max-width: 110px;
        gap: 3px;
    }

    .om-student-name { font-size: 11px; }

    .om-table th.session {
        min-width: 32px;
    }

    .om-table th.session .om-session-pill {
        font-size: 8px;
        padding: 1px 3px;
    }

    .om-table th.session .om-session-date {
        font-size: 7px;
    }

    .om-check, .om-miss, .om-future {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .om-status {
        font-size: 8px;
        padding: 2px 6px;
    }

    .om-eligibility-banner {
        font-size: 11px;
        padding: 8px 10px;
        gap: 6px;
    }

    .om-modal-header {
        padding: 12px 14px;
    }

    .om-modal-header h2 {
        font-size: 14px;
    }

    #oc-program-matrix-modal .oc-modal {
        max-width: 100vw !important;
        width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0;
        margin: 0;
    }

    #oc-matrix-content {
        max-height: calc(100vh - 60px) !important;
    }
}

/* ── Small screens — extra compact ────────────────────────── */
@media (max-width: 480px) {
    .om-table th:first-child,
    .om-table td:first-child {
        max-width: 90px;
        width: 90px;
    }

    .om-student {
        max-width: 90px;
    }

    .om-student-name { font-size: 10px; }
    .om-gender-tag { display: none; }
    .om-latino-tag { display: none; }

    .om-table th.session {
        min-width: 28px;
    }

    .om-check, .om-miss, .om-future {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
}

/* ── Dark mode coverage via design tokens ─────────────────── */
/* All colors use CSS custom properties redefined by design-tokens.css
   under #omm-wrapper[data-theme="dark"]. Override hardcoded values: */
#omm-wrapper[data-theme="dark"] .om-stat-female {
    color: #f472b6;
    background: rgba(236, 72, 153, 0.15);
}

#omm-wrapper[data-theme="dark"] .om-gender-tag.f {
    color: #f472b6;
    background: rgba(236, 72, 153, 0.15);
}

#omm-wrapper[data-theme="dark"] .om-table td {
    border-bottom-color: rgba(255,255,255,0.04);
}

#omm-wrapper[data-theme="dark"] .om-row-eligible td:first-child {
    background: rgba(48, 209, 88, 0.06);
}
#omm-wrapper[data-theme="dark"] .om-row-risk td:first-child {
    background: rgba(255, 214, 10, 0.06);
}
#omm-wrapper[data-theme="dark"] .om-row-behind td:first-child {
    background: rgba(255, 69, 58, 0.06);
}

/* ════════════════════════════════════════════════════════════════════════
 * V7.34 — Matrix filter bar (option / status / date range / master CSV).
 * V7.36.1 — Selectors prefixed with #oc-matrix-content + !important on
 * theme-conflict-prone properties because the page theme (Elementor on
 * the live site) overrides flat button/input rules with body-scoped
 * selectors. The matrix renders into #oc-matrix-content via AJAX, so
 * scoping there gives high specificity without touching unrelated UI.
 * ══════════════════════════════════════════════════════════════════════ */

#oc-matrix-content .om-matrix-filterbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    padding: 12px 16px !important;
    margin-bottom: 12px;
    background: var(--surface, #fff) !important;
    border-bottom: 1px solid var(--border-color, #e5e7eb) !important;
    border-radius: 8px 8px 0 0;
}
#oc-matrix-content .om-matrix-filterbar__row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px 16px !important;
    align-items: center !important;
    justify-content: space-between !important;
}
#oc-matrix-content .om-matrix-filterbar__group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: center !important;
}
#oc-matrix-content .om-matrix-filterbar__group--right { margin-left: auto !important; }
#oc-matrix-content .om-matrix-filterbar__label {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--text-muted, #6b7280) !important;
    margin-right: 2px;
    line-height: 1 !important;
}
#oc-matrix-content .om-matrix-filterbar__sep {
    color: var(--text-muted, #9ca3af) !important;
    font-size: 12px !important;
}

/* Chips — buttons. Theme overrides these the hardest. !important on the
   pill-defining properties (background, border, padding, radius, color). */
#oc-matrix-content .om-filter-chip {
    display: inline-flex !important;
    align-items: center !important;
    padding: 5px 12px !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    color: var(--text-muted, #6b7280) !important;
    background: #fff !important;
    border: 1px solid var(--border-color, #e5e7eb) !important;
    border-radius: 999px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    text-transform: none !important;
    box-shadow: none !important;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#oc-matrix-content .om-filter-chip:hover {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: var(--text-color, #111827) !important;
}
#oc-matrix-content .om-filter-chip.is-active {
    background: var(--primary-color, #4f46e5) !important;
    border-color: var(--primary-color, #4f46e5) !important;
    color: #fff !important;
}
#oc-matrix-content .om-filter-chip.is-active:hover {
    background: var(--primary-color, #4f46e5) !important;
    color: #fff !important;
    opacity: 0.9;
}

/* Date inputs — themes commonly enforce full-width or chunky padding here. */
#oc-matrix-content .om-filter-date {
    width: auto !important;
    max-width: 160px !important;
    padding: 5px 8px !important;
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    border: 1px solid var(--border-color, #e5e7eb) !important;
    border-radius: 6px !important;
    background: #fff !important;
    color: var(--text-color, #111827) !important;
    box-shadow: none !important;
    cursor: pointer;
}
#oc-matrix-content .om-filter-date:focus {
    outline: none !important;
    border-color: var(--primary-color, #4f46e5) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

#oc-matrix-content .om-filter-clear {
    padding: 5px 12px !important;
    margin-left: 4px;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--text-muted, #6b7280) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
    text-decoration: underline !important;
}
#oc-matrix-content .om-filter-clear:hover { color: var(--danger, #dc2626) !important; }

/* Master CSV — themes love overriding primary button styles. */
#oc-matrix-content .om-master-csv-btn {
    display: inline-flex !important;
    align-items: center !important;
    padding: 7px 16px !important;
    margin: 0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: #fff !important;
    background: var(--primary-color, #4f46e5) !important;
    border: 0 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    text-transform: none !important;
    transition: opacity 0.12s, transform 0.06s;
}
#oc-matrix-content .om-master-csv-btn:hover {
    opacity: 0.92;
    color: #fff !important;
    background: var(--primary-color, #4f46e5) !important;
}
#oc-matrix-content .om-master-csv-btn:active { transform: translateY(1px); }

#omm-wrapper[data-theme="dark"] #oc-matrix-content .om-matrix-filterbar {
    background: rgba(28, 28, 30, 0.95) !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}
#omm-wrapper[data-theme="dark"] #oc-matrix-content .om-filter-chip {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.7) !important;
}
#omm-wrapper[data-theme="dark"] #oc-matrix-content .om-filter-chip:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}
#omm-wrapper[data-theme="dark"] #oc-matrix-content .om-filter-date {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * V7.37.1 — Matrix payment columns (read-only ✓ marks; PD + PF).
 * ═══════════════════════════════════════════════════════════════════════ */

#oc-matrix-content .om-pay-col {
    text-align: center !important;
    white-space: nowrap !important;
    font-size: 11px !important;
    width: 38px !important;
    min-width: 38px !important;
}
#oc-matrix-content .om-pay-cell {
    text-align: center !important;
    padding: 4px 6px !important;
}

