/* public/assets/css/responsive.css
   KHMER HRMS — Responsive Breakpoint System
   Season: S00 — Project Zero Setup
   Reference: Master Reference Section 6.5 (Breakpoints), 6.6 (Bottom Nav),
              6.7 (Alpine.js Sidebar Toggle)

   Established now so every view built from S01 onward already has the
   full mobile-first grid, sidebar/hamburger, table-card, print, and
   PWA-safe-area rules available — Rule #11/#12.
*/

/* ━━━ BASE — mobile first ━━━ */
.container    { width: 100%; padding: 0 16px; margin: 0 auto; }
.sidebar      { display: none; }
/* Body content used to have ZERO side padding below 768px — every
   page's cards/tables sat flush against the phone's screen edges.
   16px matches the 8px spacing scale (Premium UI §4) and the
   .container padding used elsewhere at this size. */
.main-content { width: 100%; padding: 16px; max-width: 100vw; }
.stat-cards   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row     { display: flex; flex-direction: column; gap: 12px; }
.btn-group    { display: flex; flex-direction: column; width: 100%; }
.page-header  { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: var(--space-3, 24px); }
.tabs-nav     { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.modal        { width: 95vw; max-height: 90vh; overflow-y: auto; }
.card-grid    { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ━━━ SM 576px ━━━ */
@media (min-width: 576px) {
    .container  { max-width: 540px; padding: 0 20px; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .card-grid  { grid-template-columns: 1fr 1fr; }
}

/* ━━━ MD 768px — Tablet ━━━ */
@media (min-width: 768px) {
    .container       { max-width: 720px; }
    .sidebar         { display: flex; flex-direction: column; width: 240px; flex-shrink: 0; }
    .layout-shell    { display: flex; min-height: 100vh; }
    .main-content    { flex: 1; min-width: 0; padding: 24px; }
    .stat-cards      { grid-template-columns: repeat(3, 1fr); }
    .form-row        { flex-direction: row; }
    .btn-group       { flex-direction: row; width: auto; }
    .page-header     { flex-direction: row; align-items: center; }
    .card-grid       { grid-template-columns: 1fr 1fr; }
    .modal           { width: 600px; }
    .sidebar-overlay { display: none !important; }
}

/* ━━━ LG 992px ━━━ */
@media (min-width: 992px) {
    .container  { max-width: 960px; }
    .stat-cards { grid-template-columns: repeat(4, 1fr); }
    .card-grid  { grid-template-columns: repeat(3, 1fr); }
    .sidebar    { width: 260px; }
    .modal      { width: 720px; }
}

/* ━━━ XL 1200px ━━━ */
@media (min-width: 1200px) {
    .container    { max-width: 1140px; }
    .card-grid    { grid-template-columns: repeat(4, 1fr); }
    .sidebar      { width: 280px; }
    .main-content { padding: 32px; }
}

/* ━━━ XXL 1400px ━━━ */
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* ━━━ MOBILE NAV HAMBURGER ━━━ */
.hamburger           { display: flex; cursor: pointer; padding: 8px; background: none; border: none; }
/* Hamburger bars are now an inline SVG (.hamburger-icon) - see app.css */
.sidebar-overlay     { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; }
.sidebar.mobile-open { display: flex !important; position: fixed; top: 0; left: 0; height: 100vh; z-index: 50; transform: translateX(0); }
.sidebar.sidebar-hidden { display: none !important; }
@media (min-width: 768px) { .sidebar.sidebar-hidden { display: none !important; } }

@media (min-width: 768px) {
    .hamburger { display: flex; }
}

/* ━━━ MOBILE TOP BAR CLEAN-UP (reported fix) ━━━
   On phones the current page name used to sit in the header bar next
   to the hamburger, wrapping onto 3-4 lines and pushing the action
   icons out of place. Below 768px it's dropped entirely — the sidebar
   drawer / bottom nav / page's own <h1> already say where you are, so
   nothing is lost, only the cramped duplicate label. Full-width action
   row (hamburger left, icons right) gets the freed-up space. The
   full-name pill in the user menu is also hidden on very narrow phones
   (<576px) — just the avatar stays, tap it to see the name/role in the
   dropdown — the same "icon over label" trade already applied to the
   KH/EN switcher above 576px. */
@media (max-width: 767.98px) {
    .top-bar-title { display: none; }
}
@media (max-width: 575.98px) {
    .user-menu-name { display: none; }
    .user-menu-trigger { padding: 4px; }
}

/* ━━━ TABLE RESPONSIVE ━━━
   FIX (reported): .data-table used to be forced to `display: block`
   in the unscoped mobile-first BASE rules above, with no min-width
   media query ever setting it back to a real `table` display. A
   block-level <table> stops the browser's table layout algorithm
   from stretching columns to fill the container, so every list page
   (Mobile/QR Check-In Log, Employees, etc.) rendered with a big empty
   gap to the right of the table on tablet/desktop — the .table-wrap
   card looked full-width, but the <table> inside it did not.
   `display: block` is only actually needed on narrow phones (paired
   with .table-wrap's own overflow-x: auto) to allow raw horizontal
   scrolling for tables that AREN'T using the card-style `.table-card`
   layout below; from 768px up, tables go back to their normal
   `table` display so width: 100% (app.css) stretches every column to
   fill the page properly. */
@media (max-width: 767.98px) {
    .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ━━━ TABLE RESPONSIVE (card-style rows on mobile) ━━━ */
@media (max-width: 767px) {
    .table-card thead        { display: none; }
    .table-card tbody tr     { display: block; border: 1px solid var(--border); border-radius: var(--radius, 14px); margin-bottom: 12px; padding: 12px; }
    .table-card tbody td     { display: flex; justify-content: space-between; padding: 4px 0; border: none; font-size: 13px; }
    .table-card tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: 8px;
    }
}

/* ━━━ MOBILE BOTTOM NAVIGATION (Section 6.6) ━━━
   khmer24.com's own mobile app uses a floating, rounded-top tab bar
   with its single most important action ("Post/Sell") raised as a
   circular button that pops above the bar line. Mirrored here: the
   bar gets rounded top corners + a real elevation shadow instead of
   a flat bordered strip, and — when the signed-in user has
   attendance.checkin — "Check In" becomes that same raised circular
   center button, since it's the one action mobile/field employees
   open this app for most often. Everything else (Dashboard, Profile,
   Logout) stays a normal flat tab; the whole row still shares one
   base class so a user WITHOUT attendance.checkin simply gets a
   plain 3-tab bar with no raised button, no separate CSS path. */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 62px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.10);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-size: 10px; color: var(--text-muted);
    text-decoration: none; padding: 8px 4px;
    transition: color 0.15s;
    min-width: 0;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 20px; height: 20px; margin-bottom: 2px; }
/* With Chat added (S16 UI pass) the row can hold up to 5 tabs — keep
   every label to one line instead of wrapping/overlapping the icon
   above it on the narrowest phones (Section 6.5 xs, 320–359px). */
.bottom-nav-item span:last-child {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unread-chat indicator on the bottom-nav Chat tab — same small red
   dot language as .badge-dot on the sidebar link (app.css), just
   repositioned to sit on the icon of a column-flex tab instead of a
   row-flex sidebar link. */
.bottom-nav-icon-wrap { position: relative; display: inline-flex; }
.bottom-nav-badge {
    position: absolute;
    top: -4px; right: -8px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}

/* The raised center action (e.g. Check In). Negative margin-top
   pops the circular icon above the bar's top edge; the label stays
   on the normal baseline with its siblings so the row still reads
   as one tidy tab strip, not a floating island. */
.bottom-nav-primary { color: var(--primary); font-weight: 600; }
.bottom-nav-primary-icon {
    display: flex; align-items: center; justify-content: center;
    width: 46px; height: 46px;
    margin-top: -26px;
    margin-bottom: 4px;
    border-radius: 999px;
    background: linear-gradient(160deg, var(--accent), var(--primary));
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 45%, transparent);
    border: 3px solid var(--surface);
}
.bottom-nav-primary-icon svg {
    width: 20px; height: 20px; margin-bottom: 0;
    stroke: #fff; color: #fff;
}

@media (max-width: 767px) {
    .bottom-nav   { display: flex; }
    .main-content { padding-bottom: 74px; }
}

/* ━━━ PRINT ━━━ */
@media print {
    .sidebar, .top-bar, .hamburger, .btn, .no-print, nav, .pagination { display: none !important; }
    body    { background: white; color: black; font-family: 'Battambang', 'NotoSansKhmer', 'Barlow', sans-serif; font-size: 10pt; }
    table   { border-collapse: collapse; width: 100%; }
    th, td  { border: 1px solid #ccc; padding: 4px 8px; }
    .page-break { page-break-before: always; }
    @page   { margin: 15mm; size: A4; }
    a       { text-decoration: none; color: black; }
}

/* ━━━ PWA SAFE AREAS (iPhone notch) ━━━ */
.top-bar    { padding-top: env(safe-area-inset-top); }
.sidebar    { padding-bottom: env(safe-area-inset-bottom); }


/* S09 FINAL shell overrides — fixed desktop rail + fixed topbar.
   app.css owns the full shell geometry; these rules only protect
   responsive behavior from earlier mobile-first declarations. */
@media (min-width: 768px) {
    .layout-shell { display: block; }
    .sidebar { display: flex; }
    .sidebar.sidebar-hidden { display: flex !important; }
    .hamburger { display: flex; }
}
@media (max-width: 767.98px) {
    .layout-shell { display: block; }
    .sidebar { display: flex; }
    .sidebar.sidebar-hidden { display: flex !important; }
}


/* S09 FINAL V9 — responsive table integrity */
@media (max-width: 767.98px) {
    /* Non-card tables keep normal table-cell geometry and can scroll
       horizontally inside .table-wrap. */
    .data-table:not(.table-card) td.actions,
    .data-table:not(.table-card) th:last-child {
        width: 180px !important;
        min-width: 180px !important;
        max-width: 240px !important;
        text-align: right !important;
    }

    .data-table:not(.table-card) td.actions {
        display: table-cell !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
    }

    .data-table:not(.table-card) td.actions > form,
    .data-table:not(.table-card) td.actions > a,
    .data-table:not(.table-card) td.actions > button,
    .data-table:not(.table-card) td.actions > .btn {
        display: inline-flex !important;
        width: auto;
        flex: 0 0 auto !important;
    }

    /* Card tables intentionally use a flex action lane, but every other
       cell still shares the same row card and spacing. */
    .data-table.table-card tbody td.actions {
        display: flex !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
        text-align: left !important;
        padding-right: 0 !important;
    }

    .table-wrap {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        scrollbar-gutter: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        margin: 0 !important;
    }
}

@media (min-width: 768px) {
    .table-wrap {
        width: 100% !important;
        overflow-x: auto;
        scrollbar-gutter: auto !important;
    }

    .data-table {
        width: 100% !important;
        max-width: none !important;
    }
}


/* =====================================================================
   S09 V10 — Premium responsive polish
   - Attendance tables stay true tables on mobile and scroll cleanly to
     the wrapper edge so every column remains accessible.
   - All table action icons are centered consistently.
   - Desktop collapsed-sidebar scrollbar is quieter/lighter.
   - Notification badge numbers sit slightly lower and left.
   ===================================================================== */

/* Desktop collapsed sidebar: quieter, lighter scroll rail. */
@media (min-width: 992px) {
    .sidebar-nav {
        scrollbar-width: thin !important;
        scrollbar-color: color-mix(in srgb, var(--text-muted) 18%, transparent) transparent !important;
        padding-right: 4px;
    }
    .sidebar-nav::-webkit-scrollbar {
        width: 4px;
    }
    .sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }
    .sidebar-nav::-webkit-scrollbar-thumb {
        background: color-mix(in srgb, var(--text-muted) 18%, transparent);
        border-radius: 999px;
    }
    .sidebar.sidebar-hidden .badge-dot {
        top: 1px !important;
        right: 0 !important;
    }
}

/* All table action lanes: icons are optically centered. */
.data-table td.actions,
.table td.actions {
    text-align: center !important;
    vertical-align: middle !important;
}
.data-table td.actions {
    display: table-cell !important;
}
.data-table td.actions > form,
.data-table td.actions > a,
.data-table td.actions > button,
.data-table td.actions > .btn,
.table td.actions > form,
.table td.actions > a,
.table td.actions > button,
.table td.actions > .btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
}
.data-table td.actions > form + form,
.data-table td.actions > a + a,
.data-table td.actions > a + form,
.data-table td.actions > form + a,
.data-table td.actions > button + button,
.data-table td.actions > button + a,
.data-table td.actions > a + button {
    margin-left: 6px !important;
}

/* Attendance table (list/pending/trash tabs): phone-responsive UI is
   cloned 1:1 from the Employees table — same .table-wrap + .data-table
   .table-card markup, so it gets the exact same stacked-card layout on
   phones (see "TABLE RESPONSIVE (card-style rows on mobile)" above)
   instead of a separate horizontal-scroll behaviour. No table-specific
   override rules are needed here any more; removing them is what makes
   the two tables match. */
