/* ============================================================
   OUTCARE DASHBOARD - COMPLETE RESPONSIVE STYLESHEET
   Breakpoints:
     Large Desktop  : > 1440px
     Desktop        : 1200px - 1440px
     Small Desktop  : 1025px - 1200px
     Tablet         : 768px - 1024px
     Large Mobile   : 481px - 767px
     Small Mobile   : <= 480px
   ============================================================ */

/* ---- MOBILE MENU TOGGLE (hidden on desktop) --------------- */
.mobile-menu-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--content-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 8px;
    transition: all var(--transition);
}
.mobile-menu-toggle:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}
.mobile-menu-toggle svg { width: 20px; height: 20px; }

/* ---- SIDEBAR OVERLAY (mobile only) ----------------------- */
.sidebar-overlay {
    display: none !important;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active, .sidebar-overlay.show { display: block; }

/* ---- MOBILE CLOSE BUTTON inside sidebar ------------------- */
.sidebar-close-btn {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    transition: background var(--transition);
}
.sidebar-close-btn:hover { background: rgba(255,255,255,0.2); }
.sidebar-close-btn svg { width: 16px; height: 16px; }

/* ============================================================
   LARGE DESKTOP (> 1440px)
   ============================================================ */
@media screen and (min-width: 1441px) {
    :root { --sidebar-w: 270px; }
    .page-content { padding: 32px; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
    .page-title { font-size: 24px; }
}

/* ============================================================
   SMALL DESKTOP / LAPTOP (1025px - 1200px)
   ============================================================ */
@media screen and (max-width: 1200px) {
    :root { --sidebar-w: 240px; }
    .page-content { padding: 22px; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .greeting-name { font-size: 18px; }
    .topbar { padding: 0 20px; gap: 14px; }
}

/* ============================================================
   TABLET (768px - 1024px)
   ============================================================ */
@media screen and (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .page-content { padding: 18px; }
    .topbar { padding: 0 18px; gap: 10px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
    .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .department-grid { grid-template-columns: 1fr; }
    .oc-table, .data-card table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .topbar-center { max-width: 280px; }
    .greeting-name { font-size: 17px; }
    .emp-card-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ============================================================
   TABLET / LARGE MOBILE (481px - 767px)
   ============================================================ */
@media screen and (max-width: 767px) {
    .mobile-menu-toggle { display: flex; }
    .sidebar-close-btn { display: flex; }

    .sidebar {
        position: fixed;
        left: 0; top: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
        width: 260px !important;
    }
    .sidebar.open { transform: translateX(0); }

    .main-wrapper { margin-left: 0 !important; width: 100%; }

    .topbar { padding: 0 12px; gap: 6px; height: 60px; }
    .topbar-left { min-width: auto; }
    .greeting-name { font-size: 16px; }
    .topbar-center { display: none !important; }
    .topbar-right { gap: 6px; }
    .user-text { display: none !important; }

    .page-content { padding: 14px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px 14px; }
    .stat-icon { width: 42px; height: 42px; }
    .stat-value { font-size: 22px; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
    .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
    .page-title { font-size: 19px; }

    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .profile-layout { grid-template-columns: 1fr; }

    .oc-table, .data-card table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 0; }

    .data-card { padding: 14px; }
    .data-card-header { flex-direction: column; align-items: flex-start; gap: 8px; }

    .emp-card-grid { grid-template-columns: 1fr !important; }
    .emp-card { flex-direction: column; align-items: flex-start !important; }

    .btn { min-width: auto; }

    .login-glass-card { width: 92%; padding: 28px 18px; }
    .login-title { font-size: 22px; }

    .modal-overlay { padding: 12px; }
    .modal-box { width: 100%; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 20px 16px; }

    .department-grid { grid-template-columns: 1fr; }

    .settings-layout { grid-template-columns: 1fr !important; }
    .settings-sidebar-nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; border-right: none !important; border-bottom: 1px solid var(--border); padding-bottom: 12px !important; padding-right: 0 !important; margin-bottom: 16px; }
    .settings-nav-item { padding: 8px 14px !important; border-radius: 20px !important; border-left: none !important; border: 1px solid var(--border) !important; font-size: 13px !important; }
    .settings-nav-item.active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }

    #holiday-wrapper table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #holiday-wrapper > div:first-child { flex-direction: column; align-items: flex-start; gap: 12px; }
    #holiday-wrapper > div:first-child > div:last-child { width: 100%; flex-direction: column; gap: 8px; }
    #holiday-wrapper > div:first-child > div:last-child .btn { width: 100%; justify-content: center; }
    #holiday-wrapper h1 { font-size: 20px !important; }

    .profile-modal-content { flex-direction: column !important; gap: 16px !important; }
    .profile-modal-sidebar { width: 100% !important; min-width: auto !important; text-align: center; }
    .profile-info-grid { grid-template-columns: 1fr !important; }

    .attendance-grid { grid-template-columns: 1fr !important; }
    .payroll-summary-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

    :root { --topbar-h: 60px; }
}

/* ============================================================
   SMALL MOBILE (<= 480px)
   ============================================================ */
@media screen and (max-width: 480px) {
    :root { --topbar-h: 56px; }

    .topbar { height: 56px; padding: 0 10px; }
    .topbar-icon-btn { width: 34px; height: 34px; }
    .topbar-icon-btn svg { width: 16px; height: 16px; }
    .greeting-name { font-size: 15px; }

    .page-title { font-size: 18px; }
    .page-subtitle { font-size: 12px; }
    .page-content { padding: 10px; }

    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 14px 12px; gap: 12px; }
    .stat-icon { width: 38px; height: 38px; }
    .stat-icon svg { width: 20px; height: 20px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 12px; }

    .page-actions { flex-direction: column; width: 100%; gap: 8px; }
    .page-actions .btn { width: 100%; justify-content: center; }

    .user-chip { padding: 4px; }
    .chevron-down { display: none !important; }

    .data-card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .data-card { padding: 12px; border-radius: var(--radius-sm); }

    .modal-box { padding: 16px 12px; border-radius: var(--radius); }

    .form-control, .form-select { font-size: 14px; }
    .form-label { font-size: 13px; }

    .oc-table th, .oc-table td { padding: 10px 10px; font-size: 12px; }
    .badge { font-size: 10px; padding: 3px 8px; }

    .login-glass-card { width: 96%; padding: 24px 14px; }
    .login-title { font-size: 20px; }
    .login-input { font-size: 14px; }
    .login-submit-btn { padding: 13px; font-size: 14px; }

    .settings-sidebar-nav { gap: 6px; }
    .settings-nav-item { padding: 6px 12px !important; font-size: 12px !important; }

    .emp-card-grid { grid-template-columns: 1fr !important; }
    .payroll-summary-grid { grid-template-columns: 1fr !important; }

    .tree-node { padding: 8px 12px !important; font-size: 12px !important; }
    .tree-connector { height: 20px !important; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive table { min-width: 600px; }

/* Mobile search bar */
.mobile-search-bar {
    display: none !important;
    padding: 8px 12px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.mobile-search-bar .search-wrapper {
    background: var(--content-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.mobile-search-bar .search-input {
    flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: var(--text-primary);
}
.mobile-search-bar .search-icon { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.mobile-search-btn {
    display: none !important;
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); padding: 2px;
}
.mobile-search-btn svg { width: 20px; height: 20px; }
@media screen and (max-width: 767px) {
    .mobile-search-btn { display: flex; align-items: center; justify-content: center; }
    .mobile-search-bar.visible { display: block; }
}


/* ============================================================
   FLUID RESPONSIVENESS & TARGET BREAKPOINTS (OVERRIDE LAYER)
   ============================================================ */

/* 1. Global Constraints & Fluid Typography */
html {
    /* Fluid typography mapping 14px on mobile to 16px on desktop */
    font-size: clamp(14px, 1.2vw + 10px, 16px);
}

body {
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* Eliminate horizontal scrolling entirely */
}

/* Ensure ALL elements use border-box explicitly if missed */
*, *::before, *::after {
    box-sizing: border-box !important;
}

/* Images and Media safety */
img, video, iframe, canvas, svg {
    max-width: 100% !important;
    height: auto;
}

/* Generic flexible inputs */
input, select, textarea {
    max-width: 100%;
}

/* 2. Breakpoint 1: Large Desktops & Ultrawides (>= 1440px) */
@media screen and (min-width: 1440px) {
    /* Cap content width and center it so it doesn't stretch infinitely */
    .main-content {
        max-width: 1600px;
        margin-left: auto;
        margin-right: auto;
        /* Sidebar needs to be considered if it's fixed */
    }
}

/* 3. Breakpoint 2: Laptops & Small Desktops (1024px - 1439px) */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    .page-header {
        flex-direction: row;
        align-items: center;
    }
    .stat-grid, .form-grid-2, .form-grid-3 {
        gap: 16px;
    }
}

/* 4. Breakpoint 3: Tablets (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* Transition from multi-column grids to simplified 2-column or 1-column */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Touch target minimum 48x48px */
    .btn, button, .nav-item, input[type="submit"] {
        min-height: 48px;
        padding-top: 12px;
        padding-bottom: 12px;
    }
    
    /* Reduce outer padding */
    .main-content {
        padding: 20px !important;
    }
}

/* 5. Breakpoint 4: Mobile Devices (320px - 767px) */
@media screen and (max-width: 767px) {
    /* Strict 1-column layout flow */
    .stat-grid, .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }

    .page-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .page-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Reduce extreme padding */
    .main-content {
        padding: 12px !important;
    }
    .card, .stat-card, .data-card, .form-card {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    /* Touch target minimum 48x48px for mobile as well */
    .btn, button, input, select {
        min-height: 48px !important;
    }

    /* Tables must not break layout */
    .oc-table, table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix modals taking too much space */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 10px auto !important;
        padding: 16px !important;
    }
}



/* ============================================================
   COMPREHENSIVE RESPONSIVE MASTER FIX — v3.6.12
   Author: Senior Dev Update
   Breakpoints:
     Ultra-wide   : >= 1600px
     Large Desktop: 1280px – 1599px
     Desktop      : 1025px – 1279px
     Small Desktop: 900px  – 1024px
     Tablet       : 600px  – 899px
     Large Mobile : 481px  – 599px
     Small Mobile : <= 480px
     Tiny Phone   : <= 360px
   ============================================================ */

/* ============================================================
   SECTION 1: GLOBAL SAFETY — applies at all sizes
   ============================================================ */

/* Prevent any element from bleeding past the viewport */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Every element respects its container width */
*, *::before, *::after {
    box-sizing: border-box;
    min-width: 0; /* crucial: flex/grid children can shrink below content size */
}

/* Images never overflow their container */
img, svg, video, iframe, canvas {
    max-width: 100%;
}

/* Any table that is NOT wrapped in a scroll container gets one */
.oc-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

/* Give all inline-JS-generated tables a minimum width so they scroll rather than break */
.oc-table {
    min-width: 600px;
}

/* Attendance log table — wider columns need wider min */
.att-log-table {
    min-width: 720px;
}

/* Sidebar always clips content */
.sidebar {
    overflow-x: hidden;
    overflow-y: auto;
}

/* ============================================================
   SECTION 2: ULTRA-WIDE SCREEN (>= 1600px)
   Large monitors — cap content, don't let it stretch infinitely
   ============================================================ */
@media screen and (min-width: 1600px) {
    :root { --sidebar-w: 280px; }

    .page-content {
        padding: 36px 40px;
        max-width: 1600px;
        margin-left: auto;
        margin-right: auto;
    }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 22px;
    }

    .page-title { font-size: 26px; }
    .greeting-name { font-size: 22px; }
}

/* ============================================================
   SECTION 3: LARGE DESKTOP (1280px – 1599px)
   Standard 1080p / 1440p monitors
   ============================================================ */
@media screen and (min-width: 1280px) and (max-width: 1599px) {
    :root { --sidebar-w: 260px; }

    .page-content { padding: 28px 32px; }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
    }

    .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   SECTION 4: DESKTOP / SMALL DESKTOP (1025px – 1279px)
   13"–15" laptops, small monitors
   ============================================================ */
@media screen and (min-width: 1025px) and (max-width: 1279px) {
    :root { --sidebar-w: 240px; }

    .page-content { padding: 22px 24px; }
    .topbar { padding: 0 20px; }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }

    /* Keep 3-col forms on desktop but tighten gap */
    .form-grid-3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .form-grid-2 { grid-template-columns: repeat(2, 1fr); gap: 16px; }

    /* Profile layout: keep sidebar + detail panel */
    .profile-layout { grid-template-columns: 280px 1fr; }

    .page-title { font-size: 20px; }
    .greeting-name { font-size: 18px; }

    /* Topbar search won't overlap buttons */
    .topbar-center { max-width: 320px; }
}

/* ============================================================
   SECTION 5: SMALL DESKTOP / LARGE TABLET (900px – 1024px)
   Surface Pro, iPad Pro landscape, 10"–12" convertibles
   ============================================================ */
@media screen and (min-width: 900px) and (max-width: 1024px) {
    :root { --sidebar-w: 220px; }

    .page-content { padding: 18px 20px; }
    .topbar { padding: 0 16px; gap: 12px; }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px;
    }

    /* 3-col forms → 2-col at this range */
    .form-grid-3 { grid-template-columns: repeat(2, 1fr) !important; gap: 14px; }
    .form-grid-2 { grid-template-columns: repeat(2, 1fr); gap: 14px; }

    /* Prevent profile sidebar from being too wide */
    .profile-layout { grid-template-columns: 240px 1fr; }

    /* Page header stays inline here */
    .page-header {
        flex-direction: row;
        align-items: center;
    }

    .topbar-center { max-width: 260px; }
    .greeting-name { font-size: 17px; }

    /* Attendance calendar — make cells smaller */
    .calendar-cell { min-height: 90px; padding: 8px; }
    .calendar-status { font-size: 10px; padding: 2px 5px; }
}

/* ============================================================
   SECTION 6: TABLET (600px – 899px)
   iPad mini, tablets, large phones in landscape
   ============================================================ */
@media screen and (min-width: 600px) and (max-width: 899px) {
    :root {
        --sidebar-w: 256px;  /* sidebar will be hidden anyway; this is for open state */
    }

    /* Sidebar becomes an off-canvas drawer */
    .sidebar {
        position: fixed !important;
        left: 0; top: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; width: 100%; }

    /* Show mobile toggle, hide close btn of desktop */
    .mobile-menu-toggle { display: flex !important; }
    .sidebar-close-btn  { display: flex !important; }

    /* Topbar */
    .topbar { padding: 0 14px; gap: 8px; height: 62px; }
    .topbar-center { display: none !important; } /* hide global search */
    .user-text { display: none !important; }
    .greeting-name { font-size: 16px; }

    /* Content */
    .page-content { padding: 16px; }

    /* Grids — 2 columns on tablet */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }

    /* Profile collapses */
    .profile-layout { grid-template-columns: 1fr !important; }

    /* Page header: vertical on tablet */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
        margin-bottom: 16px;
    }
    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-title { font-size: 19px; }

    /* Tables: scroll horizontally, don't break into cards on tablet */
    .oc-table { min-width: 600px; }
    .data-card { overflow-x: auto; }

    /* Attendance calendar — compact */
    .calendar-cell { min-height: 70px; padding: 6px; font-size: 11px; }
    .calendar-header-cell { font-size: 11px; padding: 8px; }
    .calendar-status { font-size: 9px; padding: 2px 4px; }

    /* Employee card grid — 2 cols */
    .emp-card-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .emp-card { flex-direction: column; align-items: flex-start !important; }

    /* Modal full-width */
    .modal-overlay { padding: 12px; }
    .modal-box { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 22px 18px; }

    /* Settings layout */
    .settings-layout { grid-template-columns: 1fr !important; }
    .settings-sidebar-nav {
        display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px;
        border-right: none !important; border-bottom: 1px solid var(--border);
        padding-bottom: 12px !important; padding-right: 0 !important; margin-bottom: 16px;
    }
    .settings-nav-item {
        padding: 8px 14px !important; border-radius: 20px !important;
        border-left: none !important; border: 1px solid var(--border) !important; font-size: 13px !important;
    }
    .settings-nav-item.active {
        background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important;
    }
}

/* ============================================================
   SECTION 7: LARGE MOBILE (481px – 599px)
   Large phones — Galaxy S series, Pixel, iPhone 12/13/14 Pro
   ============================================================ */
@media screen and (min-width: 481px) and (max-width: 599px) {
    /* Sidebar still off-canvas */
    .sidebar {
        position: fixed !important;
        left: 0; top: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        width: min(260px, 80vw) !important;
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; width: 100%; }
    .mobile-menu-toggle { display: flex !important; }
    .topbar-center { display: none !important; }
    .user-text { display: none !important; }

    .page-content { padding: 14px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .greeting-name { font-size: 16px; }

    /* Grids — 2 columns where it makes sense */
    .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr !important; }
    .profile-layout { grid-template-columns: 1fr !important; }

    /* Employee cards: 1 column */
    .emp-card-grid { grid-template-columns: 1fr !important; }

    /* Tables scroll rather than become cards */
    .oc-table { min-width: 520px; }
    .data-card { overflow-x: auto; }

    /* Page header */
    .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }
    .page-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
    .page-title { font-size: 18px; }

    /* Calendar: tiny cells with horizontal scroll */
    .calendar-scroll-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .calendar-grid { min-width: 520px; }

    /* Modal */
    .modal-overlay { padding: 10px; }
    .modal-box { width: 100%; max-width: 100%; padding: 18px 14px; }
}

/* ============================================================
   SECTION 8: SMALL MOBILE (<= 480px)
   Standard phones — iPhone SE, Galaxy A series
   ============================================================ */
@media screen and (max-width: 480px) {
    :root { --topbar-h: 58px; }

    html, body, .app-shell, .main-wrapper {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Sidebar — slim off-canvas */
    .sidebar {
        position: fixed !important;
        left: 0; top: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        width: min(260px, 82vw) !important;
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; width: 100%; }
    .mobile-menu-toggle { display: flex !important; }

    /* Topbar */
    .topbar { height: 58px; padding: 0 10px; gap: 6px; }
    .topbar-center { display: none !important; }
    .topbar-icon-btn { width: 34px; height: 34px; }
    .topbar-icon-btn svg { width: 16px; height: 16px; }
    .user-text { display: none !important; }
    .chevron-down { display: none !important; }
    .user-chip { padding: 4px; }
    .user-avatar-sm { width: 32px; height: 32px; font-size: 11px; }
    .greeting-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Content */
    .page-content { padding: 12px 10px; overflow-x: hidden; }
    .page-title { font-size: 18px; }
    .page-subtitle { font-size: 12px; }

    /* Page header always stacked */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
        margin-bottom: 14px;
    }
    .page-actions {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    .page-actions .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* ALL grids collapse to single column */
    .stat-grid, .form-grid-2, .form-grid-3, .form-grid-4, .dept-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .profile-layout { grid-template-columns: 1fr !important; }
    .emp-card-grid { grid-template-columns: 1fr !important; }
    .emp-card { flex-direction: column !important; align-items: flex-start !important; }

    /* Stat cards: 2 per row for compact display */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .stat-card { padding: 14px 12px; gap: 10px; }
    .stat-icon { width: 38px; height: 38px; flex-shrink: 0; }
    .stat-icon svg { width: 18px; height: 18px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 11px; }

    /* Cards */
    .data-card { overflow-x: auto; }
    .data-card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .form-card { padding: 16px 14px; }

    /* Tables — scrollable, don't lose the header row */
    .oc-table { min-width: 520px; }
    .oc-table thead th { padding: 10px 10px; font-size: 10px; }
    .oc-table td { padding: 10px 10px; font-size: 12px; }

    /* Buttons */
    .btn-sm { padding: 6px 10px; font-size: 11px; }

    /* Badges */
    .badge { font-size: 10px; padding: 3px 8px; }

    /* Form controls */
    .form-control, .form-label { font-size: 13px; }

    /* Calendar — horizontal scroll */
    .calendar-scroll-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
    .calendar-grid { min-width: 480px; }
    .calendar-cell { min-height: 60px; padding: 4px; }
    .calendar-header-cell { font-size: 9px; padding: 6px 2px; }
    .calendar-date { font-size: 11px; }
    .calendar-status { font-size: 8px; padding: 1px 3px; display: block; }

    /* Settings */
    .settings-layout { grid-template-columns: 1fr !important; }
    .settings-sidebar-nav {
        display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px;
        border-right: none !important; border-bottom: 1px solid var(--border);
        padding-bottom: 10px !important; margin-bottom: 14px;
    }
    .settings-nav-item {
        padding: 6px 12px !important; border-radius: 20px !important;
        border-left: none !important; border: 1px solid var(--border) !important; font-size: 12px !important;
    }

    /* Holiday table wrap */
    #holiday-wrapper { overflow-x: auto; }

    /* Modal */
    .modal-overlay { padding: 8px; }
    .modal-box { width: 100%; max-width: 100%; padding: 16px 12px; max-height: 92vh; overflow-y: auto; }

    /* Login */
    .login-glass-card { width: 96%; padding: 24px 14px; }
    .login-title { font-size: 20px; }
}

/* ============================================================
   SECTION 9: TINY PHONE (<= 360px)
   Galaxy Fold, iPhone SE 1st gen, very old Android devices
   ============================================================ */
@media screen and (max-width: 360px) {
    :root { --topbar-h: 54px; }

    .topbar { height: 54px; padding: 0 8px; gap: 4px; }
    .user-avatar-sm { width: 28px !important; height: 28px !important; font-size: 10px !important; }
    .topbar-icon-btn { width: 30px; height: 30px; }
    .greeting-name { font-size: 13px; }

    .page-content { padding: 10px 8px; }
    .page-title { font-size: 16px; }

    /* Stat cards: single column on 320px */
    .stat-grid { grid-template-columns: 1fr !important; }
    .stat-card { padding: 12px 10px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 10px; }

    /* Sidebar: 85% viewport max */
    .sidebar { width: min(240px, 85vw) !important; }

    /* Buttons: minimal padding */
    .btn { padding: 8px 12px; font-size: 12px; }
    .btn-sm { padding: 5px 8px; font-size: 11px; }

    /* Login */
    .login-glass-card { width: 98%; padding: 20px 12px; }
}

/* ============================================================
   SECTION 10: PRINT — Prevent browser chrome in printouts
   ============================================================ */
@media print {
    .sidebar,
    .topbar,
    .mobile-menu-toggle,
    .sidebar-overlay,
    .page-actions,
    .btn,
    .topbar-right,
    nav {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .page-content {
        padding: 0 !important;
        overflow: visible !important;
    }
    body, .app-shell {
        overflow: visible !important;
        height: auto !important;
    }
    @page {
        margin: 15mm;
    }
}

