/**
 * KYC System - Unified Responsive CSS
 * Mobile-first responsive design for Agent, Admin, and Reports portals
 * Optimized for mobile phones, tablets, and desktop screens
 */

/* =============================================================================
   MOBILE-FIRST BASE STYLES (Applied to all screens)
   ============================================================================= */

/* Ensure body allows proper scrolling on mobile */
body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Container adjustments for mobile */
.wrap {
    max-width: 100%;
    padding: 12px;
}

/* Improved touch targets for mobile (minimum 44x44px) */
.btn,
.nav a,
.subnav a,
button,
select,
input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
}

/* =============================================================================
   NAVIGATION - MOBILE HAMBURGER MENU
   ============================================================================= */

/* Mobile menu toggle button (hidden on desktop) */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* =============================================================================
   TABLE RESPONSIVE STRATEGIES
   ============================================================================= */

/* Strategy 1: Horizontal scroll wrapper for tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
}

.table-responsive table {
    min-width: 600px; /* Ensure table doesn't collapse too much */
}

/* Strategy 2: Card-based layout for critical tables on mobile */
@media (max-width: 768px) {
    .table-card-mobile {
        display: none; /* Hide original table */
    }

    .table-card-mobile + .mobile-card-list {
        display: block;
    }

    .mobile-card-list {
        display: none; /* Hidden on desktop */
    }

    .mobile-card-item {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid rgba(35, 48, 79, 0.3);
    }

    .mobile-card-row:last-child {
        border-bottom: none;
    }

    .mobile-card-label {
        font-size: 11px;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-weight: 600;
    }

    .mobile-card-value {
        font-size: 13px;
        color: var(--text);
        text-align: right;
    }
}

/* =============================================================================
   MOBILE BREAKPOINT (< 768px) - Phones
   ============================================================================= */

@media (max-width: 768px) {

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }

    /* Topbar adjustments */
    .topbar {
        padding-right: 60px; /* Space for menu toggle */
        margin-bottom: 12px;
    }

    .brand {
        gap: 8px;
    }

    .logo {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .brand-text h1 {
        font-size: 15px;
    }

    .brand-text p {
        display: none; /* Hide subtitle on mobile */
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .pill {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* Navigation - Mobile responsive */
    .nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background: var(--card);
        border-right: 1px solid var(--line);
        flex-direction: column;
        padding: 80px 16px 16px;
        gap: 4px;
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .nav.mobile-open {
        left: 0;
    }

    .nav a {
        width: 100%;
        justify-content: flex-start;
        padding: 14px 16px;
        font-size: 14px;
    }

    /* Subnav mobile */
    .subnav {
        flex-wrap: wrap;
        gap: 4px;
    }

    .subnav a {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* Mobile overlay when menu is open */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 998;
    }

    .mobile-overlay.show {
        display: block;
    }

    /* Card adjustments */
    .card {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .card h2 {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .card h3 {
        font-size: 13px;
    }

    /* Grid layouts - stack on mobile */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kpis {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .kpi {
        padding: 12px;
    }

    .kpi .label {
        font-size: 10px;
    }

    .kpi .val {
        font-size: 18px;
        margin-top: 4px;
    }

    .kpi .sub {
        font-size: 10px;
    }

    /* Form elements - Better touch targets */
    label {
        font-size: 11px;
        margin: 10px 0 5px;
    }

    input,
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    /* PIN boxes - Responsive sizing */
    .pin-boxes {
        gap: 8px;
        margin: 20px 0;
    }

    .pin-box {
        width: calc((100% - 24px) / 4); /* Fit 4 boxes with gaps */
        max-width: 65px;
        height: 60px;
        font-size: 24px;
    }

    /* Zeus PIN boxes */
    .zeus-pin-box {
        width: calc((100% - 24px) / 4);
        max-width: 55px;
        height: 50px;
        font-size: 20px;
    }

    /* Tables - Horizontal scroll */
    table {
        font-size: 12px;
    }

    th,
    td {
        padding: 8px 6px;
        font-size: 11px;
    }

    th {
        font-size: 10px;
    }

    /* Buttons */
    .btn {
        font-size: 12px;
        padding: 10px 14px;
    }

    .btn.sm {
        padding: 8px 12px;
        font-size: 11px;
    }

    .actions {
        gap: 8px;
        margin-top: 12px;
    }

    /* Split layout - Stack on mobile */
    .split {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Filters - Stack on mobile */
    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .filters input,
    .filters select {
        width: 100%;
    }

    .filter-selects {
        flex-direction: column;
        gap: 8px;
    }

    .filter-selects select {
        width: 100%;
        min-width: unset;
    }

    /* Filter tabs */
    .filter-tabs {
        flex-direction: column;
        gap: 4px;
    }

    .filter-tab {
        padding: 12px 14px;
        font-size: 12px;
    }

    /* Pagination */
    .pagination-wrap {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }

    .page-btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    .pagination-info,
    .page-size {
        justify-content: center;
        text-align: center;
    }

    /* Date range popup */
    .date-range-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        width: calc(100% - 32px);
        max-width: 320px;
    }

    /* Modals - Full screen on mobile */
    .modal,
    .note-modal-content {
        max-width: calc(100% - 32px);
        width: 100%;
    }

    /* KYC Header - Stack layout */
    .kyc-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .kyc-left,
    .kyc-center,
    .kyc-right {
        width: 100%;
        text-align: left;
        min-width: unset;
    }

    .kyc-center {
        text-align: left;
    }

    .kyc-right {
        text-align: left;
    }

    .kyc-customer {
        font-size: 16px;
    }

    .kyc-amount {
        font-size: 20px;
    }

    /* KYC Document card */
    .kyc-doc-inner {
        flex-direction: column;
        gap: 10px;
    }

    .kyc-doc-thumb {
        width: 100%;
        height: 200px;
    }

    /* Autocomplete list */
    .autocomplete-list {
        max-height: 150px;
    }

    .autocomplete-item {
        padding: 10px;
        font-size: 12px;
    }

    /* Dashboard header */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

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

    /* Month navigation */
    .month-nav h2 {
        font-size: 14px;
    }

    /* Company card */
    .company-card {
        padding: 12px;
    }

    .company-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Topbar dropdown */
    .topbar-dropdown-menu {
        right: 0;
        min-width: 160px;
    }

    /* Doc preview */
    .doc-preview-item {
        flex-direction: column;
        gap: 10px;
    }

    .doc-preview-thumb {
        width: 100%;
        height: 150px;
    }

    /* KYC replace form */
    .kyc-replace-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .kyc-replace-inner select,
    .kyc-file-wrap {
        width: 100%;
        min-width: unset;
    }

    /* Date wrap adjustments */
    .date-wrap input[type="date"] {
        padding-right: 12px;
    }

    /* Empty states */
    .empty {
        padding: 20px;
        font-size: 12px;
    }
}

/* =============================================================================
   TABLET BREAKPOINT (768px - 1024px) - iPads
   ============================================================================= */

@media (min-width: 768px) and (max-width: 1024px) {

    .wrap {
        max-width: 100%;
        padding: 16px;
    }

    /* Adjust grid for tablets */
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tables - Slightly reduce font */
    th,
    td {
        font-size: 12px;
        padding: 9px 7px;
    }

    /* Navigation - Wrap if needed */
    .nav {
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav a {
        font-size: 12px;
        padding: 10px 12px;
    }

    /* Cards */
    .card {
        padding: 18px;
    }

    /* PIN boxes - Medium size */
    .pin-box {
        width: 60px;
        height: 70px;
        font-size: 28px;
    }

    /* Filters - Better tablet layout */
    .filter-selects {
        gap: 8px;
    }

    .filter-selects select {
        min-width: 120px;
    }

    /* KYC document inner */
    .kyc-doc-inner {
        gap: 12px;
    }

    .kyc-doc-thumb {
        width: 120px;
        height: 120px;
    }
}

/* =============================================================================
   LARGE DESKTOP (> 1024px) - Optimal viewing
   ============================================================================= */

@media (min-width: 1024px) {

    .wrap {
        max-width: 1200px;
        padding: 20px;
    }

    /* Ensure mobile menu elements are hidden */
    .mobile-menu-toggle,
    .mobile-overlay {
        display: none !important;
    }

    /* Tables - Full size */
    table {
        font-size: 13px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 13px;
    }
}

/* =============================================================================
   EXTRA LARGE SCREENS (> 1400px)
   ============================================================================= */

@media (min-width: 1400px) {

    .wrap {
        max-width: 1400px;
    }

    /* Slightly larger fonts for better readability */
    body {
        font-size: 15px;
    }

    .card h2 {
        font-size: 17px;
    }

    th,
    td {
        font-size: 14px;
        padding: 11px 10px;
    }
}

/* =============================================================================
   LANDSCAPE ORIENTATION FIXES (Mobile landscape)
   ============================================================================= */

@media (max-height: 500px) and (orientation: landscape) {

    /* Reduce vertical spacing in landscape */
    .card {
        padding: 12px;
        margin-bottom: 10px;
    }

    .pin-boxes {
        margin: 12px 0;
    }

    .pin-box {
        height: 50px;
    }

    .kpis {
        grid-template-columns: repeat(4, 1fr);
    }

    .kpi {
        padding: 10px;
    }

    .kpi .val {
        font-size: 16px;
    }

    /* Modals take less vertical space */
    .modal-overlay,
    .note-modal {
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }

    .nav {
        padding-top: 60px;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {

    /* Hide interactive elements */
    .btn,
    .nav,
    .subnav,
    .topbar .user-info,
    .mobile-menu-toggle,
    .actions,
    .pagination,
    .filters {
        display: none !important;
    }

    /* Optimize for printing */
    body {
        background: white;
        color: black;
    }

    .wrap {
        max-width: 100%;
        padding: 0;
    }

    .card {
        border: 1px solid #ddd;
        page-break-inside: avoid;
        box-shadow: none;
        background: white;
    }

    table {
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* Use black text for print */
    * {
        color: black !important;
    }
}

/* =============================================================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================================================= */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
    .btn,
    .nav a,
    .card {
        border-width: 2px;
    }

    input,
    select,
    textarea {
        border-width: 2px;
    }
}

/* =============================================================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================================================= */

@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .nav a,
    .subnav a,
    button,
    select,
    input[type="submit"] {
        min-height: 48px;
        min-width: 48px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav a:hover,
    .subnav a:hover {
        transform: none;
    }

    /* Better tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(94, 234, 212, 0.2);
    }
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Hide on mobile */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

/* Show only on mobile */
.show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .show-mobile {
        display: none;
    }
}

/* Hide on tablet */
.hide-tablet {
    display: block;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .hide-tablet {
        display: none;
    }
}

/* Show only on tablet */
.show-tablet {
    display: none;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .show-tablet {
        display: block;
    }
}

/* Responsive text alignment */
.text-center-mobile {
    text-align: left;
}

@media (max-width: 768px) {
    .text-center-mobile {
        text-align: center;
    }
}

/* Responsive spacing */
.gap-mobile {
    gap: 8px;
}

@media (min-width: 768px) {
    .gap-mobile {
        gap: 12px;
    }
}
