/**
 * Wallet and Loans Mobile Responsive CSS
 * Optimizes mobile experience for wallet and loans pages
 */

/* Hide "View All Transactions" button on all devices */
.mt-6.text-center a[href*="transactions"] {
    display: none !important;
}

/* Hide the "Wallet" title text on all devices */
.text-4xl.font-bold.bg-gradient-to-r.from-slate-900.via-blue-900.to-indigo-900.bg-clip-text.text-transparent {
    display: none !important;
}

/* Alternative selector for the wallet title */
h1.text-4xl.font-bold {
    display: none !important;
}

/* Remove drop shadow from transactions card */
.bg-white\/70.backdrop-blur-sm.rounded-2xl.border.border-white\/20.shadow-lg {
    box-shadow: none !important;
}

/* Alternative selectors for transactions card shadow removal */
.shadow-lg {
    box-shadow: none !important;
}

.bg-white.rounded-2xl.shadow-lg {
    box-shadow: none !important;
}

/* Target any card with transactions content */
div[class*="shadow-lg"] {
    box-shadow: none !important;
}

/* ULTRA CRITICAL: Force hamburger menu visibility on all pages */
button#mobile-menu-toggle {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
    position: relative !important;
    width: auto !important;
    height: auto !important;
    padding: 0.5rem !important;
    background: transparent !important;
    border: none !important;
}

button#mobile-menu-toggle svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
}

/* Force navigation bar visibility */
nav.bg-white.border-b.border-gray-200.shadow-sm.sticky.top-0.z-50 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Override any hiding classes */
.lg\:hidden {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure hamburger is visible on mobile for all pages */
@media (max-width: 1023px) {
    button#mobile-menu-toggle,
    #mobile-menu-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 99999 !important;
        width: auto !important;
        height: auto !important;
    }

    .lg\:hidden {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* CRITICAL: Hide hamburger on desktop (lg and above) - Override everything */
@media (min-width: 1024px) {
    button#mobile-menu-toggle,
    #mobile-menu-toggle,
    .lg\:hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
}

/* CRITICAL: Override loans page SVG hiding for hamburger menu */
button#mobile-menu-toggle svg,
#mobile-menu-toggle svg,
nav button svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
}

/* Override the loans page inline styles that hide SVGs */
[data-page="loans"] button#mobile-menu-toggle,
[data-page="loans"] button#mobile-menu-toggle svg,
[data-page="loans"] #mobile-menu-toggle,
[data-page="loans"] #mobile-menu-toggle svg {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

[data-page="loans"] button#mobile-menu-toggle svg {
    display: block !important;
}

/* Fix modal close button visibility */
.modal button[type="button"],
.modal .close,
.modal .modal-close,
#improvement-modal button,
#loan-agreement-modal button {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fix modal close button SVG icons */
.modal button svg,
.modal .close svg,
.modal .modal-close svg,
#improvement-modal button svg,
#loan-agreement-modal button svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
}

/* Ensure modal close buttons work on loans page */
[data-page="loans"] .modal button,
[data-page="loans"] .modal button svg,
[data-page="loans"] #improvement-modal button,
[data-page="loans"] #improvement-modal button svg,
[data-page="loans"] #loan-agreement-modal button,
[data-page="loans"] #loan-agreement-modal button svg {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

[data-page="loans"] .modal button svg,
[data-page="loans"] #improvement-modal button svg,
[data-page="loans"] #loan-agreement-modal button svg {
    display: block !important;
}

/* Mobile responsive modal styling */
@media (max-width: 768px) {
    /* Loan Agreement Modal Mobile Optimization - Only when visible */
    #loan-agreement-modal:not(.hidden) {
        padding: 1rem !important;
        align-items: center !important;
        justify-content: center !important;
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1050 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
    }

    /* Ensure modal is hidden when it should be */
    #loan-agreement-modal.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    #loan-agreement-modal .inline-block,
    #loan-agreement-modal .modal-content {
        width: 90% !important;
        max-width: 90% !important;
        margin: auto !important;
        border-radius: 0.75rem !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        background: white !important;
        position: relative !important;
    }

    /* Modal header mobile optimization */
    #loan-agreement-modal .modal-header,
    #loan-agreement-modal h3 {
        font-size: 1.125rem !important;
        line-height: 1.4 !important;
        padding: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Modal body mobile optimization */
    #loan-agreement-modal .modal-body,
    #loan-agreement-modal .p-6 {
        padding: 1rem !important;
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }

    /* Modal footer mobile optimization - Compact inline buttons */
    #loan-agreement-modal .modal-footer,
    #loan-agreement-modal .flex.justify-end,
    #loan-agreement-modal .bg-gray-50 {
        padding: 0.75rem !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        border-top: 1px solid #e5e7eb !important;
        margin-top: auto !important;
        justify-content: center !important;
    }

    /* Mobile-specific compact buttons */
    #loan-agreement-modal button {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        border-radius: 0.375rem !important;
        margin: 0 !important;
        min-width: 80px !important;
        max-width: 120px !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 500 !important;
        border: 1px solid #d1d5db !important;
    }

    /* Cancel button - Always gray, never changes */
    #loan-agreement-modal button:first-child,
    #loan-agreement-modal button[onclick*="cancel"],
    #loan-agreement-modal button[onclick*="close"] {
        background-color: #f3f4f6 !important;
        color: #374151 !important;
        border-color: #d1d5db !important;
    }

    #loan-agreement-modal button:first-child:hover,
    #loan-agreement-modal button[onclick*="cancel"]:hover,
    #loan-agreement-modal button[onclick*="close"]:hover {
        background-color: #e5e7eb !important;
    }

    /* Agree button - Disabled state (gray) */
    #loan-agreement-modal button:last-child[disabled],
    #loan-agreement-modal button[onclick*="agree"][disabled],
    #loan-agreement-modal button[id*="agree"][disabled] {
        background-color: #f3f4f6 !important;
        color: #9ca3af !important;
        border-color: #d1d5db !important;
        cursor: not-allowed !important;
        opacity: 0.6 !important;
    }

    /* Agree button - Enabled state (green) - ONLY this button should turn green */
    #loan-agreement-modal button:last-child:not([disabled]),
    #loan-agreement-modal button[onclick*="agree"]:not([disabled]),
    #loan-agreement-modal button[id*="agree"]:not([disabled]) {
        background-color: #10b981 !important;
        color: white !important;
        border-color: #10b981 !important;
        cursor: pointer !important;
        opacity: 1 !important;
    }

    #loan-agreement-modal button:last-child:not([disabled]):hover,
    #loan-agreement-modal button[onclick*="agree"]:not([disabled]):hover,
    #loan-agreement-modal button[id*="agree"]:not([disabled]):hover {
        background-color: #059669 !important;
        border-color: #059669 !important;
    }

    /* Override any hiding from loans page JavaScript */
    [data-page="loans"] #loan-agreement-modal button {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Ensure modal content area is scrollable */
    #loan-agreement-modal .modal-body,
    #loan-agreement-modal .overflow-y-auto {
        max-height: calc(80vh - 8rem) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 1rem !important;
    }

    /* Close button mobile positioning */
    #loan-agreement-modal .close,
    #loan-agreement-modal button[type="button"]:first-child {
        position: absolute !important;
        top: 1rem !important;
        right: 1rem !important;
        width: 2rem !important;
        height: 2rem !important;
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.1) !important;
        border-radius: 50% !important;
        z-index: 10 !important;
    }

    /* Improvement Modal Mobile Optimization - Only when visible */
    #improvement-modal:not(.hidden) {
        padding: 1rem !important;
        align-items: center !important;
        justify-content: center !important;
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1050 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
    }

    /* Ensure improvement modal is hidden when it should be */
    #improvement-modal.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    #improvement-modal .inline-block {
        width: 90% !important;
        max-width: 90% !important;
        margin: auto !important;
        border-radius: 0.75rem !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        background: white !important;
        position: relative !important;
    }

    /* Ensure scroll-to-agree functionality works on mobile */
    #loan-agreement-modal .agreement-content,
    #loan-agreement-modal .terms-content {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Force scroll container to be the modal body */
    #loan-agreement-modal .modal-content {
        display: flex !important;
        flex-direction: column !important;
        height: 80vh !important;
    }

    #loan-agreement-modal .modal-header {
        flex-shrink: 0 !important;
    }

    #loan-agreement-modal .modal-body {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #loan-agreement-modal .modal-footer {
        flex-shrink: 0 !important;
    }

    /* Ensure agree button starts disabled and becomes enabled after scroll */
    #loan-agreement-modal button[disabled] {
        opacity: 0.5 !important;
        cursor: not-allowed !important;
        background-color: #9ca3af !important;
    }

    #loan-agreement-modal button:not([disabled]) {
        opacity: 1 !important;
        cursor: pointer !important;
    }
}

/* Reduce drop shadows on loans page */
.loans-container .shadow-lg,
.loans-container .shadow-xl,
.loans-container .shadow-md,
.loans-container .shadow-sm {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
}

/* Specific loans page shadow reductions */
.loans-container .bg-white.rounded-lg.shadow-lg,
.loans-container .bg-white.rounded-xl.shadow-lg,
.loans-container .bg-white.rounded-2xl.shadow-lg {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Remove shadows from loan cards */
.loans-container .loan-card,
.loans-container .credit-score-card,
.loans-container .loan-offer-card {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Reduce "No active loans" text size for mobile only */
@media (max-width: 768px) {
    .loans-container h3:contains("No active loans"),
    .loans-container .text-lg:contains("No active loans") {
        font-size: 1rem !important;
        line-height: 1.4 !important;
    }

    .loans-container p:contains("You don't have any active loans at the moment") {
        font-size: 0.875rem !important;
        line-height: 1.3 !important;
    }

    /* Target specific no loans message styling */
    .loans-container .text-center h3,
    .loans-container .text-center .text-lg {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .loans-container .text-center p {
        font-size: 0.875rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Ensure hamburger menu is visible on loans page */
#mobile-menu-toggle {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure navigation is visible on loans page */
nav.bg-white.border-b.border-gray-200.shadow-sm {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force hamburger menu visibility on mobile for loans page */
@media (max-width: 1023px) {
    #mobile-menu-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1000 !important;
    }

    .lg\:hidden {
        display: inline-flex !important;
    }
}

/* Aggressively reduce spacing between navigation and main content */
.min-h-screen.bg-gradient-to-br.from-slate-50.via-blue-50.to-indigo-100 > div {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Remove top padding from main container */
.max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 {
    padding-top: 0.25rem !important;
}

/* Reduce spacing in the header section specifically */
.max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8 {
    margin-bottom: 0.25rem !important;
}

/* Hide footer on mobile and reduce padding */
@media (max-width: 768px) {
    /* Hide the footer completely on mobile */
    footer.bg-white.border-t.border-gray-200 {
        display: none !important;
    }

    /* Reduce main content padding on mobile */
    main.flex-grow {
        padding-top: 0 !important;
        padding-bottom: 0.25rem !important;
        margin-top: 0 !important;
    }

    /* Reduce body padding */
    body {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin-top: 0 !important;
    }

    /* Reduce container padding */
    .min-h-screen {
        padding-bottom: 0 !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* Reduce wallet page specific padding */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-top: 0 !important;
        padding-bottom: 0.25rem !important;
        margin-top: 0 !important;
    }

    /* Remove top padding from the main gradient container */
    .min-h-screen.bg-gradient-to-br {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* Reduce space between sections */
    .space-y-8 > * + * {
        margin-top: 0.75rem !important;
    }

    .mb-8 {
        margin-bottom: 0.75rem !important;
    }

    .mt-8 {
        margin-top: 0.5rem !important;
    }

    /* Remove top margins from first elements */
    .space-y-8 > *:first-child {
        margin-top: 0 !important;
    }

    /* Reduce page header padding */
    .py-6 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    /* Reduce spacing between header and financial dashboard */
    .mb-8:first-child {
        margin-bottom: 0.25rem !important;
    }

    /* Specifically target the header section */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8:first-child {
        margin-bottom: 0.25rem !important;
    }

    /* Reduce spacing in header elements */
    .text-4xl.font-bold.bg-gradient-to-r {
        margin-bottom: 0.25rem !important;
    }

    /* Reduce spacing between title and subtitle */
    .flex.items-center.space-x-3 {
        margin-top: 0.25rem !important;
    }

    /* Reduce the main container py-8 padding */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 {
        padding-top: 0 !important;
        padding-bottom: 0.25rem !important;
    }

    /* Override any py-8 class specifically */
    .py-8 {
        padding-top: 0 !important;
        padding-bottom: 0.25rem !important;
    }

    /* Remove any top margins from the first child elements */
    .max-w-7xl.mx-auto > *:first-child {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Target the specific wallet page structure */
    .min-h-screen.bg-gradient-to-br.from-slate-50 {
        padding-top: 0 !important;
    }

    /* Remove top spacing from navigation area if any */
    nav + main,
    header + main {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Ultra-aggressive top space removal */
    * {
        margin-top: 0 !important;
    }

    /* Target all possible layout containers */
    .flex-grow,
    .main-content,
    main,
    .container,
    .max-w-7xl {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Remove any default browser margins */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Target the app layout structure */
    .min-h-screen.bg-gray-100,
    .min-h-screen.bg-gradient-to-br,
    .min-h-screen {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Remove spacing from any wrapper divs */
    div[class*="min-h-screen"] {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Force remove top spacing from all elements in the first 3 levels */
    body > *,
    body > * > *,
    body > * > * > * {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Reduce header title font size on mobile */
    .text-4xl.font-bold {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0 !important;
    }

    /* Reduce subtitle font size */
    .text-xl.font-bold.text-slate-700 {
        font-size: 1rem !important;
    }

    /* Aggressively reduce spacing between title and subtitle */
    .text-4xl.font-bold.bg-gradient-to-r.from-slate-900.via-blue-900.to-indigo-900.bg-clip-text.text-transparent.mb-2 {
        margin-bottom: 0 !important;
    }

    /* Reduce spacing in the header flex container */
    .flex.items-center.space-x-3 {
        margin-top: 0 !important;
    }

    /* Target the specific header structure and reduce all spacing */
    .max-w-7xl.mx-auto > .mb-8:first-child .flex.items-center.justify-between {
        margin-bottom: 0 !important;
    }

    /* Reduce spacing between header elements */
    .flex.items-center.justify-between > div:first-child {
        margin-bottom: 0 !important;
    }

    /* Target the specific wallet header structure */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8:first-child {
        margin-bottom: 0.125rem !important;
        padding-bottom: 0 !important;
    }

    /* Remove spacing from the header wrapper */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8:first-child > .flex.items-center.justify-between {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Reduce spacing in the title section */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8:first-child h1 {
        margin-bottom: 0.125rem !important;
    }

    /* Reduce spacing for the subtitle container */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 > .mb-8:first-child .flex.items-center.space-x-3 {
        margin-top: 0.125rem !important;
    }



    /* Reduce padding for wallet cards */
    .bg-white\/70.backdrop-blur-sm.rounded-2xl {
        margin-bottom: 1rem !important;
    }

    .bg-white\/70.backdrop-blur-sm.rounded-2xl .p-6 {
        padding: 1rem !important;
    }

    /* Reduce balance card padding */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Mobile-specific body class targeting */
body.wallet-mobile-view .transaction-item {
    transition: all 0.2s ease !important;
}

body.wallet-mobile-view .transaction-item:active {
    background-color: rgba(255, 255, 255, 0.9) !important;
    transform: scale(0.98) !important;
}

/* ===== WALLET PAGE MOBILE IMPROVEMENTS ===== */

/* Hide specific cards and elements on mobile */
@media (max-width: 768px) {
    /* Hide Virtual Account and Loans cards, but keep Quick Actions */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(2) {
        display: none !important;
    }

    /* Transform Virtual Account card to show only essential info */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) {
        position: absolute !important;
        right: 1rem !important;
        top: 1rem !important;
        width: auto !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        z-index: 20 !important;
        max-width: 120px !important;
    }

    /* Hide most content in virtual account card */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) > * {
        display: none !important;
    }

    /* Show only the account details container */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .bg-blue-50.border.border-blue-200.rounded-xl {
        display: block !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        position: relative !important;
    }

    /* Hide everything inside the account details container first */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .bg-blue-50.border.border-blue-200.rounded-xl > * {
        display: none !important;
    }

    /* Show only the account number and bank name */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .text-sm.font-bold.text-blue-900,
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .text-lg.font-bold.text-blue-900 {
        display: block !important;
        color: rgba(255, 255, 255, 0.95) !important;
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        text-align: right !important;
        margin: 0.125rem 0 !important;
        line-height: 1.2 !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }

    /* Make bank name slightly smaller */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .text-lg.font-bold.text-blue-900 {
        font-size: 0.6875rem !important;
        font-weight: 500 !important;
    }

    /* Add "Virtual Account" label */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(1) .bg-blue-50.border.border-blue-200.rounded-xl::before {
        content: "Virtual Account" !important;
        display: block !important;
        color: rgba(255, 255, 255, 0.85) !important;
        font-size: 0.625rem !important;
        font-weight: 500 !important;
        text-align: right !important;
        margin-bottom: 0.25rem !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }

    /* Keep Quick Actions card visible and make it full width */
    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 {
        grid-template-columns: 1fr !important;
    }

    .grid.grid-cols-1.lg\:grid-cols-3.gap-6.mb-8 > div:nth-child(3) {
        display: block !important;
        margin-bottom: 1rem !important;
    }

    /* Compact Quick Actions card for mobile */
    .bg-purple-50.rounded-2xl.p-6 {
        padding: 1rem !important;
    }

    /* Change Quick Actions to 3 columns and hide Accounts */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 0.375rem !important;
    }

    /* Hide the Accounts (Virtual Accounts) action */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a[href*="virtual-accounts"] {
        display: none !important;
    }

    /* Make Quick Action items more compact */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a {
        padding: 0.5rem 0.25rem !important;
        text-align: center !important;
    }

    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a .w-10.h-10 {
        width: 2rem !important;
        height: 2rem !important;
        margin-bottom: 0.375rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Increase icon size within the containers */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a .w-10.h-10 svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a .text-sm {
        font-size: 0.6875rem !important;
        line-height: 1.2 !important;
    }

    /* Add virtual account info below Quick Actions */
    .bg-purple-50.rounded-2xl::after {
        content: "" !important;
        display: block !important;
        margin-top: 1rem !important;
        padding-top: 0.75rem !important;
        border-top: 1px solid rgba(147, 51, 234, 0.2) !important;
    }

    /* Hide Last Deposit and This Month stats */
    .grid.grid-cols-2.gap-4.mb-8 {
        display: none !important;
    }

    /* Hide transaction filtering controls */
    .wallet-filter-controls {
        display: none !important;
    }

    /* Modify balance card layout for mobile */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .p-6 {
        padding: 1rem !important;
    }

    /* Balance card mobile layout */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-center {
        text-align: left !important;
        margin-bottom: 1rem !important;
    }

    /* Balance amount positioning */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-5xl.md\:text-6xl {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.5rem !important;
    }

    /* Compact action buttons for mobile */
    .grid.grid-cols-2.gap-3 button,
    .grid.grid-cols-2.gap-3 a {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.6875rem !important;
        border-radius: 0.5rem !important;
    }

    .grid.grid-cols-2.gap-3 button svg,
    .grid.grid-cols-2.gap-3 a svg {
        width: 1rem !important;
        height: 1rem !important;
        margin-right: 0.375rem !important;
    }

    /* Create mobile balance card layout */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 {
        position: relative !important;
    }

    /* Mobile balance layout - left side */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-center.mb-8 {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        margin-bottom: 1rem !important;
        text-align: left !important;
    }

    /* Balance content on the left */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-center.mb-8 > div:first-child {
        flex: 1 !important;
    }

    /* Hide the icon on mobile */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .inline-flex.items-center.justify-center.w-12.h-12 {
        display: none !important;
    }

    /* Compact balance text */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-gray-600.text-sm.font-medium.mb-2 {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
        color: rgba(255, 255, 255, 0.8) !important;
    }

    /* Compact available balance text */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-gray-500.text-sm.mt-2 {
        font-size: 0.6875rem !important;
        margin-top: 0.25rem !important;
        color: rgba(255, 255, 255, 0.7) !important;
    }

    /* Virtual account info is now handled by CSS transformation above */

    /* Position action buttons on the right side */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .grid.grid-cols-2.gap-3 {
        position: absolute !important;
        right: 0.75rem !important;
        bottom: 0.75rem !important;
        width: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
    }

    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .grid.grid-cols-2.gap-3 button {
        width: 4rem !important;
        padding: 0.25rem 0.375rem !important;
        font-size: 0.625rem !important;
        white-space: nowrap !important;
        line-height: 1.1 !important;
    }

    /* Ensure balance card has enough height for mobile layout */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 {
        min-height: 8rem !important;
        position: relative !important;
    }

    /* Style for mobile virtual account info */
    .mobile-virtual-account-info {
        pointer-events: none !important;
    }
}

/* Recent Transactions Section - Super Compact Mobile */
@media (max-width: 768px) {
    /* Header section mobile optimization */
    .wallet-transactions-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: stretch !important;
    }

    .wallet-transactions-header h3 {
        font-size: 1rem !important;
        margin-bottom: 0.125rem !important;
        line-height: 1.25 !important;
    }

    .wallet-transactions-header p {
        font-size: 0.75rem !important;
        margin-top: 0.125rem !important;
        line-height: 1.25 !important;
    }

    /* Filter controls mobile optimization */
    .wallet-filter-controls {
        flex-direction: column !important;
        gap: 0.375rem !important;
        width: 100% !important;
    }

    .wallet-filter-controls select {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 0.5rem 2rem 0.5rem 0.625rem !important;
        height: 2.25rem !important;
        border-radius: 0.5rem !important;
        background-size: 12px !important;
        background-position: right 0.5rem center !important;
    }

    /* Make dropdown arrows smaller on mobile */
    .wallet-filter-controls .pointer-events-none svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }

    /* Super compact transaction items for mobile */
    .transaction-item {
        padding: 0.5rem !important;
        margin-bottom: 0.375rem !important;
        border-radius: 0.5rem !important;
        /* Keep horizontal layout */
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
    }

    /* Left side - icon and details */
    .transaction-item .flex.items-center:first-child {
        flex: 1 !important;
        min-width: 0 !important;
    }

    /* Compact icon */
    .transaction-item .w-12.h-12 {
        width: 2rem !important;
        height: 2rem !important;
        margin-right: 0.5rem !important;
        border-radius: 0.375rem !important;
        flex-shrink: 0 !important;
    }

    .transaction-item .w-12.h-12 svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }

    /* Compact transaction details */
    .transaction-item .font-semibold {
        font-size: 0.8125rem !important;
        line-height: 1.125 !important;
        margin-bottom: 0.125rem !important;
        /* Truncate long text */
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 200px !important;
    }

    /* Handle transaction description span separately */
    .transaction-item .font-semibold .font-normal {
        font-size: 0.75rem !important;
        color: #64748b !important;
    }

    .transaction-item .text-sm.text-slate-500 {
        font-size: 0.6875rem !important;
        line-height: 1 !important;
        margin-top: 0.25rem !important;
    }

    /* Right side content - amount and status */
    .transaction-item .text-right {
        text-align: right !important;
        flex-shrink: 0 !important;
        margin-left: 0.5rem !important;
        min-width: 80px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        justify-content: center !important;
    }

    .transaction-item .font-bold.text-lg {
        font-size: 0.875rem !important;
        line-height: 1.125 !important;
        margin-bottom: 0.125rem !important;
        white-space: nowrap !important;
    }

    /* Ensure currency amounts don't wrap */
    .transaction-item .whitespace-nowrap {
        font-size: 0.8125rem !important;
    }

    /* Super compact status badges */
    .transaction-item .inline-flex.items-center {
        font-size: 0.625rem !important;
        padding: 0.125rem 0.375rem !important;
        line-height: 1 !important;
    }

    .transaction-item .inline-flex.items-center .w-1\.5.h-1\.5 {
        width: 0.25rem !important;
        height: 0.25rem !important;
        margin-right: 0.25rem !important;
    }

    /* Reduce spacing between transactions */
    .space-y-3 > * + * {
        margin-top: 0.375rem !important;
    }

    /* Show only first 2 transactions on mobile */
    .space-y-3 .transaction-item:nth-child(n+3) {
        display: none !important;
    }

    /* Hide "View All Transactions" button */
    .mt-6.text-center {
        display: none !important;
    }

    /* Reduce padding in transaction container */
    .bg-white\/70.backdrop-blur-sm.rounded-2xl .p-6:last-child {
        padding: 0.75rem !important;
    }

    /* Compact header padding */
    .bg-white\/70.backdrop-blur-sm.rounded-2xl .p-6:first-child {
        padding: 0.75rem !important;
        border-bottom-width: 1px !important;
    }

    /* Ensure proper touch targets for mobile */
    .transaction-item {
        min-height: 3rem !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }

    /* Better mobile scrolling */
    .space-y-3 {
        -webkit-overflow-scrolling: touch !important;
    }

    /* Optimize whitespace usage */
    .transaction-item .font-semibold {
        margin-bottom: 0.125rem !important;
    }

    .transaction-item .text-sm.text-slate-500 {
        margin-top: 0.25rem !important;
    }

    /* Additional mobile optimizations */
    .transaction-item .flex.justify-end {
        margin-top: 0.0625rem !important;
    }

    /* Ensure consistent spacing in transaction container */
    .bg-white\/70.backdrop-blur-sm.rounded-2xl {
        margin-bottom: 1rem !important;
    }

    /* Optimize the main container padding */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8.py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* Medium mobile screens (larger phones, small tablets) */
@media (min-width: 481px) and (max-width: 768px) {
    .transaction-item {
        padding: 0.625rem !important;
    }

    .transaction-item .w-12.h-12 {
        width: 2.25rem !important;
        height: 2.25rem !important;
    }

    .transaction-item .font-semibold {
        font-size: 0.875rem !important;
        max-width: 250px !important;
    }

    .transaction-item .text-sm.text-slate-500 {
        font-size: 0.75rem !important;
        margin-top: 0.1875rem !important;
    }

    .transaction-item .font-bold.text-lg {
        font-size: 0.9375rem !important;
    }

    .transaction-item .inline-flex.items-center {
        font-size: 0.6875rem !important;
        padding: 0.1875rem 0.5rem !important;
    }

    .bg-white\/70.backdrop-blur-sm.rounded-2xl .p-6 {
        padding: 1rem !important;
    }
}

/* ===== WALLET TRANSACTIONS PAGE MOBILE IMPROVEMENTS ===== */

/* Convert table to mobile cards on small screens */
@media (max-width: 768px) {
    /* Hide table structure on mobile */
    .bg-white.rounded-xl.shadow-md table,
    .bg-white.rounded-xl.shadow-md thead,
    .bg-white.rounded-xl.shadow-md tbody,
    .bg-white.rounded-xl.shadow-md th,
    .bg-white.rounded-xl.shadow-md td,
    .bg-white.rounded-xl.shadow-md tr {
        display: block !important;
    }

    /* Hide table headers */
    .bg-white.rounded-xl.shadow-md thead tr {
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
    }

    /* Style table rows as cards */
    .bg-white.rounded-xl.shadow-md tbody tr {
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 0.75rem !important;
        margin-bottom: 0.75rem !important;
        padding: 1rem !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }

    /* Style table cells as mobile content */
    .bg-white.rounded-xl.shadow-md tbody td {
        border: none !important;
        padding: 0.25rem 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 0.5rem !important;
    }

    /* Add labels before content */
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(1):before { content: "ID: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(2):before { content: "Type: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(3):before { content: "Amount: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(4):before { content: "Description: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(5):before { content: "Status: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(6):before { content: "Date: "; font-weight: 600; color: #374151; }
    .bg-white.rounded-xl.shadow-md tbody td:nth-child(7):before { content: "Actions: "; font-weight: 600; color: #374151; }

    /* Compact mobile content */
    .bg-white.rounded-xl.shadow-md tbody td .text-sm {
        font-size: 0.8125rem !important;
    }

    /* Compact badges */
    .bg-white.rounded-xl.shadow-md tbody td .px-2.inline-flex {
        font-size: 0.6875rem !important;
        padding: 0.125rem 0.375rem !important;
    }

    /* Compact action buttons */
    .bg-white.rounded-xl.shadow-md tbody td a {
        padding: 0.375rem !important;
    }

    .bg-white.rounded-xl.shadow-md tbody td a svg {
        width: 1rem !important;
        height: 1rem !important;
    }

    /* Remove last margin from last cell */
    .bg-white.rounded-xl.shadow-md tbody td:last-child {
        margin-bottom: 0 !important;
    }

    /* Compact page header */
    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8 .mb-8 h1 {
        font-size: 1.5rem !important;
    }

    .max-w-7xl.mx-auto.px-4.sm\:px-6.lg\:px-8 .mb-8 p {
        font-size: 0.875rem !important;
    }
}

/* ===== LOANS PAGE MOBILE IMPROVEMENTS ===== */

@media (max-width: 768px) {
    /* Page header mobile optimization */
    .loans-header {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: stretch !important;
    }
    
    .loans-header h2 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Button group mobile optimization - Keep inline but smaller */
    .loans-button-group {
        flex-direction: row !important;
        gap: 0.25rem !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    .loans-button-group a,
    .loans-button-group button {
        flex: 1 !important;
        min-width: 0 !important;
        justify-content: center !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
        text-transform: none !important;
        letter-spacing: normal !important;
        white-space: nowrap !important;
    }

    /* Adjust button icons on mobile */
    .loans-button-group svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
        margin-right: 0.25rem !important;
    }
    
    /* Loan Settings button mobile text */
    .loans-settings-btn .btn-text-desktop {
        display: none !important;
    }
    
    .loans-settings-btn .btn-text-mobile {
        display: inline !important;
    }
    
    /* Apply for Loan button mobile text */
    .loans-apply-btn .btn-text-desktop {
        display: none !important;
    }
    
    .loans-apply-btn .btn-text-mobile {
        display: inline !important;
    }
    
    /* KYC verification button mobile text */
    .loans-kyc-btn .btn-text-desktop {
        display: none !important;
    }
    
    .loans-kyc-btn .btn-text-mobile {
        display: inline !important;
    }
    
    /* Credit score card mobile optimization */
    .credit-score-card {
        flex-direction: row !important;
        text-align: left !important;
        gap: 1rem !important;
        align-items: center !important;
    }

    .score-circle {
        margin: 0 !important;
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0 !important;
    }

    .credit-score-info {
        flex: 1 !important;
    }

    .credit-score-info h3 {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
        line-height: 1.2 !important;
    }

    .credit-score-info p {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
        line-height: 1.2 !important;
    }

    /* Ensure credit score section is always visible and properly spaced */
    .credit-score-card {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .credit-score-info {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .credit-score-info h3,
    .credit-score-info p {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Tabs mobile optimization */
    .loans-tabs {
        flex-direction: row !important; /* Keep horizontal on mobile */
    }
    
    .loans-tab-button {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.875rem !important;
        text-align: center !important;
    }
    
    /* Tab content mobile optimization */
    .loans-tab-content {
        padding: 1rem !important;
    }
    
    /* Loan cards mobile optimization */
    .loan-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .loan-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .loan-card-amount {
        font-size: 1.125rem !important;
        font-weight: 600 !important;
    }
    
    .loan-card-status {
        align-self: flex-start !important;
    }
    
    .loan-card-details {
        margin-top: 0.75rem !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    .loan-detail-item {
        font-size: 0.75rem !important;
    }
    
    .loan-detail-label {
        color: #6b7280 !important;
        margin-bottom: 0.125rem !important;
    }
    
    .loan-detail-value {
        font-weight: 500 !important;
        color: #111827 !important;
    }
}

/* Desktop button text visibility */
@media (min-width: 769px) {
    .loans-settings-btn .btn-text-desktop {
        display: inline !important;
    }
    
    .loans-settings-btn .btn-text-mobile {
        display: none !important;
    }
    
    .loans-apply-btn .btn-text-desktop {
        display: inline !important;
    }
    
    .loans-apply-btn .btn-text-mobile {
        display: none !important;
    }
    
    .loans-kyc-btn .btn-text-desktop {
        display: inline !important;
    }
    
    .loans-kyc-btn .btn-text-mobile {
        display: none !important;
    }
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
    /* Increase touch targets */
    button, .btn, a.btn,
    [type='button'],
    [type='submit'] {
        min-height: 2.75rem !important;
        padding: 0.75rem 1rem !important;
    }
    
    /* Improve tap targets for tabs */
    .tab-button {
        min-height: 3rem !important;
        padding: 0.75rem 1rem !important;
    }
    
    /* Better spacing for mobile cards */
    .bg-white.rounded-xl,
    .bg-white.rounded-lg {
        margin-bottom: 1rem !important;
    }
}

/* Ensure proper text wrapping on mobile */
@media (max-width: 640px) {
    .wallet-transactions-header p {
        display: block !important; /* Show subtitle on larger mobile screens */
    }
}

/* ===== LOAN TABLES MOBILE IMPROVEMENTS ===== */

/* Hide table headers on mobile and show card layout instead */
@media (max-width: 768px) {
    /* Hide the table structure on mobile */
    .loans-table-container table,
    .loans-table-container thead,
    .loans-table-container tbody,
    .loans-table-container th,
    .loans-table-container td,
    .loans-table-container tr {
        display: none !important;
    }

    /* Show mobile card layout */
    .loans-mobile-cards {
        display: block !important;
    }

    .loan-mobile-card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .loan-mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #f3f4f6;
    }

    .loan-mobile-card-id {
        font-weight: 600;
        font-size: 1rem;
        color: #111827;
    }

    .loan-mobile-card-status {
        padding: 0.25rem 0.75rem;
        border-radius: 9999px;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
    }

    .loan-mobile-card-status.active,
    .loan-mobile-card-status.approved,
    .loan-mobile-card-status.disbursed {
        background-color: #dcfce7;
        color: #166534;
    }

    .loan-mobile-card-status.completed,
    .loan-mobile-card-status.paid {
        background-color: #dcfce7;
        color: #166534;
    }

    .loan-mobile-card-status.rejected {
        background-color: #fef2f2;
        color: #dc2626;
    }

    .loan-mobile-card-status.pending {
        background-color: #fef3c7;
        color: #d97706;
    }

    .loan-mobile-card-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .loan-mobile-card-detail {
        display: flex;
        flex-direction: column;
    }

    .loan-mobile-card-detail-label {
        font-size: 0.75rem;
        color: #6b7280;
        font-weight: 500;
        margin-bottom: 0.25rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    .loan-mobile-card-detail-value {
        font-size: 0.875rem;
        color: #111827;
        font-weight: 600;
    }

    .loan-mobile-card-actions {
        display: flex;
        gap: 0.5rem;
        justify-content: flex-end;
        padding-top: 0.75rem;
        border-top: 1px solid #f3f4f6;
    }

    .loan-mobile-card-action {
        padding: 0.5rem 1rem;
        border-radius: 0.375rem;
        font-size: 0.75rem;
        font-weight: 500;
        text-decoration: none;
        transition: all 0.2s ease-in-out;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }

    .loan-mobile-card-action.view {
        background-color: #f3f4f6;
        color: #374151;
        border: 1px solid #d1d5db;
    }

    .loan-mobile-card-action.view:hover {
        background-color: #e5e7eb;
        color: #111827;
    }

    .loan-mobile-card-action.pay {
        background-color: #10b981;
        color: white;
        border: 1px solid #10b981;
    }

    .loan-mobile-card-action.pay:hover {
        background-color: #059669;
        border-color: #059669;
    }

    .loan-mobile-card-action svg {
        width: 0.75rem;
        height: 0.75rem;
    }
}

/* Desktop: Hide mobile cards and show table */
@media (min-width: 769px) {
    .loans-mobile-cards {
        display: none !important;
    }

    .loans-table-container {
        display: block !important;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 480px) {
    /* Extra compact wallet transactions for very small screens */
    .wallet-transactions-header h3 {
        font-size: 0.9375rem !important;
    }

/* Hide virtual account section in Quick Actions on desktop */
@media (min-width: 769px) {
    .mobile-virtual-account-section {
        display: none !important;
    }

    /* Reset Quick Actions to normal grid on desktop */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Show the Accounts action on desktop */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a[href*="virtual-accounts"] {
        display: flex !important;
    }

    /* Reset icon sizes for desktop */
    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a .w-10.h-10 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .bg-purple-50.rounded-2xl .grid.grid-cols-2.gap-3 a .w-10.h-10 svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
}

    .wallet-transactions-header p {
        font-size: 0.6875rem !important;
    }

    .wallet-filter-controls select {
        font-size: 0.6875rem !important;
        padding: 0.375rem 1.75rem 0.375rem 0.5rem !important;
        height: 2rem !important;
    }

    .transaction-item {
        padding: 0.375rem !important;
        margin-bottom: 0.25rem !important;
    }

    .transaction-item .w-12.h-12 {
        width: 1.75rem !important;
        height: 1.75rem !important;
        margin-right: 0.375rem !important;
    }

    .transaction-item .w-12.h-12 svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }

    .transaction-item .font-semibold {
        font-size: 0.75rem !important;
        line-height: 1 !important;
    }

    .transaction-item .text-sm.text-slate-500 {
        font-size: 0.625rem !important;
        margin-top: 0.1875rem !important;
    }

    .transaction-item .font-bold.text-lg {
        font-size: 0.8125rem !important;
    }

    .transaction-item .inline-flex.items-center {
        font-size: 0.5625rem !important;
        padding: 0.0625rem 0.25rem !important;
    }

    .space-y-3 > * + * {
        margin-top: 0.25rem !important;
    }

    .bg-white\/70.backdrop-blur-sm.rounded-2xl .p-6 {
        padding: 0.5rem !important;
    }

    .mt-6.text-center a {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
        margin-top: 0.75rem !important;
    }

    /* Extra compact balance card for very small screens */
    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 {
        min-height: 6rem !important;
    }

    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .text-5xl.md\:text-6xl {
        font-size: 1.75rem !important;
    }

    .bg-gradient-to-br.from-emerald-500.via-green-500.to-teal-500 .grid.grid-cols-2.gap-3 button {
        width: 3.5rem !important;
        padding: 0.1875rem 0.25rem !important;
        font-size: 0.5625rem !important;
        line-height: 1.0 !important;
    }

    /* Extra compact virtual account info */
    .mobile-virtual-account-info div {
        font-size: 0.625rem !important;
    }

    /* Extra compact transactions table for very small screens */
    .bg-white.rounded-xl.shadow-md tbody tr {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    .bg-white.rounded-xl.shadow-md tbody td {
        padding: 0.125rem 0 !important;
        margin-bottom: 0.25rem !important;
    }

    .bg-white.rounded-xl.shadow-md tbody td:before {
        font-size: 0.6875rem !important;
    }

    .bg-white.rounded-xl.shadow-md tbody td .text-sm {
        font-size: 0.75rem !important;
    }

    .bg-white.rounded-xl.shadow-md tbody td .px-2.inline-flex {
        font-size: 0.625rem !important;
        padding: 0.0625rem 0.25rem !important;
    }

    /* Loans page optimizations for very small screens */
    .loans-header h2 {
        font-size: 1.125rem !important;
    }

    .credit-score-info h3 {
        font-size: 0.875rem !important;
    }

    .loans-tab-button {
        font-size: 0.75rem !important;
        padding: 0.5rem 0.25rem !important;
    }

    /* Extra small buttons for very small screens */
    .loans-button-group a,
    .loans-button-group button {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.6875rem !important;
        gap: 0.125rem !important;
    }

    /* Ensure credit score section is compact */
    .credit-score-card {
        padding: 0.75rem !important;
    }

    .score-circle {
        width: 40px !important;
        height: 40px !important;
    }

    .credit-score-info h3 {
        font-size: 0.75rem !important;
    }

    .credit-score-info p {
        font-size: 0.6875rem !important;
    }
}

/* Desktop modal buttons - Same functionality, standard sizing */
@media (min-width: 769px) {
    /* Desktop button styling */
    #loan-agreement-modal button {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
        border-radius: 0.375rem !important;
        margin: 0 !important;
        min-width: 100px !important;
        max-width: 150px !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 500 !important;
        border: 1px solid #d1d5db !important;
    }

    /* Desktop modal footer */
    #loan-agreement-modal .modal-footer,
    #loan-agreement-modal .flex.justify-end,
    #loan-agreement-modal .bg-gray-50 {
        padding: 1rem 1.5rem !important;
        flex-direction: row !important;
        gap: 0.75rem !important;
        justify-content: flex-end !important;
        background: white !important;
        border-top: 1px solid #e5e7eb !important;
    }

    /* Desktop Cancel button - Always gray, never changes */
    #loan-agreement-modal button:first-child,
    #loan-agreement-modal button[onclick*="cancel"],
    #loan-agreement-modal button[onclick*="close"] {
        background-color: #f3f4f6 !important;
        color: #374151 !important;
        border-color: #d1d5db !important;
    }

    #loan-agreement-modal button:first-child:hover,
    #loan-agreement-modal button[onclick*="cancel"]:hover,
    #loan-agreement-modal button[onclick*="close"]:hover {
        background-color: #e5e7eb !important;
    }

    /* Desktop Agree button - Disabled state (gray) */
    #loan-agreement-modal button:last-child[disabled],
    #loan-agreement-modal button[onclick*="agree"][disabled],
    #loan-agreement-modal button[id*="agree"][disabled] {
        background-color: #f3f4f6 !important;
        color: #9ca3af !important;
        border-color: #d1d5db !important;
        cursor: not-allowed !important;
        opacity: 0.6 !important;
    }

    /* Desktop Agree button - Enabled state (green) - ONLY this button should turn green */
    #loan-agreement-modal button:last-child:not([disabled]),
    #loan-agreement-modal button[onclick*="agree"]:not([disabled]),
    #loan-agreement-modal button[id*="agree"]:not([disabled]) {
        background-color: #10b981 !important;
        color: white !important;
        border-color: #10b981 !important;
        cursor: pointer !important;
        opacity: 1 !important;
    }

    #loan-agreement-modal button:last-child:not([disabled]):hover,
    #loan-agreement-modal button[onclick*="agree"]:not([disabled]):hover,
    #loan-agreement-modal button[id*="agree"]:not([disabled]):hover {
        background-color: #059669 !important;
        border-color: #059669 !important;
    }
}
