/* ============================================================
   DAMERAX WORKFORCE — assets/css/employee-mobile.css
   Mobile-responsive layer for the Employee Portal ONLY.
   Loaded after app.css exclusively by employee/layout.php.
   Does NOT affect admin, superadmin, or any other pages.
   ============================================================ */

/* ── Base touch improvements (all sizes) ──────────────────── */
.btn, .nav-item, .page-link {
    -webkit-tap-highlight-color: transparent;
}

/* Ensure form controls are large enough to tap comfortably */
.form-control {
    min-height: 44px;
    font-size: 1rem; /* prevents iOS zoom on focus */
}

select.form-control {
    min-height: 44px;
}

/* ── Tablet (≤768px) ──────────────────────────────────────── */
@media (max-width: 768px) {

    /* Stat grids: 2-up on tablet */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px;
    }

    /* Table: horizontally scrollable with touch momentum */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Quick links wrap naturally */
    .card-body .btn {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 130px;
    }
}

/* ── Mobile (≤600px) — core layout overhaul ──────────────── */
@media (max-width: 600px) {

    /* ── Sidebar: hide entirely — replaced by bottom nav ── */
    .sidebar {
        display: none !important;
    }

    /* ── Topbar: full width, compact ── */
    .topbar {
        left: 0 !important;
        padding: 0 14px;
    }

    .topbar-toggle {
        display: none !important; /* sidebar gone, no toggle needed */
    }

    .topbar-title {
        font-size: .95rem;
    }

    .user-name {
        display: none; /* save space — avatar still shows */
    }

    /* ── Main content: no sidebar margin, bottom nav padding ── */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 14px 12px 80px; /* 80px bottom = above bottom nav */
    }

    .app-footer {
        margin-left: 0 !important;
        margin-bottom: 56px; /* sit above bottom nav */
        padding: 10px 14px;
        font-size: .72rem;
    }

    /* ── Bottom navigation bar ── */
    .emp-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--black);
        border-top: 1px solid rgba(255,255,255,.08);
        z-index: 200;
        align-items: stretch;
    }

    .emp-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: rgba(255,255,255,.5);
        font-size: .62rem;
        font-weight: 500;
        text-decoration: none;
        letter-spacing: .03em;
        -webkit-tap-highlight-color: transparent;
        transition: color .15s;
        padding: 6px 4px;
        border-top: 2px solid transparent;
    }

    .emp-bottom-nav a svg {
        width: 20px;
        height: 20px;
        opacity: .7;
    }

    .emp-bottom-nav a.active,
    .emp-bottom-nav a:active {
        color: var(--orange);
        border-top-color: var(--orange);
    }

    .emp-bottom-nav a.active svg,
    .emp-bottom-nav a:active svg {
        opacity: 1;
    }

    /* ── Page header: stack vertically ── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 14px;
    }

    .page-header h2 {
        font-size: 1.1rem;
    }

    /* ── Stat cards: 2-up, compact ── */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: .72rem;
    }

    /* ── Cards ── */
    .card-header {
        padding: 13px 16px;
    }

    .card-body {
        padding: 14px 16px;
    }

    /* ── Table → Card list on mobile ── */
    /* Hide table headers on mobile — data shown inline */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody tr {
        display: block;
        background: var(--white);
        border: 1px solid var(--grey-200);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 12px 14px;
        box-shadow: var(--shadow);
    }

    .table-mobile-cards tbody tr:hover {
        background: var(--white);
    }

    .table-mobile-cards tbody tr:last-child td {
        border-bottom: none;
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid var(--grey-100);
        font-size: .84rem;
        gap: 8px;
    }

    .table-mobile-cards td:last-child {
        border-bottom: none;
        padding-top: 10px;
    }

    /* Label shown via data-label attribute */
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-size: .72rem;
        font-weight: 600;
        color: var(--grey-500);
        text-transform: uppercase;
        letter-spacing: .04em;
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Action buttons in card rows: full width */
    .table-mobile-cards td:last-child .btn {
        width: 100%;
        justify-content: center;
    }

    /* ── Forms ── */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .form-footer {
        flex-direction: column;
    }

    .form-footer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Filter bar: stack vertically */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .form-control,
    .filter-bar .btn {
        width: 100%;
    }

    .search-input {
        max-width: 100%;
    }

    /* ── Payslip mobile ── */
    .payslip-wrap {
        padding: 14px 12px;
        font-size: .82rem;
    }

    .payslip-header {
        flex-direction: column;
        gap: 14px;
        text-align: left;
    }

    .payslip-biz {
        text-align: left !important;
    }

    .payslip-info-grid {
        grid-template-columns: 1fr !important;
        gap: 0;
    }

    /* Earnings / Deductions: stack vertically */
    .payslip-earnings-deductions {
        grid-template-columns: 1fr !important;
    }

    .payslip-table th,
    .payslip-table td {
        padding: 7px 10px;
        font-size: .8rem;
    }

    .payslip-net {
        flex-direction: column;
        gap: 4px;
        text-align: center;
        padding: 14px;
    }

    .payslip-net .val {
        font-size: 1.5rem;
    }

    /* Print/Back buttons on mobile */
    div[style*="display:flex"][style*="gap:10px"] {
        flex-direction: column;
    }

    div[style*="display:flex"][style*="gap:10px"] .btn {
        width: 100%;
        justify-content: center;
    }

    /* Dashboard latest payroll card flex */
    .card-body[style*="display:flex"][style*="flex-wrap:wrap"] {
        flex-direction: column;
        gap: 14px !important;
    }

    /* Month selector form on attendance page */
    form[style*="display:flex"][style*="gap:12px"] {
        flex-direction: column;
        align-items: stretch;
    }

    form[style*="display:flex"][style*="gap:12px"] .form-group,
    form[style*="display:flex"][style*="gap:12px"] .btn {
        width: 100%;
    }

    /* Quick links: full width buttons */
    .card-body > a.btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── Small phones (≤380px) ── */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .topbar {
        padding: 0 10px;
    }

    .main-content {
        padding: 10px 10px 80px;
    }
}

/* ── Bottom nav: hidden on desktop ── */
.emp-bottom-nav {
    display: none;
}

/* ── Login page mobile ── */
@media (max-width: 480px) {
    .login-box {
        padding: 28px 20px;
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}