/* ==============================================
   MOBILE RESPONSIVE STYLES
   Professional Mobile View for All Phone Sizes
   ============================================== */

/* ============================================
   BASE MOBILE RESETS
   ============================================ */

/* Prevent horizontal scroll */
html,
body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* Better touch targets */
button,
a,
input,
select,
textarea {
    min-height: 44px;
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

/* Fluid Typography */
html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

/* ============================================
   RESPONSIVE GRID SYSTEM
   ============================================ */

@media (max-width: 992px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .grid {
        gap: 1rem;
    }
}

/* ============================================
   RESPONSIVE CARDS
   ============================================ */

@media (max-width: 768px) {
    .card {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start !important;
    }

    .card-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 1rem;
        border-radius: 10px;
    }
}

/* ============================================
   RESPONSIVE STAT CARDS
   ============================================ */

@media (max-width: 768px) {
    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* ============================================
   RESPONSIVE BUTTONS
   ============================================ */

@media (max-width: 768px) {
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }

    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    /* Stack buttons on mobile */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2>.btn {
        flex: 1 1 100%;
        text-align: center;
        justify-content: center;
    }

    /* Action buttons in tables */
    .action-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 0.875rem 1rem;
        width: 100%;
    }

    .btn-block {
        padding: 1rem;
    }
}

/* ============================================
   RESPONSIVE FORMS
   ============================================ */

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-control {
        padding: 0.875rem 1rem;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    select.form-control {
        padding-right: 2rem;
        background-position: right 1rem center;
    }
}

@media (max-width: 480px) {
    .form-control {
        padding: 1rem;
        border-radius: 10px;
    }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */

@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        min-width: 600px;
        font-size: 0.9rem;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* ============================================
   RESPONSIVE PAGE HEADERS
   ============================================ */

@media (max-width: 768px) {
    .page-header {
        padding: 1rem 0;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.35rem;
    }
}

/* ============================================
   RESPONSIVE MODALS
   ============================================ */

@media (max-width: 768px) {
    .modal-centered {
        padding: 1rem;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        padding: 1.5rem;
        overflow-y: auto;
    }

    .modal-content h3 {
        font-size: 1.25rem;
    }
}

/* ============================================
   DASHBOARD SPECIFIC MOBILE STYLES
   ============================================ */

@media (max-width: 768px) {

    /* Dashboard Main Grid */
    .dashboard-main-grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-main-grid>.quick-purchase-card {
        order: 1;
    }

    .dashboard-main-grid>.recent-txn-card {
        order: 2;
    }

    /* Balance Card */
    .balance-card {
        padding: 1.5rem;
    }

    .balance-card .balance-amount {
        font-size: 2rem;
    }

    /* Quick Purchase Form */
    .quick-purchase-card .form-group {
        margin-bottom: 1rem;
    }

    /* Payment Method Toggle */
    .payment-option {
        padding: 0.625rem 0.75rem !important;
        font-size: 0.9rem;
    }

    /* Transaction Cards Scroll */
    .transactions-horizontal-scroll {
        padding-bottom: 0.5rem;
    }

    .txn-card {
        min-width: 140px;
        max-width: 160px;
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .balance-card .balance-amount {
        font-size: 1.75rem;
    }

    .txn-card {
        min-width: 130px;
        max-width: 145px;
    }
}

/* ============================================
   SEARCH BAR & FILTERS
   ============================================ */

@media (max-width: 768px) {
    .search-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .search-bar input {
        width: 100%;
    }

    .search-bar .btn {
        width: 100%;
    }

    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .filter-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        flex-shrink: 0;
    }
}

/* ============================================
   BANNER & PROMO CARDS
   ============================================ */

@media (max-width: 768px) {

    /* WAEC Banner */
    .card[href="waec_checker.php"],
    a.card[style*="linear-gradient"] {
        flex-direction: column !important;
        text-align: center;
        gap: 1rem !important;
        padding: 1.25rem !important;
    }

    .card[href="waec_checker.php"]>div:first-child,
    a.card[style*="linear-gradient"]>div:first-child {
        flex-direction: column !important;
        text-align: center;
    }

    .card[href="waec_checker.php"] h3,
    a.card[style*="linear-gradient"] h3 {
        font-size: 1.1rem !important;
    }

    .card[href="waec_checker.php"] p,
    a.card[style*="linear-gradient"] p {
        font-size: 0.85rem !important;
    }

    /* Bulk Orders Banner */
    .card[style*="var(--primary-color)"] .d-flex.gap-2 {
        flex-direction: column;
        width: 100%;
    }

    .card[style*="var(--primary-color)"] .d-flex.gap-2 .btn {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   QUICK ACTIONS GRID
   ============================================ */

@media (max-width: 768px) {
    .grid.grid-3.mt-4 {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .grid.grid-3.mt-4 .card {
        padding: 1rem 0.5rem;
    }

    .grid.grid-3.mt-4 div[style*="font-size: 3rem"] {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }

    .grid.grid-3.mt-4 h4 {
        font-size: 0.85rem;
    }

    .grid.grid-3.mt-4 .text-muted {
        display: none;
    }
}

/* ============================================
   ADMIN PAGE SPECIFIC
   ============================================ */

@media (max-width: 768px) {

    /* Users Table Actions */
    td .d-flex {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    td .action-btn {
        width: 100%;
        justify-content: center;
    }

    /* User Avatar */
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

/* ============================================
   BUY DATA PAGE SPECIFIC
   ============================================ */

@media (max-width: 768px) {

    /* Network Selection Cards */
    #network-selection .bundle-card,
    #bundles-container .bundle-card {
        padding: 1rem;
    }

    #bundles-container .bundle-card h4 {
        font-size: 1rem;
    }

    /* Payment Tabs */
    .tab-row {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .tab-row button,
    .tab-row .tab-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* ============================================
   WALLET PAGE SPECIFIC
   ============================================ */

@media (max-width: 768px) {
    .wallet-card {
        padding: 1.5rem;
    }

    .wallet-balance {
        font-size: 2.25rem;
    }
}

/* ============================================
   PROFILE PAGE SPECIFIC
   ============================================ */

@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
}

/* ============================================
   LOGIN/REGISTER PAGES
   ============================================ */

@media (max-width: 768px) {

    .login-card,
    .register-card,
    .auth-card {
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 16px;
    }

    .login-card h2,
    .register-card h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {

    .login-card,
    .register-card,
    .auth-card {
        margin: 0.5rem;
        padding: 1.25rem;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

@media (max-width: 768px) {
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    .p-4 {
        padding: 1rem !important;
    }

    .gap-2 {
        gap: 0.75rem !important;
    }

    /* Text utilities */
    .text-center-mobile {
        text-align: center !important;
    }

    .hide-on-mobile {
        display: none !important;
    }

    .show-on-mobile {
        display: block !important;
    }

    /* Full width on mobile */
    .full-width-mobile {
        width: 100% !important;
    }
}

/* ============================================
   SMOOTH ANIMATIONS FOR MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Reduce motion for performance */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* Smoother transitions on mobile */
    .card,
    .btn,
    .form-control {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    /* Disable hover effects on touch devices */
    @media (hover: none) {

        .card:hover,
        .btn:hover {
            transform: none;
        }
    }
}

/* ============================================
   SAFE AREA SUPPORT (iPhone X+)
   ============================================ */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .main-content {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .page-header {
        padding: 0.5rem 0;
    }

    .stat-card {
        padding: 0.75rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {

    .sidebar-container,
    .mobile-header-bar,
    .sidebar-toggle,
    .btn,
    .modal-centered {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}