/* /assets/css/responsive.css */

/* =========================================
   1. UNIVERSAL TOUCH & HARDWARE BASICS
   ========================================= */
html {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    overflow-x: hidden;
}

/* Prevent iOS auto-zoom on inputs */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
    font-size: 16px !important;
}

/* Fluid Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; }

/* Responsive Tables */
.table-container,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius, 8px);
}

/* Mobile Bottom Navigation (Hidden on Desktop) */
.mobile-bottom-nav {
    display: none;
}

/* =========================================
   2. TABLET & DRAWER SIDEBAR (Max Width: 1024px)
   ========================================= */
@media screen and (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        position: fixed;
        top: 0;
        left: 0;
        z-index: 10000;
        width: 270px;
        height: 100vh;
        height: 100dvh;
        box-shadow: none;
    }

    body.sidebar-open .sidebar,
    body.mobile-sidebar-open .sidebar,
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.28);
    }

    body.sidebar-open .sidebar-overlay,
    body.mobile-sidebar-open .sidebar-overlay,
    .sidebar-overlay.active {
        display: block;
    }

    .top-header {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Full-Screen Modals */
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px !important;
    }

    .modal-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }

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

    .btn,
    button,
    .qa-btn {
        min-height: 44px;
    }

    .slip-sticky-preview {
        position: static !important;
    }
}

/* =========================================
   3. MOBILE APP EXPERIENCE (Max Width: 768px)
   ========================================= */
@media screen and (max-width: 768px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Sticky Native-Style App Bar */
    .top-header {
        position: sticky !important;
        top: 0;
        left: 0;
        right: 0;
        height: auto !important;
        min-height: 54px;
        padding: 8px 12px !important;
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px;
        z-index: 999;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
    }

    .top-header > div:first-child {
        max-width: 100% !important;
        width: 100%;
        gap: 8px !important;
    }

    .sidebar-toggle {
        min-width: 40px;
        min-height: 40px;
        border-radius: 10px;
        background: #f3f9fd;
        border: 1px solid #c7e0f4;
        flex-shrink: 0;
    }

    .global-search-container {
        min-width: 0 !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        flex: 1;
    }

    .global-search-input {
        padding-right: 12px !important;
        height: 40px !important;
        border-radius: 10px !important;
    }

    .hotkey-badge {
        display: none !important;
    }

    .top-meta {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        padding-top: 4px;
        border-top: 1px solid #f1f5f9;
    }

    .top-meta::-webkit-scrollbar {
        display: none;
    }

    .top-meta .firm-select,
    .top-meta .season-select {
        font-size: 13px !important;
        min-height: 36px;
        padding: 4px 8px;
        border-radius: 8px;
    }

    /* Main Content Flow (No overlap with sticky header or bottom nav) */
    .main-content {
        padding-top: 0 !important;
        height: auto !important;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: visible !important;
        padding-bottom: calc(78px + env(safe-area-inset-bottom)) !important;
    }

    .content-inner {
        padding: 12px !important;
    }

    /* App-like Cards & Headers */
    .page-title {
        font-size: 18px !important;
        margin-bottom: 12px !important;
    }

    .flex-between {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .card {
        border-radius: 14px !important;
        margin-bottom: 14px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
    }

    .card-header,
    .card-body {
        padding: 14px !important;
    }

    .card-grid {
        grid-template-columns: 1fr !important;
    }

    /* Compact Table Cells */
    table th,
    table td {
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Tactile Tap Feedback */
    .btn:active,
    button:active,
    .nav-item:active,
    .mobile-bottom-nav-item:active {
        transform: scale(0.97);
    }

    /* Modals */
    .modal-header,
    .modal-footer {
        padding: 14px !important;
    }

    /* Keep Translit Indicator above Bottom Nav */
    #translit-indicator-badge {
        bottom: calc(74px + env(safe-area-inset-bottom)) !important;
        right: 12px !important;
        font-size: 11px !important;
        padding: 6px 10px !important;
    }

    /* Native Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9990;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.07);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: #64748b;
        font-size: 11px;
        font-weight: 700;
        padding: 4px 2px;
        border-radius: 10px;
        position: relative;
        transition: color 0.15s ease, transform 0.12s ease;
    }

    .mobile-bottom-nav-item svg {
        width: 21px;
        height: 21px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-bottom-nav-item.active {
        color: #005A9E;
    }

    .mobile-bottom-nav-item.active::before {
        content: "";
        position: absolute;
        top: -6px;
        width: 28px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: #005A9E;
    }
}

@media screen and (max-width: 520px) {
    .portal-back-btn {
        display: none !important;
    }
}

/* =========================================
   4. SIDEBAR OVERLAY (For Mobile)
   ========================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9999;
    backdrop-filter: blur(2px);
}

@media print {
    .mobile-bottom-nav,
    .sidebar-overlay,
    #translit-indicator-badge {
        display: none !important;
    }
}
