/**
 * MuchData Mobile UI - Structured & Optimized
 * Version: 2.1
 * Updated: November 22, 2025
 * 
 * Optimized for:
 * - Google Pixel 7 (412x915px)
 * - Infinix Smart 6 (720x1600px)
 * - iPhone 12/13/14 (390x844px)
 * - Samsung Galaxy S21 (360x800px)
 * - Generic Android devices (320px - 768px)
 */

/* Import Global CSS Variables */
@import url('css-variables.css');

/* ========================================
   MOBILE-SPECIFIC OVERRIDES
   ======================================== */
/* Note: Mobile variables are now defined in css-variables.css */

/* ========================================
   DEVICE-SPECIFIC BREAKPOINTS
   ======================================== */

/* Small phones (320px - 374px) */
@media (max-width: 374px) {
    :root {
        --mobile-space-lg: 12px;
        --mobile-space-xl: 16px;
        --mobile-text-base: 0.9375rem;
    }
}

/* Standard phones (375px - 413px) */
@media (min-width: 375px) and (max-width: 413px) {
    :root {
        --mobile-space-lg: 16px;
        --mobile-space-xl: 20px;
    }
}

/* Large phones (414px - 767px) */
@media (min-width: 414px) and (max-width: 767px) {
    :root {
        --mobile-space-lg: 18px;
        --mobile-space-xl: 24px;
    }
}

/* ========================================
   GLOBAL MOBILE RESET
   ======================================== */

@media (max-width: 768px) {
    html {
        font-size: 16px;
        -webkit-text-size-adjust: 100%;
        -webkit-tap-highlight-color: transparent;
        scroll-behavior: smooth;
    }

    body {
        margin: 0;
        padding: 0;
        width: 100%;
        min-height: 100vh;
        overflow-x: hidden;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        touch-action: pan-y;
    }

    * {
        box-sizing: border-box;
        max-width: 100%;
    }

    button,
    a,
    input,
    select,
    textarea {
        touch-action: manipulation;
    }

    button,
    a.btn,
    .btn {
        min-height: var(--mobile-touch-min);
        min-width: var(--mobile-touch-min);
        padding: var(--mobile-space-sm) var(--mobile-space-lg);
    }
}

/* ========================================
   MOBILE HEADER
   ======================================== */

@media (max-width: 768px) {
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--mobile-header-height);
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: var(--z-mobile-header);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 var(--mobile-space-lg);
    }

    .mobile-menu-toggle {
        width: var(--mobile-touch-comfortable);
        height: var(--mobile-touch-comfortable);
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        cursor: pointer;
        border-radius: 8px;
    }

    .mobile-header-title {
        font-size: var(--mobile-text-lg);
        font-weight: 600;
        color: #1f2937;
        margin: 0;
    }
}

/* ========================================
   MOBILE CONTENT AREA
   ======================================== */

@media (max-width: 768px) {
    .mobile-content {
        padding-top: var(--mobile-header-height);
        padding-bottom: var(--mobile-bottom-nav-height);
        min-height: 100vh;
        width: 100%;
    }

    .mobile-content-inner {
        padding: var(--mobile-space-lg);
    }

    @supports (padding: max(0px)) {
        .mobile-content {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
    }
}

/* ========================================
   MOBILE SIDEBAR
   ======================================== */

@media (max-width: 768px) {
    .mobile-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--mobile-sidebar-width);
        height: 100vh;
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: var(--z-mobile-sidebar);
        overflow-y: auto;
    }

    .mobile-sidebar.active {
        transform: translateX(0);
    }

    .mobile-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-mobile-sidebar) - 1);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }

    .mobile-sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    body.mobile-sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */

@media (max-width: 768px) {
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--mobile-bottom-nav-height);
        background: #ffffff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: var(--z-mobile-header);
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 var(--mobile-space-sm);
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #6b7280;
        padding: var(--mobile-space-xs);
        border-radius: 8px;
        min-height: var(--mobile-touch-comfortable);
    }

    .mobile-bottom-nav-item.active {
        color: #3b82f6;
    }

    .mobile-bottom-nav-icon {
        font-size: 20px;
        margin-bottom: 2px;
    }

    .mobile-bottom-nav-label {
        font-size: 11px;
        font-weight: 500;
    }
}

/* ========================================
   MOBILE CARDS
   ======================================== */

@media (max-width: 768px) {
    .mobile-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        margin-bottom: var(--mobile-space-lg);
        overflow: hidden;
    }

    .mobile-card-body {
        padding: var(--mobile-space-lg);
    }

    .mobile-stats-card {
        background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
        border-radius: 16px;
        padding: var(--mobile-space-xl);
        color: white;
        margin-bottom: var(--mobile-space-lg);
    }
}

/* ========================================
   MOBILE FORMS
   ======================================== */

@media (max-width: 768px) {
    .mobile-form-group {
        margin-bottom: var(--mobile-space-lg);
    }

    .mobile-form-label {
        display: block;
        font-size: var(--mobile-text-sm);
        font-weight: 500;
        color: #374151;
        margin-bottom: var(--mobile-space-sm);
    }

    .mobile-form-input,
    .mobile-form-select,
    .mobile-form-textarea {
        width: 100%;
        padding: var(--mobile-space-md);
        font-size: var(--mobile-text-base);
        border: 2px solid #e5e7eb;
        border-radius: 8px;
        background: white;
        min-height: var(--mobile-touch-comfortable);
    }

    .mobile-form-input:focus {
        outline: none;
        border-color: #3b82f6;
    }
}

/* ========================================
   MOBILE BUTTONS
   ======================================== */

@media (max-width: 768px) {
    .mobile-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: var(--mobile-space-md) var(--mobile-space-xl);
        font-size: var(--mobile-text-base);
        font-weight: 600;
        border-radius: 8px;
        border: none;
        cursor: pointer;
        min-height: var(--mobile-touch-comfortable);
        text-decoration: none;
        gap: var(--mobile-space-sm);
    }

    .mobile-btn-primary {
        background: linear-gradient(135deg, #3b82f6, #1e40af);
        color: white;
    }

    .mobile-btn-full {
        width: 100%;
    }
}

/* ========================================
   MOBILE UTILITIES
   ======================================== */

@media (max-width: 768px) {
    .mobile-mt-sm {
        margin-top: var(--mobile-space-sm);
    }

    .mobile-mt-md {
        margin-top: var(--mobile-space-md);
    }

    .mobile-mt-lg {
        margin-top: var(--mobile-space-lg);
    }

    .mobile-mb-sm {
        margin-bottom: var(--mobile-space-sm);
    }

    .mobile-mb-md {
        margin-bottom: var(--mobile-space-md);
    }

    .mobile-mb-lg {
        margin-bottom: var(--mobile-space-lg);
    }

    .mobile-p-sm {
        padding: var(--mobile-space-sm);
    }

    .mobile-p-md {
        padding: var(--mobile-space-md);
    }

    .mobile-p-lg {
        padding: var(--mobile-space-lg);
    }

    .mobile-text-center {
        text-align: center;
    }

    .mobile-hidden {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #wallet-view .col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    #wallet-view .card .card-body {
        text-align: left;
        padding: var(--mobile-space-lg);
    }

    #wallet-view>.card {
        width: 100% !important;
        max-width: 100% !important;
    }

    #wallet-view .card .mb-3>.d-flex.align-items-center {
        justify-content: space-between !important;
        background: #f8fafc;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 10px 12px;
        gap: var(--mobile-space-sm);
    }

    #wallet-view [id$='-account-number'] {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        font-size: 1.125rem;
        letter-spacing: 0.06em;
        white-space: nowrap;
        line-height: 1.2;
    }

    #wallet-view .btn.btn-sm {
        min-height: var(--mobile-touch-min);
        padding: 8px 12px;
        border-radius: 8px;
    }

    #wallet-view h5.card-title {
        font-size: 1rem;
        margin-bottom: var(--mobile-space-md);
    }

    #wallet-view .rounded-circle.d-inline-flex {
        width: 48px !important;
        height: 48px !important;
    }
}

@media (max-width: 768px) {
    #wallet-view .row.mb-4>.col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
    }

    #wallet-view .row.g-4>.col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
}