/**
 * Mobile Responsive Styles
 * Binance-like mobile experience for ArbiMax
 * RTL-safe, neon-purple brand colors
 */

/* ============================================================
   SPLASH SCREEN - Smooth fade-out transition
   ============================================================ */
#splash-screen {
    transition: opacity 300ms ease;
}

#splash-screen.is-hidden {
    opacity: 0;
    pointer-events: none;
}

/* HARD LOCK: Hide splash when boot completes */
html.booted #splash-screen,
body.booted #splash-screen,
html.boot-complete #splash-screen,
body.boot-complete #splash-screen {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================================
   AUTH-PUBLIC HARD GATING
   Hide any protected UI when user is not authenticated
   ============================================================ */
html.auth-public body,
body.auth-public {
    background: #0c0c12;
    overflow: hidden !important;
}

html.auth-public #body-wrapper,
html.auth-public #arbimax-sidebar,
html.auth-public .sidebar,
html.auth-public nav,
html.auth-public .tabs,
html.auth-public .tab-container,
html.auth-public .dashboard,
html.auth-public #dashboard,
html.auth-public #main-content,
html.auth-public .dashboard-shell,
html.auth-public .layout-shell,
html.auth-public .topbar,
html.auth-public .navbar,
html.auth-public header.top {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ensure auth containers remain visible and centered */
html.auth-public #app,
html.auth-public [data-app-root],
html.auth-public .auth-shell {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

html.auth-public #app {
    min-height: 100vh;
    padding: var(--am-space-6) var(--am-space-3);
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Media: Tablet & Small Screens (900px and below) */
@media (max-width: 900px) {
    /* Collapse sidebar */
    #arbimax-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 70px;
        width: 260px !important;
        z-index: 1000;
        transition: transform 0.3s ease;
        transform: translateX(-100%);
    }

    #arbimax-sidebar.open {
        transform: translateX(0);
    }

    /* Sidebar overlay */
    #sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 70px;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    #sidebar-overlay.open {
        display: block;
    }

    /* Main content adjusts for bottom nav */
    #main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        padding-bottom: 80px !important;
    }

    /* Hide collapse button, show hamburger */
    #collapseBtn {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1001;
    }

    /* Cards more compact */
    .card {
        margin-bottom: var(--am-list-gap) !important;
        padding: var(--am-space-4) !important;
    }

    .card-header {
        padding: var(--am-space-3) 0 !important;
    }

    .card-header h2,
    .card-header h3 {
        font-size: 14px !important;
    }

    /* Modals become full-screen-like on mobile */
    .modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 70px !important;
        width: 100% !important;
        height: auto !important;
        max-height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    .modal-content {
        flex: 1;
        overflow-y: auto;
        padding: var(--am-space-4);
    }

    .modal-footer {
        display: flex;
        gap: var(--am-space-2);
        padding: var(--am-space-4);
        border-top: 1px solid var(--border-subtle);
        background: rgba(0, 0, 0, 0.3);
        position: sticky;
        bottom: 0;
    }

    .modal-footer .btn {
        flex: 1;
    }

    /* Tables scroll horizontally */
    .data-table {
        font-size: 12px !important;
    }

    .data-table th,
    .data-table td {
        padding: 8px 4px !important;
    }

    /* Grid adjusts */
    .metric-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Tabs horizontal scroll instead of wrap */
    div[style*="display:flex"] {
        flex-wrap: wrap;
    }

    /* Buttons get more padding for touch */
    .btn {
        padding: 10px 16px !important;
        min-height: 44px !important;
        font-size: 13px !important;
    }

    /* Inputs bigger for touch */
    input,
    textarea,
    select {
        font-size: 16px !important;
        padding: 12px !important;
        min-height: 44px !important;
    }

    /* Header more compact */
    h1 {
        font-size: 24px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    h3 {
        font-size: 16px !important;
    }

    /* RTL support */
    [dir="rtl"] #main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    [dir="rtl"] #collapseBtn {
        left: auto;
        right: 20px;
    }

    [dir="rtl"] #arbimax-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    [dir="rtl"] #arbimax-sidebar.open {
        transform: translateX(0);
    }
}

/* Media: Mobile Phones (600px and below) */
@media (max-width: 600px) {
    /* Root font size */
    :root {
        font-size: 13px;
    }

    /* Hide desktop header if present */
    .desktop-header {
        display: none;
    }

    /* Card padding minimal */
    .card {
        margin-bottom: 8px !important;
        padding: 12px !important;
        border-radius: 8px !important;
    }

    /* Buttons fill width */
    .btn {
        width: 100%;
        padding: 12px 16px !important;
        min-height: 48px !important;
    }

    .btn-group,
    div[style*="display:flex"] [style*="flex:1"] {
        flex: 1;
    }

    /* Forms stack vertically */
    form div {
        display: block !important;
    }

    form input,
    form select,
    form textarea {
        width: 100% !important;
        margin-bottom: 12px !important;
    }

    /* Table becomes list on very small screens */
    .data-table {
        display: block !important;
        overflow-x: auto !important;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 12px;
        border: 1px solid var(--border-subtle);
        border-radius: 4px;
        overflow: hidden;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px !important;
        border-bottom: 1px solid var(--border-subtle);
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 8px;
        color: var(--text-secondary);
        min-width: 100px;
    }

    /* Sidebar much narrower */
    #arbimax-sidebar {
        width: 200px !important;
    }

    /* Modals full viewport */
    .modal {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    .modal-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Close button more accessible */
    .modal-close-btn {
        font-size: 24px !important;
        padding: 8px 12px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }

    /* Text sizes */
    body {
        font-size: 13px;
    }

    h1 {
        font-size: 20px !important;
    }

    h2 {
        font-size: 16px !important;
    }

    h3 {
        font-size: 14px !important;
    }

    small {
        font-size: 11px !important;
    }

    /* Grid single column */
    .metric-grid {
        grid-template-columns: 1fr !important;
    }

    /* Status pills inline */
    .pill {
        font-size: 10px !important;
        padding: 4px 8px !important;
    }

    /* Spacing reduction */
    .card > *:first-child {
        margin-top: 0 !important;
    }

    .card > *:last-child {
        margin-bottom: 0 !important;
    }

    /* Bottom nav always visible */
    #mobile-bottom-nav {
        display: flex !important;
        height: 70px;
    }

    #main-content {
        padding-bottom: 80px !important;
    }

    /* More menu narrower */
    #mobile-more-menu {
        right: 0 !important;
        left: auto !important;
        min-width: 120px !important;
    }

    /* RTL on mobile */
    [dir="rtl"] {
        text-align: right;
        direction: rtl;
    }

    [dir="rtl"] #mobile-more-menu {
        right: auto !important;
        left: 10px !important;
    }

    [dir="rtl"] .modal-footer {
        flex-direction: column-reverse;
    }

    [dir="rtl"] input,
    [dir="rtl"] textarea,
    [dir="rtl"] select {
        text-align: right;
    }
}

/* Landscape mode (height-aware) */
@media (max-width: 900px) and (max-height: 600px) {
    #arbimax-sidebar {
        bottom: 0;
    }

    #main-content {
        padding-bottom: 0 !important;
    }

    #mobile-bottom-nav {
        display: none !important;
    }

    .modal {
        bottom: 0 !important;
    }
}

/* Utility classes for mobile */
.mobile-only {
    display: none;
}

@media (max-width: 900px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}

/* Touch-friendly spacing */
@media (hover: none) and (pointer: coarse) {
    button,
    a,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 16px;
    }

    .btn {
        min-height: 48px !important;
        padding: 12px 16px !important;
    }
}

/* Prevent double tap zoom */
button,
.btn,
input,
textarea,
select,
a {
    touch-action: manipulation;
}
