/**
 * SPA + PWA + Mobile Responsive Stylesheet
 * Scoped additions to complement style.css — does NOT replace it.
 * Loaded on all user dashboard + frontend pages.
 */

/* ════════════════════════════════════════════════════════════════════
   1. PWA / STANDALONE MODE
   ════════════════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
    /* Respect iOS safe area (notch / home indicator) */
    body {
        padding-top: env(safe-area-inset-top, 0px);
    }

    .navbar-wrapper {
        padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    }

    /* Prevent rubber-banding on iOS */
    html, body {
        overscroll-behavior: none;
    }
}


/* ════════════════════════════════════════════════════════════════════
   2. MOBILE SIDEBAR OVERLAY
   On tablet / mobile the sidebar slides in over the content.
   main.js toggles `.active` on `.sidebar` and `.body-overlay`.
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 991px) {

    /* Sidebar: fixed, off-screen left by default */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 260px !important;
        z-index: 1060 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Show sidebar when main.js adds .active */
    .sidebar.active {
        left: 0 !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18) !important;
    }

    /* Main wrapper: full width, no left margin */
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Overlay: fills screen, hidden by default */
    .body-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.45) !important;
        z-index: 1050 !important;
        display: none !important;
        opacity: 0;
        transition: opacity 0.25s ease;
    }

    .body-overlay.active {
        display: block !important;
        opacity: 1 !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   3. MOBILE BOTTOM NAVIGATION BAR
   5-tab nav fixed at the bottom — visible only on mobile.
   ════════════════════════════════════════════════════════════════════ */

.mobile-bottom-nav {
    display: none; /* hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: #ffffff;
    border-top: 1px solid #e8eaf0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.07);
    /* iOS home indicator clearance */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 991px) {
    .mobile-bottom-nav {
        display: flex;
    }

    /* Push main content up so bottom nav doesn't overlap it */
    .main-body-wrapper {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 4px 8px;
    text-decoration: none !important;
    color: #9aa0b0 !important;
    font-size: 10px;
    font-weight: 500;
    min-height: 56px;
    transition: color 0.15s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mobile-nav-item i {
    font-size: 22px;
    margin-bottom: 2px;
    display: block;
    line-height: 1;
}

.mobile-nav-item span {
    display: block;
    letter-spacing: 0.01em;
}

/* Active state */
.mobile-nav-item.active,
.mobile-nav-item:active {
    color: var(--primary-color, #007bff) !important;
}

.mobile-nav-item.active i {
    color: var(--primary-color, #007bff) !important;
}

/* Active indicator bar at top */
.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary-color, #007bff);
    border-radius: 0 0 4px 4px;
}


/* ════════════════════════════════════════════════════════════════════
   4. TOUCH TARGETS (iOS HIG: 44×44 pt minimum)
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

    .btn,
    .btn--base,
    .btn--primary,
    .btn--danger,
    .btn--warning,
    .btn--info,
    button[type="submit"],
    button[type="button"] {
        min-height: 44px !important;
    }

    .form--control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }

    .sidebar-menu-item a {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }

    .notification-icon,
    .header-user-thumb a {
        min-width: 44px !important;
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   5. RESPONSIVE TABLES
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

    /* Wrap table in horizontal scroll */
    .table-area {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure table has a minimum width so columns don't collapse */
    .table-area .custom-table,
    .table-area table {
        min-width: 560px;
    }

    /* DataTables: compact search input */
    .dataTables_wrapper .dataTables_filter input {
        width: 140px !important;
    }

    /* DataTables: stack header info on small screens */
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        float: none !important;
    }

    /* Action button group */
    .table .action-btn-wrapper,
    .table td .btn-wrapper {
        display: inline-flex !important;
        flex-wrap: wrap;
        gap: 4px;
    }
}


/* ════════════════════════════════════════════════════════════════════
   6. CARD & DASHBOARD LAYOUT
   ════════════════════════════════════════════════════════════════════ */

/* Balance / stat cards: 2 columns on phone */
@media (max-width: 575px) {

    .dashboard-inner .col-xl-3,
    .dashboard-inner .col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Looser card padding on mobile */
    .card-wrapper,
    .custom-card .card-body {
        padding: 16px !important;
    }

    /* Modal dialog fills screen on tiny phones */
    .modal-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }

    .modal-dialog.modal-sm {
        max-width: calc(100vw - 16px) !important;
    }

    /* Balance figure */
    .balance-area .amount,
    .balance-widget .amount {
        font-size: 26px !important;
    }

    /* Section headings */
    .dashboard-area-heading h2,
    .section-heading .title {
        font-size: 18px !important;
    }

    /* Virtual card preview */
    .virtual-card-area .virtual-card {
        max-width: 100% !important;
    }

    /* Copy-to-clipboard row */
    .copy-btn-wrapper .copy-btn {
        white-space: nowrap;
    }
}


/* ════════════════════════════════════════════════════════════════════
   7. TOP NAVBAR (STICKY ON MOBILE)
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 991px) {

    .navbar-wrapper {
        position: sticky !important;
        top: 0 !important;
        z-index: 900 !important;
        background: #ffffff !important;
        box-shadow: 0 1px 8px rgba(0, 0, 0, 0.07) !important;
        padding: 10px 16px !important;
    }

    .dashboard-title-part {
        gap: 8px;
        flex-wrap: nowrap;
    }

    /* Compact language selector */
    .language-select {
        max-width: 90px !important;
        font-size: 12px !important;
    }

    /* Notification dropdown: full-width on small screens */
    .notification-wrapper {
        right: -60px !important;
        width: 300px !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   8. FORMS & INPUTS
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 575px) {

    /* Two-column form rows: stack to single column */
    .col-xl-6.form-group,
    .col-lg-6.form-group,
    .col-md-6.form-group {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Amount input with currency symbol: keep side by side */
    .input-group .form--control {
        font-size: 16px !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   9. SPA / TURBO DRIVE
   ════════════════════════════════════════════════════════════════════ */

/* Turbo progress bar */
.turbo-progress-bar {
    background: var(--primary-color, #007bff) !important;
    height: 3px !important;
}

/* Subtle loading cursor during navigation */
html[data-turbo-loading] body {
    cursor: progress;
}


/* ════════════════════════════════════════════════════════════════════
   10. BILL PAYMENT / SERVICES — MOBILE
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 575px) {

    /* Service category cards: 2 per row */
    .bill-category-wrapper .bill-category-item,
    .service-grid .service-item {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    /* Biller logo cards: full width */
    .biller-card {
        width: 100% !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   11. SELL CRYPTO — MOBILE
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 575px) {

    .sell-crypto-form .crypto-rate-display {
        font-size: 20px !important;
    }

    .crypto-asset-select .asset-option {
        padding: 10px 8px !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   12. LANDING PAGE (FRONTEND) — MOBILE
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 575px) {

    /* Hero banner */
    .banner-section .banner-content .title {
        font-size: 26px !important;
        line-height: 1.3 !important;
    }

    .banner-section .banner-content .sub-title {
        font-size: 14px !important;
    }

    /* App store button row: stack vertically */
    .app-btn-wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .app-btn-wrapper a {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Feature cards */
    .feature-section .feature-item {
        margin-bottom: 20px !important;
    }

    /* Statistics counter */
    .statistics-section .count-item .title {
        font-size: 28px !important;
    }
}


/* ════════════════════════════════════════════════════════════════════
   13. HEADER / NAVBAR (FRONTEND LANDING)
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 991px) {

    /* Ensure nav toggle button is visible */
    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
    }

    /* Mobile nav links: bigger tap targets */
    .navbar-nav .nav-item .nav-link {
        padding: 10px 16px !important;
        min-height: 44px;
        display: flex !important;
        align-items: center;
    }
}


/* ════════════════════════════════════════════════════════════════════
   14. SCROLLBAR STYLING (WEBKIT)
   ════════════════════════════════════════════════════════════════════ */

@media (min-width: 992px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb {
        background: #c8cdd8;
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #a0a8b8;
    }
}


/* ════════════════════════════════════════════════════════════════════
   15. PRINT
   ════════════════════════════════════════════════════════════════════ */

@media print {
    .mobile-bottom-nav,
    .sidebar,
    .navbar-wrapper {
        display: none !important;
    }

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