/**
 * Mobile-friendly layout for Money Changer (phones & tablets).
 */

.login-info {
    background: #ecfdf5;
    color: #065f46;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 12px;
    text-align: center;
}

.login-help {
    font-size: 12px;
    color: #5b6b82;
    line-height: 1.45;
    margin: 0 0 16px;
}

.login-forgot {
    text-align: center;
    margin-top: 14px;
    font-size: 12px;
}

.login-forgot a {
    color: #1e4a7a;
    font-weight: 600;
}

.login-panel-single {
    grid-template-columns: 1fr;
    max-width: 480px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
}

body.sidebar-mobile-open .sidebar-backdrop {
    display: block;
}

.alert-banner {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 12px;
}

.alert-banner:focus,
.login-error:focus,
.login-info:focus,
.flash:focus,
.mas-bulk-flash:focus,
.dup-customer-banner:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #99f6e4;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.profile-box h3 {
    margin: 0 0 12px;
    font-size: 14px;
    color: #1a2332;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-stack label {
    font-size: 11px;
    font-weight: 600;
    color: #5b6b82;
}

.form-stack input {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
}

.form-hint {
    margin: 0;
    font-size: 11px;
    color: #64748b;
}

/* Prevent horizontal page scroll; wide content scrolls inside wrappers */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.app-body,
body.mc-standalone {
    overflow-x: clip;
}

.app-shell {
    min-width: 0;
}

/* Touch-friendly controls */
@media (max-width: 900px) {
    .app-topbar {
        padding: 0;
    }

    .app-topbar .topbar-row-main {
        padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
    }

    .topbar-right {
        gap: 8px;
        font-size: 11px;
    }

    .topbar-user {
        display: none;
    }

    .app-content,
    .content {
        padding: 12px 14px max(24px, env(safe-area-inset-bottom, 0px));
        max-width: 100%;
    }

    .app-sidebar {
        width: min(300px, 88vw);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 110;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    .app-shell {
        margin-left: 0 !important;
    }

    body.sidebar-collapsed .app-shell {
        margin-left: 0 !important;
    }

    .nav-link,
    .nav-group-toggle,
    .nav-submenu a,
    .nav-subgroup-toggle,
    .nav-submenu-nested a,
    .btn:not(.btn-sm):not(.btn-xs),
    button:not(.btn-sm):not(.btn-xs),
    .topbar-link,
    .topbar-menu-btn,
    .topbar-theme-opt {
        min-height: 44px;
    }

    .nav-submenu a,
    .nav-subgroup-toggle,
    .nav-submenu-nested a {
        padding: 10px 12px;
        font-size: var(--nav-submenu-font-size, 12px);
    }

    .nav-submenu-nested a {
        padding: 10px 12px 10px 28px;
    }

    .dash-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-header h1 {
        font-size: 18px;
    }

    .page-header-actions,
    .page-toolbar,
    .toolbar-row {
        flex-wrap: wrap;
        width: 100%;
    }

    /* Horizontal scroll for wide tables (keep table display intact) */
    .table-scroll,
    .table-scroll-wrap,
    .table-wrap,
    .table-responsive,
    .ua-table-scroll,
    .curr-table-scroll,
    .bk-table-scroll,
    .rb-rates-table-wrap,
    .fr-table-scroll,
    .grid-scroll,
    .grid-container,
    .cm-contact-all-scroll,
    .dayend-history-scroll,
    .mas-table-wrap,
    .je-table-scroll,
    .lce-table-scroll,
    .gl-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .app-content .box,
    .app-content .card,
    .app-content .panel,
    .app-content .admin-card {
        max-width: 100%;
    }

    .app-content .box:has(> table),
    .app-content .card:has(> table) {
        overflow-x: auto;
    }

    #grid {
        min-width: 640px;
    }

    .app-content .form-grid,
    .app-content .admin-page .form-grid,
    .app-content .filter-bar,
    .filter-row {
        grid-template-columns: 1fr !important;
        flex-direction: column;
        align-items: stretch !important;
    }

    .app-content .two-column,
    .two-col,
    .split-layout {
        grid-template-columns: 1fr !important;
    }

    .app-content .container {
        height: auto !important;
        min-height: calc(100dvh - var(--topbar-h) - 24px);
    }

    body.forex-teller-active main.app-content.content {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    body.quick-transaction-page main.app-content.content {
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 10px 12px max(20px, env(safe-area-inset-bottom, 0px));
    }

    body.quick-transaction-page .qt-container.forex-entry-container {
        min-height: 0;
    }

    body.quick-transaction-page .qt-grid-card {
        flex: 1 1 auto;
        min-height: 200px;
    }

    body.quick-transaction-page .qt-grid-card .grid-container {
        max-height: min(50vh, 420px);
    }

    .app-notif-panel {
        right: -8px;
    }

    .table-scroll {
        height: auto !important;
        max-height: min(72vh, 560px) !important;
    }

    /* DataTables controls stack on narrow screens */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        width: 100%;
        margin-bottom: 8px;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
        width: 100%;
        margin-top: 8px;
    }

    /* Modals & overlays */
    .modal-dialog {
        margin: 0.75rem auto;
        max-width: calc(100vw - 1.5rem);
    }

    .modal-fullscreen-sm-down {
        width: 100vw;
        max-width: none;
        margin: 0;
    }

    .dim-dialog {
        width: min(520px, calc(100vw - 16px));
        max-height: calc(100dvh - 16px);
    }

    .amb-dialog {
        max-width: calc(100vw - 24px);
    }

    /* iOS: avoid zoom on focus for form fields (not grid cells) */
    .app-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]),
    .app-content select,
    .app-content textarea,
    .login-panel input,
    .mc-standalone input:not([type="checkbox"]):not([type="radio"]),
    .mc-standalone select,
    .mc-standalone textarea {
        font-size: 16px;
    }

    .reset-pass-form {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .reset-pass-form input {
        width: 100%;
        min-width: 0;
    }

    .login-panel {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .login-brand {
        padding: 24px 20px;
    }
}

@media (max-width: 600px) {
    .topbar-context {
        display: none;
    }

    .topbar-link {
        padding: 8px 10px;
    }

    .page-header h1 {
        font-size: 16px;
    }

    .sidebar-brand .brand-logo {
        max-width: 100%;
        height: auto;
    }

    .app-content .card,
    .app-content .panel {
        padding: 12px;
    }

    .app-content table th,
    .app-content table td {
        padding: 8px 6px;
        font-size: 11px;
    }

    #grid {
        min-width: 560px;
    }
}

/* Tablet landscape — between phone and desktop shell */
@media (min-width: 601px) and (max-width: 900px) {
    .profile-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Standalone popup / iframe pages (customer contacts, etc.) */
body.mc-standalone {
    margin: 0;
}

body.mc-standalone .cc-shell {
    padding: 12px 14px max(20px, env(safe-area-inset-bottom, 0px));
    max-width: 100%;
    box-sizing: border-box;
}

body.mc-standalone .cc-header {
    flex-direction: column;
    align-items: flex-start;
}

body.mc-standalone .btn,
body.mc-standalone button {
    min-height: 40px;
}

body.mc-standalone .table-responsive {
    -webkit-overflow-scrolling: touch;
}
