/* ============================================================
   ADS - Bento Grid design layer (loaded LAST, see Core/templates/_styles.html)

   Re-skins the whole application with a Bento Grid system while keeping the
   ADS identity (green #0ea16f, frosted wallpaper, logo, type). It works purely
   by class: no markup, element id, route or script behaviour is changed, so
   every screen, validation and workflow keeps working exactly as before.

   Scale:   tile radius 24 / 20 / 14 / 10   gap 16   inset 12
   Hierarchy: one solid-green moment per view (the active nav item); the key
   stat in each KPI tile gets a soft green tint; everything else is quiet glass.
   ============================================================ */

:root {
    --bento-gap: 16px;
    --bento-inset: 12px;
    --bento-r-xl: 24px;
    --bento-r-lg: 20px;
    --bento-r-md: 14px;
    --bento-r-sm: 10px;
    --bento-line: rgba(15, 23, 42, 0.07);
    --bento-surface: rgba(255, 255, 255, 0.80);
    --bento-tint: rgba(14, 161, 111, 0.07);
    --bento-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 30px -14px rgba(15, 23, 42, 0.16);
    --bento-focus: 0 0 0 3px rgba(14, 161, 111, 0.22);
}

/* ---------- accessibility floor ---------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   SHELL - floating sidebar + floating header (desktop)
   Mobile keeps the existing drawer + bottom bar behaviour.
   ============================================================ */
@media (min-width: 901px) {
    .sidebar {
        top: var(--bento-inset);
        left: var(--bento-inset);
        height: calc(100vh - (var(--bento-inset) * 2));
        border-radius: var(--bento-r-xl);
        border: 1px solid var(--bento-line);
        box-shadow: var(--bento-shadow);
        background: var(--bento-surface);
    }
    .main-content { margin-left: calc(var(--sidebar-w) + var(--bento-inset)); }
    .sidebar-collapsed .main-content { margin-left: calc(var(--sidebar-collapsed-w) + var(--bento-inset)); }

    .header {
        top: var(--bento-inset);
        margin: var(--bento-inset) var(--bento-inset) 0 var(--bento-inset);
        border-radius: var(--bento-r-lg);
        border: 1px solid var(--bento-line);
        box-shadow: var(--bento-shadow);
        background: var(--bento-surface);
        padding: 0 20px;
    }
}
.sidebar-brand { border-bottom: 1px solid var(--bento-line); }
.sidebar-user  { border-bottom: 1px solid var(--bento-line); }

/* Navigation: pill items, one solid-green active tile */
.sidebar-nav { gap: 4px; padding: 12px; }
.sidebar-nav a,
.sidebar-nav button.nav-btn,
.sidebar-nav .nav-group-header {
    border-radius: var(--bento-r-md);
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.sidebar-nav a:hover,
.sidebar-nav button.nav-btn:hover,
.sidebar-nav .nav-group-header:hover { background: var(--bento-tint); }
.sidebar-nav a.active,
.sidebar-nav button.nav-btn.active {
    background: var(--green);
    color: #fff;
    box-shadow: 0 8px 16px -8px rgba(14, 161, 111, 0.7);
}
.sidebar-nav a.active i,
.sidebar-nav a.active .sidebar-text,
.sidebar-nav button.nav-btn.active i,
.sidebar-nav button.nav-btn.active .sidebar-text { color: #fff; }
.sidebar-nav-label { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; }
.nav-group.open > .nav-group-header { background: var(--bento-tint); }
.nav-group-items { border-radius: var(--bento-r-md); }

.header-icon-btn { border-radius: var(--bento-r-md); }
.header-search { border-radius: var(--bento-r-md); }
.notif-panel,
.header-search-results,
.repos-popup {
    border-radius: var(--bento-r-lg);
    border: 1px solid var(--bento-line);
    box-shadow: var(--bento-shadow);
}

/* ============================================================
   PAGES - every screen is a 12-column bento canvas
   Direct children span the full row by default; use .bento-grid
   and the .bento-span-* helpers for tile layouts inside a screen.
   ============================================================ */
.page-screen .page-body {
    padding: 18px 20px 48px;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--bento-gap);
    align-content: start;
}
.page-screen .page-body > * { grid-column: 1 / -1; min-width: 0; }
.page-screen .page-body > .ts-card,
.page-screen .page-body > .form-wrapper-screen { margin-bottom: 0; }

.page-screen-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--gray-900);
    margin: 0;
}
.page-screen-title i {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--bento-r-md);
    background: var(--green-lite);
    border: 1px solid var(--green-mid);
    color: var(--green-dark);
    font-size: 16px;
}
.ts-workflow-hint {
    margin: 0;
    padding: 12px 16px;
    border-radius: var(--bento-r-md);
    background: var(--bento-tint);
    border: 1px solid rgba(14, 161, 111, 0.16);
    color: var(--gray-700);
    line-height: 1.55;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--bento-gap);
    align-items: stretch;
}
.bento-grid > * { min-width: 0; margin-bottom: 0; }
.bento-span-3  { grid-column: span 3; }
.bento-span-4  { grid-column: span 4; }
.bento-span-5  { grid-column: span 5; }
.bento-span-6  { grid-column: span 6; }
.bento-span-7  { grid-column: span 7; }
.bento-span-8  { grid-column: span 8; }
.bento-span-12 { grid-column: 1 / -1; }
@media (max-width: 900px) {
    .bento-grid > [class*="bento-span-"] { grid-column: 1 / -1; }
}

/* ============================================================
   TILES - one radius, one border, one shadow across the app
   ============================================================ */
.ts-card,
.page-screen .ts-card,
.page-screen .stat-card,
.form-wrapper-screen,
.page-screen .exp-distance-builder,
.assigned-tickets-section,
.travel-card,
.user_name {
    border-radius: var(--bento-r-lg);
    border: 1px solid var(--bento-line);
    box-shadow: var(--bento-shadow);
}
.form-wrapper-screen { padding: 22px; background: var(--bento-surface); }
.ts-card h4 { font-size: 15px; font-weight: 700; }

/* Section headers inside tiles */
.section-header,
.page-screen .section-header {
    border-radius: var(--bento-r-md);
    border: 1px solid var(--bento-line);
    padding: 10px 14px;
}
.section-header h3 { font-size: 15.5px; font-weight: 700; }
.section-header h3 i {
    width: 30px; height: 30px; display: inline-grid; place-items: center;
    border-radius: var(--bento-r-sm); background: var(--green-lite); font-size: 13px; margin-right: 6px;
}

/* KPI / stat mini-tiles */
.lv-balance-stat,
.exp-summary-tile,
.dm-exc-stat,
.stat-card {
    border-radius: var(--bento-r-md);
}
.exp-summary-grid { gap: var(--bento-gap); }
.lv-balance-stat-highlight,
.dm-exc-stat-highlight {
    background: var(--green-lite);
    border-color: var(--green-mid);
}
.lv-balance-bar-track { border-radius: 9999px; overflow: hidden; }

/* ============================================================
   DASHBOARD - bento composition
   The three wrappers are flattened (display: contents) so the calendar,
   KPI tiles and ticket table become siblings on one grid, whatever
   mix of cards the active role shows (hidden cards simply drop out and
   `dense` packing closes the gaps).

     [ calendar  5x2 ][ leave 3 ][ WFH 4 ]
     [ calendar      ][ attendance  7    ]
     [ tickets / summary  12             ]
   ============================================================ */
.dash-top-row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: row dense;
    gap: var(--bento-gap);
    align-items: stretch;
    margin-bottom: 0;
}
.dash-top-left,
.dash-mini-row,
.dash-top-right { display: contents; }

.dash-top-row > .lcal-card,
.dash-top-row .lcal-card { grid-column: span 5; grid-row: span 2; margin: 0; }
.dash-top-row #leave-balance-card { grid-column: span 7; margin: 0; }
.dash-top-row #attendance-card    { grid-column: span 7; margin: 0; }
.dash-top-row .dm-exc-card,
.dash-top-row .dm-exc-summary-beside-calendar.ts-card { grid-column: span 7; margin: 0; height: auto; }
.dash-top-row .assigned-tickets-section { grid-column: 1 / -1; height: auto; margin: 0; }
.dash-top-row .lv-balance-card { max-width: none; min-width: 0; }

.dash-bottom-row { gap: var(--bento-gap); margin-top: var(--bento-gap); }
.dash-bottom-row > .ts-card { margin-bottom: 0; }

/* Responsive tiers for the dashboard grid (desktop sidebar is visible down to 901px).
     >= 1101px  full bento above (calendar 5 | leave 3 | WFH 4 / attendance 7)
     901-1100   calendar 6 (2 rows) beside leave + WFH, attendance full row
     <= 900px   drawer layout: calendar full row, leave 5 | WFH 7, rest full row
   This used to collapse to the stacked layout at <= 1280px, which is the CSS
   width of a 1920x1080 screen at 150% Windows scaling (and 1536 @ 125% is only
   just above it) - so those laptops got a stretched, over-tall dashboard. */
@media (min-width: 901px) and (max-width: 1100px) {
    .dash-top-row .lcal-card { grid-column: span 6; grid-row: span 2; }
    .dash-top-row #leave-balance-card { grid-column: span 6; }
    .dash-top-row #attendance-card,
    .dash-top-row .dm-exc-card,
    .dash-top-row .dm-exc-summary-beside-calendar.ts-card { grid-column: span 12; }

    /* Keep the ticket table readable: scroll inside its own wrapper rather
       than crushing the Title column (mobile <= 768px has its own layout). */
    #assigned-tickets-section .tickets-table { min-width: 640px; }
}
@media (max-width: 900px) {
    .dash-top-row .lcal-card { grid-column: span 12; grid-row: auto; }
    .dash-top-row #leave-balance-card { grid-column: span 12; }
    .dash-top-row #attendance-card,
    .dash-top-row .dm-exc-card,
    .dash-top-row .dm-exc-summary-beside-calendar.ts-card { grid-column: span 12; }
}
/* Ticket "#" column: 56px (minus cell padding) clipped 4-digit ticket numbers
   such as "#1000" to "#1...". Desktop/tablet table only. */
@media (min-width: 769px) {
    #assigned-tickets-section .tickets-table th:nth-child(1),
    #assigned-tickets-section .tickets-table td:nth-child(1) { width: 76px; }
}
@media (max-width: 760px) {
    .dash-top-row { gap: 12px; }
    .dash-top-row > *,
    .dash-top-row .lcal-card,
    .dash-top-row #leave-balance-card,
    .dash-top-row #wfh-summary-card,
    .dash-top-row #attendance-card { grid-column: 1 / -1; }
    .page-screen .page-body { padding: 14px 12px 96px; gap: 12px; }
}

/* ============================================================
   FILTERS, SEARCH, PAGINATION
   ============================================================ */
.ticket-filters-row,
.page-screen .ticket-filters-row,
.exp-toolbar {
    border-radius: var(--bento-r-md);
    border: 1px solid var(--bento-line);
    padding: 10px 12px;
}
.tickets-pagination {
    border-radius: var(--bento-r-md);
    border: 1px solid var(--bento-line);
    padding: 8px 12px;
}

/* ============================================================
   TABLES
   ============================================================ */
.tickets-table-wrap,
.ts-table-wrap,
.exp-table-wrap {
    border-radius: var(--bento-r-md);
    border: 1px solid var(--bento-line);
}
.tickets-table thead th,
.ts-table thead th,
.exp-admin-clean-table thead th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 1px solid var(--bento-line);
}
.tickets-table thead th:first-child,
.ts-table thead th:first-child { border-top-left-radius: var(--bento-r-md); }
.tickets-table thead th:last-child,
.ts-table thead th:last-child  { border-top-right-radius: var(--bento-r-md); }
.tickets-table tbody tr,
.ts-table tbody tr,
.exp-admin-clean-table tbody tr { transition: background 0.12s ease; }
.tickets-table tbody td,
.ts-table tbody td { border-bottom: 1px solid var(--bento-line); }

/* ============================================================
   FORMS - related fields grouped into soft tiles
   ============================================================ */
.form-grid { gap: var(--bento-gap); }
.form-grid > .field-group {
    padding: 14px 16px;
    border-radius: var(--bento-r-md);
    border: 1px solid var(--bento-line);
    background: rgba(255, 255, 255, 0.62);   /* no backdrop-filter: keeps dropdowns un-clipped */
}
.field-label { font-size: 12.5px; font-weight: 600; color: var(--gray-600); text-transform: none; letter-spacing: 0; }

.ts-input, .ts-select, .ts-textarea,
.ticket-filter-select,
.field-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field-group select,
.field-group textarea {
    border-radius: 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ts-input:focus, .ts-select:focus, .ts-textarea:focus,
.ticket-filter-select:focus,
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    border-color: var(--green);
    box-shadow: var(--bento-focus);
    outline: none;
}
.ts-form-row { gap: 10px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.ts-btn,
.refresh-btn,
.github-login-btn,
.btn-primary,
button.primary {
    border-radius: 12px;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.ts-btn:active, .refresh-btn:active { transform: translateY(1px); }
.ts-btn-primary { box-shadow: 0 8px 16px -10px rgba(14, 161, 111, 0.75); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    border-radius: var(--bento-r-xl);
    border: 1px solid var(--bento-line);
    box-shadow: 0 30px 70px -20px rgba(15, 23, 42, 0.35);
}
.modal-header { border-bottom: 1px solid var(--bento-line); padding-bottom: 12px; }

/* ============================================================
   MOBILE BOTTOM BAR + LOGIN
   ============================================================ */
@media (max-width: 900px) {
    .mobile-bottom-nav {
        border-radius: var(--bento-r-lg) var(--bento-r-lg) 0 0;
        border: 1px solid var(--bento-line);
        border-bottom: 0;
        box-shadow: 0 -10px 30px -16px rgba(15, 23, 42, 0.25);
    }
}
.login-container {
    border-radius: var(--bento-r-xl);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 30px 70px -24px rgba(15, 23, 42, 0.45);
}
.login-error { border-radius: var(--bento-r-md); }

/* ============================================================
   DEVICE ACCESS (Super Admin) tiles
   ============================================================ */
.da-grid { align-items: stretch; }
.da-switch-card { grid-column: span 5; }
.da-roles-card  { grid-column: span 7; }
@media (max-width: 1100px) {
    .da-switch-card, .da-roles-card { grid-column: 1 / -1; }
}
.da-card-title { font-size: 15.5px; font-weight: 700; color: var(--gray-900); margin-bottom: 12px; }
.da-card-hint  { font-size: 13px; color: var(--gray-600); line-height: 1.5; margin-bottom: 14px; }
.da-switch-row { display: flex; align-items: center; gap: 16px; }
.da-switch {
    position: relative; flex: none;
    width: 68px; height: 38px; border-radius: 9999px;
    border: 1px solid var(--gray-200); background: var(--gray-200);
    cursor: pointer; transition: background 0.2s ease, border-color 0.2s ease;
}
.da-switch .da-switch-knob {
    position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25); transition: transform 0.2s ease;
}
.da-switch.on { background: var(--green); border-color: var(--green-dark); }
.da-switch.on .da-switch-knob { transform: translateX(30px); }
.da-switch:disabled { opacity: 0.6; cursor: progress; }
.da-state-text { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.da-state-sub  { font-size: 13px; color: var(--gray-600); margin-top: 3px; line-height: 1.45; }
.da-meta { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--bento-line); font-size: 12.5px; color: var(--gray-600); }
.da-roles-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px; margin-bottom: 16px;
}
.da-role {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    border: 1px solid var(--bento-line); border-radius: var(--bento-r-md);
    background: #fff; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--gray-900);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.da-role:hover { border-color: var(--green-mid); }
.da-role:has(input:checked) { border-color: var(--green-mid); background: var(--green-lite); }
.da-role input { width: 17px; height: 17px; accent-color: var(--green); flex: none; }
#nav-device-access-badge { background: var(--green); color: #fff; }

/* ============================================================
   MASTER DATA -> Stage Mapping (GitHub label -> Stage) tiles
   ============================================================ */
.sm-grid { align-items: start; }
.sm-tile {
    padding: 18px; border-radius: var(--bento-r-lg);
    border: 1px solid var(--bento-line);
    background: var(--bento-surface);
    box-shadow: var(--bento-shadow);
}
.sm-tile-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.sm-tile-title i {
    width: 30px; height: 30px; display: inline-grid; place-items: center;
    border-radius: var(--bento-r-sm); background: var(--green-lite); color: var(--green-dark); font-size: 13px;
}
.sm-hint { font-size: 12.5px; line-height: 1.5; color: var(--gray-600); margin: 0 0 14px; }
.sm-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sm-field label { font-size: 12.5px; font-weight: 600; color: var(--gray-600); }
.sm-field input {
    width: 100%; box-sizing: border-box; padding: 9px 12px; font: inherit; font-size: 14px;
    border: 1px solid var(--gray-200); border-radius: 12px; background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sm-field input:focus { border-color: var(--green); box-shadow: var(--bento-focus); outline: none; }
.sm-req { color: #dc2626; }
.sm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.sm-list-tile { padding: 14px; }
.sm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sm-search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.sm-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 12px; }
.sm-search input {
    width: 100%; box-sizing: border-box; padding: 9px 12px 9px 32px; font: inherit; font-size: 13.5px;
    border: 1px solid var(--gray-200); border-radius: 12px; background: #fff;
}
.sm-search input:focus { border-color: var(--green); box-shadow: var(--bento-focus); outline: none; }
.sm-count { font-size: 12.5px; color: var(--gray-600); }
.sm-table-wrap { max-height: 560px; overflow: auto; border: 1px solid var(--bento-line); border-radius: var(--bento-r-md); background: #fff; }
.sm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sm-table thead th {
    position: sticky; top: 0; z-index: 1; background: #fff; text-align: left;
    padding: 10px 14px; font-size: 12.5px; font-weight: 600; color: var(--gray-600);
    border-bottom: 1px solid var(--bento-line);
}
.sm-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--bento-line); vertical-align: middle; }
.sm-table tbody tr:last-child td { border-bottom: 0; }
.sm-table tbody tr:hover { background: var(--bento-tint); }
.sm-row-editing, .sm-table tbody tr.sm-row-editing:hover { background: var(--green-lite); }
.sm-label { font-weight: 600; color: var(--gray-900); word-break: break-word; }
.sm-stage-pill {
    display: inline-block; padding: 3px 11px; border-radius: 9999px; font-size: 12.5px; font-weight: 600;
    background: var(--green-lite); border: 1px solid var(--green-mid); color: var(--green-dark);
}
.sm-col-actions { width: 96px; text-align: right !important; white-space: nowrap; }
.sm-empty { text-align: center; color: var(--gray-400); padding: 28px 14px !important; }


/* Leave & Balances card - one calm row of balances (Leave | Comp-Off | WFH) */
.lvb-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.lvb-item { padding: 10px 12px; border: 1px solid rgba(100, 116, 139, 0.18); border-radius: 10px; background: rgba(255, 255, 255, 0.35); min-width: 0; }
.lvb-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #64748b; }
.lvb-value { font-size: 26px; font-weight: 700; line-height: 1.15; margin-top: 4px; color: inherit; }
.lvb-unit { font-size: 12px; font-weight: 500; color: #64748b; margin-left: 4px; }
.lvb-item .lv-balance-bar-track { margin: 8px 0; }
.lvb-notes { font-size: 11px; color: #64748b; line-height: 1.45; margin-top: 6px; }
.lvb-loading { font-size: 12px; color: #64748b; padding: 8px 0; grid-column: 1 / -1; }
#dash-mini-row > #leave-balance-card { flex: 1 1 100%; }
