/* ============================================================
   MOBILE RESPONSIVE - Global Dashboard CSS
   Works across: dashboard.php, fee_page.php, partner_dashboard.php,
   distributer_dashboard.php, accounts_dashboard.php, facilitator_dashboard.php
   ============================================================ */

/* ── BASE ── */
* { box-sizing: border-box; }
img { max-width: 100%; }

/* ── HEADER (shared header.php) ── */
@media (max-width: 768px) {
    .header { padding: 0.75rem 1rem; }
    .header-container { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; }
    .logo { font-size: 1.1rem; }
    .nav-actions { gap: 0.4rem; }
    .nav-btn { padding: 0.4rem 0.8rem; font-size: 0.78rem; }
}

/* ── DASHBOARD WRAPPER / SIDEBAR LAYOUT ── */
@media (max-width: 768px) {
    .dashboard-wrapper { flex-direction: column; }

    /* Sidebar slide-in */
    .sidebar {
        position: fixed !important;
        top: 0; left: 0;
        height: 100vh !important;
        width: 270px !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050 !important;
        overflow-y: auto;
    }
    .sidebar.active, .sidebar.open { transform: translateX(0) !important; }
    #sidebar-close { display: flex !important; }

    /* Main content full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 0.5rem !important;
    }

    /* Top header compact */
    .top-header {
        padding: 0.6rem 0.75rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    .top-header .page-title { font-size: 0.95rem !important; }
    .header-right, .header-left { gap: 0.4rem !important; }

    /* Dashboard container */
    .dashboard-container { padding: 0.5rem 0 !important; }
    .dashboard-section { padding: 0.75rem !important; }
}

/* ── GRIDS ── */
@media (max-width: 768px) {
    .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem !important; }
    .grid-cols-2 { grid-template-columns: 1fr !important; gap: 0.75rem !important; }
    .score-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem !important; }
    .cards-grid { grid-template-columns: 1fr !important; }
    .two-col, .three-col { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .grid-cols-3, .grid-cols-4, .grid-cols-2 { grid-template-columns: 1fr !important; }
    .score-grid, .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── CARDS ── */
@media (max-width: 768px) {
    .score-card, .stat-card, .info-card, .card {
        padding: 0.85rem !important;
    }
    .score-value, .stat-value { font-size: 1.5rem !important; }
    .card-header, .section-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
}

/* ── TABLES ── */
@media (max-width: 768px) {
    .table-responsive, .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 500px; font-size: 0.8rem; }
    th, td { padding: 0.5rem 0.6rem !important; white-space: nowrap; }
    .table-scroll { display: block; overflow-x: auto; width: 100%; }
}

/* ── TABS ── */
@media (max-width: 768px) {
    .tab-nav, .tabs-nav, .tab-list {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 0.25rem !important;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .tab-nav::-webkit-scrollbar { display: none; }
    .tab-btn, .tab-item, .nav-tab {
        font-size: 0.78rem !important;
        padding: 0.45rem 0.75rem !important;
        flex-shrink: 0;
    }
}

/* ── FORMS ── */
@media (max-width: 768px) {
    .form-row { flex-direction: column !important; gap: 0.75rem !important; }
    .form-group { margin-bottom: 0.75rem !important; }
    .form-control, input[type="text"], input[type="email"],
    input[type="password"], input[type="number"], select, textarea {
        font-size: 16px !important; /* prevent zoom on iOS */
        width: 100% !important;
        padding: 0.6rem 0.75rem !important;
    }
    .input-group { flex-direction: column !important; }
    .input-group .btn, .input-group button { width: 100%; border-radius: 8px !important; }
    label, .form-label { font-size: 0.85rem !important; }
}

/* ── BUTTONS ── */
@media (max-width: 480px) {
    .btn-group { flex-direction: column !important; width: 100%; }
    .btn-group .btn, .btn-group button { width: 100% !important; }
    .action-buttons { flex-wrap: wrap !important; gap: 0.5rem !important; }
}

/* ── MODALS ── */
@media (max-width: 768px) {
    .modal { padding: 0 !important; align-items: flex-end !important; }
    .modal-content {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        padding: 1.25rem !important;
    }
    .modal-header { padding-bottom: 0.75rem !important; }
    .modal-title { font-size: 1.05rem !important; }
}

/* ── ANNOUNCEMENTS / CONTENT CARDS ── */
@media (max-width: 768px) {
    .announcement-card, .announcement-item, .announcement-history-item {
        padding: 0.75rem !important;
        border-radius: 10px !important;
    }
    .announcement-header { flex-direction: column !important; gap: 0.4rem !important; }
}

/* ── CHATBOT ── */
@media (max-width: 768px) {
    .chatbot {
        min-width: unset !important;
        width: 100% !important;
        max-height: 280px !important;
    }
    .chat-input-row { flex-wrap: wrap; gap: 0.5rem; }
    .chat-input-row input { min-width: 0; flex: 1; }
}

/* ── PROFILE / USER INFO ── */
@media (max-width: 768px) {
    .profile-grid, .user-info-grid { grid-template-columns: 1fr !important; }
    .profile-header { flex-direction: column !important; text-align: center; gap: 1rem !important; }
    .profile-avatar { margin: 0 auto !important; }
}

/* ── FEE PAGE ── */
@media (max-width: 768px) {
    .fee-container, .payment-container { padding: 1rem !important; }
    .fee-grid, .payment-grid { grid-template-columns: 1fr !important; }
    .fee-card, .payment-card { padding: 1rem !important; }
    .payment-methods { flex-direction: column !important; gap: 0.75rem !important; }
    .amount-display { font-size: 1.8rem !important; }
    .installment-options { flex-direction: column !important; }
}

/* ── PARTNER DASHBOARD ── */
@media (max-width: 768px) {
    .partner-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .referral-table-wrap { overflow-x: auto; }
    .commission-cards { grid-template-columns: 1fr !important; }
    .lead-list { font-size: 0.82rem; }
}
@media (max-width: 480px) {
    .partner-stats { grid-template-columns: 1fr !important; }
}

/* ── DISTRIBUTOR DASHBOARD ── */
@media (max-width: 768px) {
    .distributor-grid { grid-template-columns: 1fr !important; }
    .credit-card-row { flex-direction: column !important; }
}

/* ── ACCOUNTS / ADMIN DASHBOARD ── */
@media (max-width: 768px) {
    .admin-grid { grid-template-columns: 1fr !important; }
    .filter-row { flex-direction: column !important; gap: 0.5rem !important; }
    .filter-row select, .filter-row input { width: 100% !important; }
    .export-btns { flex-wrap: wrap; gap: 0.5rem; }
    .badge-group { flex-wrap: wrap; gap: 0.3rem; }
}

/* ── SIDEBAR OVERLAY ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1049;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block !important; }

/* ── PREVENT BODY SCROLL WHEN SIDEBAR OPEN ── */
body.sidebar-open { overflow: hidden !important; }

/* ── TOUCH IMPROVEMENTS ── */
@media (max-width: 768px) {
    .nav-item, .tab-btn, .btn, button {
        min-height: 40px;
        touch-action: manipulation;
    }
    /* Scrollable sections */
    .content-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Remove hover effects on touch */
    .card:hover, .score-card:hover { transform: none !important; }
}

/* ── TYPOGRAPHY SCALE ── */
@media (max-width: 480px) {
    h1 { font-size: 1.4rem !important; }
    h2 { font-size: 1.2rem !important; }
    h3 { font-size: 1rem !important; }
    p, li, td, th { font-size: 0.85rem !important; }
    .section-title { font-size: 1.1rem !important; }
}

/* ── UTILITY ── */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .text-center-mobile { text-align: center !important; }
    .w-full-mobile { width: 100% !important; }
    .p-sm-mobile { padding: 0.75rem !important; }
    .flex-col-mobile { flex-direction: column !important; }
    .gap-sm-mobile { gap: 0.5rem !important; }
}
