/* ============================================================
   PUMA ATTENDANCE — MOBILE RESPONSIVE STYLESHEET
   Place in: public/css/mobile.css
   Link AFTER style.css in layouts/app.blade.php
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* ── AUTH PAGE ────────────────────────────── */
@media (max-width: 768px) {
    .auth-page { flex-direction: column !important; min-height: 100svh; }
    .auth-left { display: none !important; }
    .auth-right { width: 100% !important; padding: 28px 20px !important; display: flex; align-items: flex-start; justify-content: center; }
    .auth-form-wrapper { width: 100%; max-width: 440px; }
    .auth-title { font-size: 1.5rem !important; }
}

/* ── SIDEBAR + LAYOUT ─────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1); position: fixed !important; z-index: 999; height: 100% !important; top: 0; left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.18); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.46); z-index: 998; }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .topbar-toggle { display: flex !important; }
}

/* ── TOPBAR ───────────────────────────────── */
@media (max-width: 600px) {
    .topbar { padding: 0 12px !important; gap: 8px !important; }
    .topbar-breadcrumb { font-size: .8rem !important; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #topbarDate { display: none !important; }
    .topbar-username { display: none !important; }
}

/* ── PAGE CONTENT ─────────────────────────── */
@media (max-width: 640px) {
    .page-content { padding: 14px !important; }
}

/* ── PAGE HEADER ──────────────────────────── */
@media (max-width: 640px) {
    .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 12px !important; }
    .page-header .btn, .page-header > a.btn { width: 100% !important; justify-content: center !important; text-align: center !important; }
    .page-header > .d-flex, .page-header > div:last-child:not(:first-child) { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
    .page-header > .d-flex .btn { flex: 1; justify-content: center; }
    .page-title { font-size: 1.15rem !important; }
    .page-subtitle { font-size: .78rem !important; }
}

/* ── CARD ─────────────────────────────────── */
@media (max-width: 480px) {
    .card-body-custom { padding: 14px !important; }
    .card-header-custom { padding: 12px 14px !important; flex-wrap: wrap; gap: 8px; }
}

/* ── STAT GRID ────────────────────────────── */
@media (max-width: 640px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .stat-card { padding: 14px !important; }
    .stat-value { font-size: 1.5rem !important; }
    .stat-label { font-size: .72rem !important; }
}
@media (max-width: 360px) { .stat-grid { grid-template-columns: 1fr !important; } }

/* ── TABLES ───────────────────────────────── */
.table-wrapper { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
.data-table { min-width: 520px; }
@media (max-width: 480px) {
    .data-table th, .data-table td { padding: 10px 8px !important; font-size: .78rem !important; }
    .user-cell-email { display: none !important; }
}

/* ── FILTER FORMS ─────────────────────────── */
@media (max-width: 640px) {
    .filter-form { flex-direction: column !important; align-items: stretch !important; }
    .filter-form .form-group { width: 100% !important; min-width: unset !important; flex: none !important; margin: 0 0 8px 0 !important; }
    .filter-form .btn { width: 100%; justify-content: center; }
}

/* ── FORM ROWS ────────────────────────────── */
@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr !important; }
}

/* ── CHECK-IN CAMERA GRID ─────────────────── */
@media (max-width: 640px) {
    .checkin-grid { grid-template-columns: 1fr !important; }
    #videoPreview, #selfiePreview { height: 200px !important; }
}

/* ── BREAK BUTTONS ────────────────────────── */
@media (max-width: 480px) {
    .break-btn-row { flex-direction: column !important; gap: 8px !important; }
    .break-btn-row .btn { width: 100% !important; justify-content: center !important; }
}

/* ── LEAVE ACTIONS ────────────────────────── */
@media (max-width: 768px) {
    .leave-actions { flex-direction: column !important; gap: 6px !important; align-items: stretch !important; }
    .leave-actions form { display: flex !important; gap: 6px !important; width: 100% !important; }
    .leave-actions .form-control { flex: 1 !important; min-width: 0 !important; width: auto !important; }
}

/* ── EXPENSE STATS ROW ────────────────────── */
@media (max-width: 640px) {
    .expense-stats-row { flex-direction: column !important; }
    .expense-stats-row .card { width: 100% !important; min-width: unset !important; }
}

/* ── QUICK ACTIONS ────────────────────────── */
@media (max-width: 640px) {
    .quick-actions { flex-direction: column !important; }
    .quick-actions .btn { width: 100% !important; justify-content: center !important; }
}

/* ── INLINE GRID OVERRIDES ────────────────── */
@media (max-width: 640px) {
    [style*="repeat(auto-fit"] { grid-template-columns: repeat(2, 1fr) !important; }
    [style*="repeat(4, 1fr)"]  { grid-template-columns: repeat(2, 1fr) !important; }
    [style*="repeat(3, 1fr)"]  { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 380px) {
    [style*="repeat(auto-fit"] { grid-template-columns: 1fr !important; }
}

/* ── ALERTS ───────────────────────────────── */
@media (max-width: 480px) {
    .alert { font-size: .82rem !important; padding: 10px 12px !important; }
}

/* ── DROPDOWN MENUS ───────────────────────── */
@media (max-width: 480px) {
    .dropdown-menu-custom { right: 0 !important; left: auto !important; min-width: 240px !important; max-width: calc(100vw - 24px) !important; }
}

/* ── PAGINATION ───────────────────────────── */
@media (max-width: 480px) {
    nav[role="navigation"] { font-size: .78rem !important; }
}

/* ── UTILITIES ────────────────────────────── */
.d-flex { display: flex; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
@media (max-width: 480px) { .mb-24 { margin-bottom: 16px !important; } }

/* ── Global hardening for Blade inline layouts ─────────────── */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }

    .page-content > * {
        max-width: 100%;
    }

    .card,
    .table-wrapper {
        max-width: 100%;
    }

    /* Make long button labels wrap instead of overflow */
    .btn {
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 640px) {
    /* Common filter/action forms are inline-flex with inline styles in many blades */
    .card-body-custom form[style*="display:flex"],
    .card-header-custom form[style*="display:flex"],
    .page-content form[style*="display:flex"] {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .card-body-custom form[style*="display:flex"] .form-group,
    .card-header-custom form[style*="display:flex"] .form-group,
    .page-content form[style*="display:flex"] .form-group {
        width: 100% !important;
        min-width: 0 !important;
        margin-bottom: 0 !important;
    }

    .card-body-custom form[style*="display:flex"] .btn,
    .card-header-custom form[style*="display:flex"] .btn,
    .page-content form[style*="display:flex"] .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Action groups inside tables/cards */
    td > div[style*="display:flex"],
    .card-body-custom div[style*="display:flex"][style*="gap"] {
        flex-wrap: wrap;
    }

    td > div[style*="display:flex"] .btn,
    td > div[style*="display:flex"] form {
        width: 100%;
    }

    td > div[style*="display:flex"] form .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 12px !important;
    }

    .page-title {
        font-size: 1.05rem !important;
        line-height: 1.3;
    }

    .page-subtitle {
        font-size: 0.74rem !important;
    }

    .topbar {
        min-height: 56px;
        height: auto;
    }

    .topbar-actions {
        gap: 6px;
    }

    .topbar-btn {
        width: 34px;
        height: 34px;
    }

    .table-wrapper {
        border-radius: 12px;
    }

    .data-table {
        min-width: 640px;
    }

    .data-table td,
    .data-table th {
        white-space: nowrap;
    }

    /* Pagination blocks in Laravel links() output */
    nav[role="navigation"] > div {
        gap: 8px;
        flex-wrap: wrap;
    }
}
