/* Responsive Styles - Mobile-First Approach */
/* PayZillion ISO 8583 Card Payments Simulator */

/* ============================================
   BASE MOBILE STYLES (320px+)
   All styles start here and scale up
   ============================================ */

/* Header - Mobile */
.header-container {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-md);
}

.logo {
    font-size: var(--text-xl);
}

.main-content {
    padding: var(--space-md);
}

/* Channel Selector - Mobile */
.channel-selector {
    gap: var(--space-sm);
}

.channel-btn {
    padding: var(--space-sm) var(--space-md);
    min-width: 90px;
}

.channel-icon {
    font-size: var(--text-xl);
}

.channel-label {
    font-size: var(--text-xs);
}

/* ATM - Mobile Base */
.atm-keypad {
    padding: var(--space-sm);
}

.atm-key {
    height: clamp(36px, 8vw, 48px);
    font-size: var(--text-sm);
}

.atm-key.cancel,
.atm-key.clear,
.atm-key.enter {
    font-size: clamp(8px, 2vw, 11px);
}

.atm-slots {
    flex-direction: row;
    gap: var(--space-xs);
}

/* ATM slot buttons — fluid sizing for mobile */
.atm-card-slot,
.atm-cash-dispenser,
.atm-deposit-slot {
    height: clamp(40px, 9vw, 50px);
    font-size: clamp(8px, 2vw, 11px);
}

.softkey {
    display: none;
}

/* ATM display option buttons — mobile-friendly */
.atm-display-options {
    height: auto;
    min-height: clamp(150px, 45vw, 190px);
}

.options-left .option,
.options-right .option {
    height: clamp(22px, 5vw, 28px);
    font-size: clamp(7px, 1.8vw, 10px);
    padding: 1px 4px;
}

/* ATM amount grid — mobile-friendly */
.atm-amount-grid {
    gap: clamp(4px, 1.5vw, 8px);
}

.atm-amount-option {
    padding: clamp(4px, 1.5vw, 8px);
    font-size: clamp(10px, 2.5vw, 14px);
}

/* POS - Mobile Base */
.pos-key {
    height: clamp(34px, 7vw, 44px);
    font-size: var(--text-base);
}

/* POS slot buttons — fluid sizing for mobile */
.pos-chip-slot,
.pos-contactless,
.pos-swipe-slot {
    height: clamp(38px, 8vw, 45px);
    font-size: clamp(8px, 2vw, 11px);
}

/* POS transaction menu buttons — mobile friendly */
.pos-menu-item {
    padding: clamp(4px, 1.2vw, 8px);
    font-size: clamp(9px, 2.2vw, 12px);
}

/* E-Commerce - Mobile Base */
.browser-header {
    flex-wrap: wrap;
}

.browser-url-bar {
    order: 3;
    width: 100%;
    margin-top: var(--space-xs);
}

.browser-content {
    padding: var(--space-md);
    min-height: clamp(280px, 60vh, 400px);
}

.ecom-products,
.products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(3px, 1vw, 8px);
}

.product-image {
    height: var(--product-img-height, 40px);
}

/* eCommerce buttons — mobile friendly sizing */
.add-to-cart-btn {
    padding: clamp(3px, 1vw, 6px);
    font-size: clamp(8px, 2vw, 11px);
}

.checkout-btn {
    padding: clamp(3px, 1vw, 6px);
    font-size: clamp(8px, 2vw, 11px);
}

.pay-btn {
    padding: clamp(6px, 1.5vw, 10px);
    font-size: clamp(10px, 2.5vw, 13px);
}

/* Payment Options - Mobile */
.payment-options-grid {
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}

.wallet-buttons {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.wallet-btn {
    font-size: 0.6rem;
    padding: 6px 4px;
}

.form-row {
    flex-direction: column;
}

.otp-input {
    width: clamp(36px, 10vw, 48px);
    height: clamp(44px, 12vw, 56px);
    font-size: var(--text-lg);
}

/* Transaction Log - Mobile */
.log-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
}

.log-content {
    max-height: 300px;
}

/* Cards Section - Mobile (1 card per row) */
.cards-grid {
    grid-template-columns: 1fr;
}

.card-visual {
    height: auto;
}

.card-number {
    font-size: var(--text-base);
}

/* Help Section - Mobile */
.help-container {
    flex-direction: column;
}

.help-sidebar {
    width: 100%;
    border-inline-end: none;
    border-block-end: 1px solid var(--border-light);
}

.help-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.help-nav li {
    margin-block-end: 0;
}

.help-nav a {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

.help-content {
    padding: var(--space-md);
    overflow-x: hidden;
}

.help-topic-body {
    overflow-wrap: break-word;
    word-break: break-word;
}

.help-section ul,
.help-section ol,
.help-topic-body ul,
.help-topic-body ol {
    padding-left: var(--space-md);
}

.help-section li,
.help-topic-body li {
    font-size: var(--text-sm);
}

.help-section p,
.help-topic-body p {
    font-size: var(--text-sm);
}

.help-table {
    font-size: var(--text-xs);
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.help-table th,
.help-table td {
    padding: var(--space-xs);
    white-space: nowrap;
}

.help-code,
.help-topic-body code {
    font-size: 0.75em;
    word-break: break-all;
}

.help-topic-header {
    gap: var(--space-sm);
}

.help-topic-title {
    font-size: var(--text-lg) !important;
}

/* About Section - Mobile */
.about-hero {
    padding: var(--space-lg);
}

.about-hero .about-logo {
    font-size: var(--text-2xl);
}

.about-tagline {
    font-size: var(--text-base);
}

.social-links {
    flex-direction: column;
    align-items: center;
}

.social-link {
    width: 100%;
    max-width: 200px;
    justify-content: center;
}

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

/* Section Header - Mobile */
.section-header {
    flex-direction: column;
    align-items: flex-start;
}

/* Simulator Control Bar - Mobile handled in main.css @media */

/* Live Transaction Flow - Mobile (above simulator on small screens) */
.simulator-right {
    order: -1; /* Flow diagram above simulator on mobile */
}

.transaction-flow .flow-title {
    font-size: 11px;
}

/* Receipt Modal - Mobile */
.receipt-paper-large {
    min-width: auto;
    width: 90%;
    max-width: 300px;
    font-size: var(--text-xs);
}

/* ============================================
   SMALL DEVICES (576px and up)
   Landscape phones, large phones
   ============================================ */
@media (min-width: 576px) {
    .header-container {
        padding: var(--space-sm) var(--space-lg);
    }
    
    .logo {
        font-size: var(--text-2xl);
    }
    
    .main-content {
        padding: var(--space-lg);
    }
    
    .channel-btn {
        padding: var(--space-md) var(--space-lg);
        min-width: 110px;
    }
    
    .softkey {
        display: flex;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .social-links {
        flex-direction: row;
    }
    
    .section-header {
        flex-direction: row;
        align-items: center;
    }

    /* Reset flow diagram order on larger screens — stays on right side */
    .simulator-right {
        order: unset;
    }

    .simulator-left {
        order: unset;
    }
    
    /* Card selector - handled by sim-control-bar in main.css */
    
    .log-header {
        flex-direction: row;
        align-items: center;
    }
}

/* ============================================
   MEDIUM DEVICES (768px and up)
   Tablets, large landscape phones
   ============================================ */
@media (min-width: 768px) {
    .main-nav {
        display: flex;
    }
    
    .mobile-menu-btn {
        display: none;
    }
    
    .mobile-nav {
        display: none !important;
    }
    
    .help-container {
        flex-direction: row;
    }
    
    .help-sidebar {
        width: 200px;
        border-inline-end: 1px solid var(--border-light);
        border-block-end: none;
    }
    
    .help-nav {
        flex-direction: column;
        flex-wrap: nowrap;
    }
    
    .help-nav a {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-sm);
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        flex-direction: row;
    }
    
    .browser-url-bar {
        order: unset;
        width: auto;
        margin-top: 0;
    }
}

/* ============================================
   LARGE DEVICES (992px and up)
   Small desktops, large tablets
   ============================================ */
@media (min-width: 992px) {
    .header-container {
        padding: var(--space-md) var(--space-xl);
    }
    
    .header-title {
        display: block;
    }
    
    .main-content {
        padding: var(--space-xl);
        max-width: 1200px;
    }
    
    .help-sidebar {
        width: 220px;
    }
    
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   EXTRA LARGE DEVICES (1200px and up)
   Standard desktops
   ============================================ */
@media (min-width: 1200px) {
    .main-content {
        max-width: 1400px;
    }
    
    .help-sidebar {
        width: 250px;
    }
}

/* ============================================
   LAPTOP BREAKPOINT (1400px and up)
   Common laptop resolutions (1366x768, 1440x900)
   ============================================ */
@media (min-width: 1400px) {
    :root {
        --device-atm-width: 420px;
        --device-pos-width: 300px;
        --device-phone-width: 300px;
        --device-phone-height: 580px;
        --product-img-height: 40px;
        --product-emoji-size: 18px;
        --product-title-font: 10px;
        --product-price-font: 11px;
        --product-btn-font: 10px;
        --product-btn-padding: 4px;
    }
    
    .main-content {
        max-width: 1500px;
    }
    
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   ULTRA WIDE (1600px and up)
   Large monitors
   ============================================ */
@media (min-width: 1600px) {
    :root {
        --device-atm-width: 440px;
        --device-pos-width: 320px;
        --device-phone-width: 310px;
        --device-phone-height: 600px;
        --product-img-height: 46px;
        --product-emoji-size: 20px;
        --product-title-font: 10px;
        --product-price-font: 11px;
        --product-btn-font: 10px;
        --product-btn-padding: 5px;
    }
    
    .main-content {
        max-width: 1600px;
    }
    
    .simulator-container {
        min-height: 700px;
    }
}

/* ============================================
   2K DISPLAYS (1920px and up)
   Full HD and QHD monitors
   ============================================ */
@media (min-width: 1920px) {
    :root {
        --device-atm-width: 460px;
        --device-pos-width: 340px;
        --device-ecom-width: 400px;
        --device-phone-width: 320px;
        --device-phone-height: 620px;
        --product-img-height: 52px;
        --product-emoji-size: 22px;
        --product-title-font: 11px;
        --product-price-font: 12px;
        --product-btn-font: 11px;
        --product-btn-padding: 5px;
    }
    
    .main-content {
        max-width: 1800px;
    }
    
    /* Side-by-side layout for ultra-wide */
    .simulator-wrapper {
        gap: var(--space-2xl);
    }
}

/* ============================================
   4K DISPLAYS (2560px and up)
   4K monitors and large displays
   ============================================ */
@media (min-width: 2560px) {
    :root {
        --device-atm-width: 500px;
        --device-pos-width: 380px;
        --device-ecom-width: 420px;
        --device-phone-width: 330px;
        --device-phone-height: 640px;
        --product-img-height: 58px;
        --product-emoji-size: 24px;
        --product-title-font: 12px;
        --product-price-font: 13px;
        --product-btn-font: 11px;
        --product-btn-padding: 6px;
    }
    
    .main-content {
        max-width: 2200px;
    }
    
    .header-container {
        max-width: 2400px;
    }
    
    /* Larger ISO log for 4K */
    .iso-message-log-container {
        max-width: 1200px;
    }
}

/* ============================================
   5K+ DISPLAYS (3840px and up)
   Ultra-high resolution displays
   ============================================ */
@media (min-width: 3840px) {
    :root {
        --device-atm-width: 600px;
        --device-pos-width: 440px;
        --device-ecom-width: 500px;
        --device-phone-width: 340px;
        --device-phone-height: 660px;
        --product-img-height: 64px;
        --product-emoji-size: 26px;
        --product-title-font: 13px;
        --product-price-font: 14px;
        --product-btn-font: 12px;
        --product-btn-padding: 7px;
    }
    
    .main-content {
        max-width: 3000px;
    }
    
    .header-container {
        max-width: 3200px;
    }
}

/* ============================================
   HiDPI / RETINA DISPLAYS
   High pixel density screens
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    /* Sharper borders on Retina */
    .atm-screen,
    .pos-screen,
    .phone-screen {
        border-width: 0.5px;
    }
    
    /* Thinner lines for high-DPI */
    .flow-arrow .arrow-line {
        width: 2px;
    }
}

/* 4K laptop scaling (usually 150-200% zoom) */
@media (-webkit-min-device-pixel-ratio: 1.5) and (max-width: 1920px) {
    :root {
        /* Slightly larger touch targets for scaled displays */
        --device-atm-width: clamp(340px, 45vw, 420px);
        --device-pos-width: clamp(260px, 35vw, 320px);
    }
}

/* ============================================
   HEIGHT CONSIDERATIONS
   Short viewports (laptops, landscape phones)
   ============================================ */
@media (max-height: 700px) {
    .simulator-container {
        min-height: 500px;
    }
}

@media (max-height: 600px) {
    .onboarding-overlay .onboarding-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION
   Phones and tablets in landscape
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .simulator-container {
        min-height: 400px;
    }
    
    .simulator-wrapper {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .transaction-flow {
        padding: var(--space-sm);
    }
    
    /* Compact flow diagram in landscape */
    .flow-diagram {
        gap: 2px;
    }
    
    .flow-node {
        padding: var(--space-xs) var(--space-sm);
    }
    
    .node-label {
        font-size: 9px;
    }
}

/* ============================================
   ASPECT RATIO QUERIES
   Ultra-wide and tall screens
   ============================================ */

/* Ultra-wide monitors (21:9 and wider) */
@media (min-aspect-ratio: 21/9) and (min-width: 1200px) {
    .simulator-wrapper {
        gap: var(--space-2xl);
    }
    
    .main-content {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: var(--space-xl);
    }
    
    /* Better use of horizontal space */
    .iso-message-log-container {
        max-width: none;
    }
}

/* Tall mobile screens (9:16 and taller) */
@media (max-aspect-ratio: 9/16) {
    /* Products grid stays 2-column for consistency */
}

/* Square-ish tablets - keep side by side */
@media (min-aspect-ratio: 3/4) and (max-aspect-ratio: 4/3) {
    .simulator-wrapper {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .simulator-right {
        flex: 0 0 clamp(100px, 15vw, 160px);
        max-width: 160px;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   Phones and tablets with touch screens
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Minimum 44px touch targets (WCAG) */
    .atm-key,
    .pos-key {
        min-height: 44px;
    }
    
    .nav-btn,
    .nav-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    .channel-btn {
        min-height: 60px;
    }
    
    .help-nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Remove hover effects on touch */
    .atm-key:hover,
    .pos-key:hover,
    .channel-btn:hover,
    .nav-btn:hover {
        background: inherit;
        transform: none;
    }
    
    /* Add active state feedback */
    .atm-key:active,
    .pos-key:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    /* Larger scrollbar for touch */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
}

/* Fine pointer (mouse) optimizations */
@media (hover: hover) and (pointer: fine) {
    .atm-key:hover,
    .pos-key:hover {
        transform: translateY(-1px);
    }
}

/* ============================================
   PRINT STYLES
   Printing transactions and documentation
   ============================================ */
@media print {
    /* Hide interactive elements */
    .main-header,
    .mobile-nav,
    .sim-control-bar,
    .channel-selector,
    .network-simulation-toggle,
    .simulator-container,
    .transaction-flow,
    .iso-message-log,
    .main-footer,
    .back-to-top,
    .toast-container,
    .onboarding-overlay {
        display: none !important;
    }
    
    /* Show all sections for printing */
    .section {
        display: block !important;
        page-break-inside: avoid;
    }
    
    /* Optimize table for print */
    .transactions-table {
        font-size: 10px;
    }
    
    .transactions-table th,
    .transactions-table td {
        padding: 4px;
        border: 1px solid #000;
    }
    
    .export-buttons {
        display: none;
    }
    
    /* Force black text for printing */
    body {
        color: #000 !important;
        background: #fff !important;
    }
    
    a {
        color: #000 !important;
        text-decoration: underline;
    }
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST MODE
   Windows High Contrast and forced colors
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-muted: #333;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
        --shadow-xl: none;
    }
    
    .atm-screen,
    .pos-screen,
    .phone-screen {
        border: 2px solid #000;
    }
    
    .channel-btn,
    .nav-btn,
    .atm-key,
    .pos-key {
        border: 2px solid currentColor;
    }
    
    /* Remove gradients */
    .atm-body,
    .pos-body,
    .mobile-phone-frame {
        background: #333;
    }
}

@media (forced-colors: active) {
    .atm-screen,
    .pos-screen {
        border: 2px solid CanvasText;
    }
    
    .channel-btn.active {
        background: Highlight;
        color: HighlightText;
    }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   Users who prefer minimal animation
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .arrow-packet {
        display: none;
    }
}

/* ============================================
   DARK MODE SUPPORT
   Automatic dark mode based on system preference
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        /* Background Colors */
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --bg-tertiary: #0f3460;
        
        /* Text Colors */
        --text-primary: #e8e8e8;
        --text-secondary: #b8b8d0;
        --text-muted: #8888a0;
        
        /* Border Colors */
        --border-color: #3a3a5a;
        --border-light: #2a2a4a;
        
        /* Adjusted Status Colors for dark mode */
        --success-light: rgba(16, 185, 129, 0.2);
        --error-light: rgba(239, 68, 68, 0.2);
        --warning-light: rgba(245, 158, 11, 0.2);
        --info-light: rgba(59, 130, 246, 0.2);
        
        /* Shadow adjustments */
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
    }
    
    /* Adjust specific components for dark mode */
    .main-header {
        background: var(--bg-primary);
        border-color: var(--border-color);
    }
    
    .channel-btn,
    .nav-btn {
        background: var(--bg-tertiary);
        border-color: var(--border-color);
    }
    
    .channel-btn:hover,
    .nav-btn:hover {
        background: var(--bg-secondary);
    }
    
    /* POS screen stays light for readability */
    .pos-screen {
        background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
        color: #1a1a2e;
    }
    
    /* E-commerce phone screen */
    .phone-screen {
        background: #1a1a2e;
    }
    
    .phone-screen .product-card,
    .phone-screen .cart-item,
    .phone-screen .checkout-section {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }
    
    /* Transaction table */
    .transactions-table {
        background: var(--bg-primary);
    }
    
    .transactions-table th {
        background: var(--bg-tertiary);
    }
    
    .transactions-table tr:nth-child(even) {
        background: var(--bg-secondary);
    }
    
    /* ISO Log */
    .iso-message-log {
        background: var(--bg-primary);
    }
    
    .log-content {
        background: #0a0a18;
    }
    
    /* Cards */
    .card-item {
        background: var(--bg-primary);
    }
    
    /* Help section */
    .help-content {
        background: var(--bg-primary);
    }
    
    /* Modal backgrounds */
    .modal-content,
    .onboarding-content,
    .confirm-dialog {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
    }
    
    /* Toast notifications */
    .toast {
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
    }
    
    /* Flow diagram */
    .flow-node {
        background: var(--bg-tertiary);
    }
    
    .transaction-flow {
        background: var(--bg-primary);
    }
}

/* ============================================
   FOLDABLE DEVICE SUPPORT
   Samsung Galaxy Fold, Surface Duo, etc.
   ============================================ */

/* Spanning across fold - show both screens */
@media (horizontal-viewport-segments: 2) {
    .simulator-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: env(viewport-segment-inline-gap);
    }
    
    .simulator-left {
        grid-column: 1;
    }
    
    .simulator-right {
        grid-column: 2;
    }
}

@media (vertical-viewport-segments: 2) {
    .main-content {
        display: grid;
        grid-template-rows: 1fr 1fr;
        gap: env(viewport-segment-block-gap);
    }
}

/* ============================================
   CONTAINER QUERIES
   Component-level responsiveness
   ============================================ */

/* ATM container queries */
@container atm-device (max-width: 350px) {
    .atm-screen {
        height: 240px;
        font-size: 11px;
    }
    
    .atm-key {
        height: 34px;
        font-size: 13px;
    }
}

@container atm-device (min-width: 420px) {
    .atm-screen {
        height: 300px;
    }
    
    .atm-key {
        height: 48px;
    }
}

/* POS container queries */
@container pos-device (max-width: 260px) {
    .pos-screen {
        height: clamp(140px, 28vw, 180px);
    }
    
    .pos-key {
        height: 32px;
        font-size: 14px;
    }
}

@container pos-device (min-width: 320px) {
    .pos-screen {
        height: clamp(180px, 32vw, 220px);
    }
    
    .pos-key {
        height: 44px;
    }
}

/* E-commerce container queries */
@container ecom-device (max-width: 300px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-image {
        height: 80px;
    }
}

@container ecom-device (min-width: 360px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   CSS LOGICAL PROPERTIES
   RTL language support
   ============================================ */

/* Use logical properties for spacing */
.header-container {
    padding-inline: var(--space-xl);
    padding-block: var(--space-md);
}

.main-content {
    padding-inline: var(--space-xl);
    padding-block: var(--space-xl);
    margin-inline: auto;
}

.help-sidebar {
    border-inline-end: 1px solid var(--border-light);
}

.log-field-name {
    margin-inline-end: var(--space-md);
}

.nav-item,
.nav-btn {
    margin-inline-start: var(--space-sm);
}

/* RTL-specific adjustments */
[dir="rtl"] .mobile-menu-btn {
    margin-inline-start: auto;
    margin-inline-end: 0;
}

[dir="rtl"] .flow-arrow {
    transform: scaleX(-1);
}

/* ============================================
   UTILITY CLASSES
   Responsive visibility helpers
   ============================================ */

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

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

/* Hide on desktop */
@media (min-width: 768px) {
    .hide-desktop {
        display: none;
    }
}

/* Hide on touch devices */
@media (hover: none) {
    .hide-touch {
        display: none;
    }
}

/* Show only on touch devices */
@media (hover: hover) {
    .show-touch-only {
        display: none;
    }
}

/* ============================================
   CMS — Card Management Responsive
   Mobile-first: list↔detail view navigation
   ============================================ */

/* ── Mobile (< 768px) ── */
@media (max-width: 767px) {
    /* Header compact */
    .cms-header { padding: 12px 16px; }
    .cms-title { font-size: 16px; }

    /* Dashboard: 2x2 compact grid */
    .cms-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px 12px;
    }
    .cms-stat-card { padding: 10px 12px; gap: 8px; }
    .cms-stat-icon { width: 32px; height: 32px; font-size: 14px; }
    .cms-stat-value { font-size: 14px; }
    .cms-stat-label { font-size: 9px; }

    /* Full-screen toggle between list and detail */
    .cms-content {
        grid-template-columns: 1fr;
        min-height: auto;
        position: relative;
        overflow-x: hidden;
    }

    /* Card list takes full width */
    .cms-card-list {
        border-right: none;
        max-height: none;
    }
    .cms-list-header { padding: 10px 14px; }

    /* Show arrow indicator on mobile */
    .cms-list-item-arrow { display: flex; }

    /* Detail panel hidden by default on mobile */
    .cms-detail-panel {
        display: none;
        min-height: auto;
        overflow-x: hidden;
    }

    /* When detail is active on mobile */
    .cms-content.detail-active .cms-card-list { display: none; }
    .cms-content.detail-active .cms-detail-panel { display: flex; }

    /* Show back button on mobile */
    .cms-back-btn { display: flex; }

    /* Card header: stack vertically, card visual centered */
    .cms-card-header {
        flex-direction: column;
        align-items: center;
        gap: 14px;
        padding: 16px;
        overflow: hidden;
    }
    .cms-card-visual-wrap {
        width: 100%;
        max-width: 280px;
    }
    .cms-card-visual-wrap .card-visual { max-width: 100%; }
    .cms-card-visual-wrap .card-number {
        font-size: 13px;
        letter-spacing: 1.5px;
    }
    .cms-card-visual-wrap .card-holder { font-size: 10px; }
    .cms-card-visual-wrap .card-expiry-value { font-size: 11px; }
    .cms-card-visual-wrap .card-chip {
        width: 32px;
        height: 24px;
        top: 28%;
    }
    .cms-card-summary { align-items: center; text-align: center; width: 100%; }
    .cms-card-title-row { justify-content: center; }
    .cms-card-meta { grid-template-columns: repeat(2, 1fr); gap: 6px; width: 100%; }
    .cms-meta-item { align-items: center; text-align: center; }
    .cms-card-actions-bar { justify-content: center; }

    /* Tabs: horizontal scroll, compact */
    .cms-tabs { padding: 0 12px; }
    .cms-tab { padding: 9px 10px; font-size: 10px; letter-spacing: 0.3px; }

    /* Tab panels compact */
    .cms-tab-panel { padding: 12px 14px; }

    /* Data grids single column on mobile */
    .cms-data-grid { grid-template-columns: 1fr; gap: 8px; }
    .cms-data-grid.cols-3 { grid-template-columns: 1fr; }

    /* Toggle desc hidden on small screens to save space */
    .cms-toggle-desc { display: none; }
}

/* ── Small phones (< 420px) ── */
@media (max-width: 419px) {
    .cms-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 8px 10px;
    }
    .cms-stat-card { padding: 8px 10px; }
    .cms-stat-icon { width: 28px; height: 28px; font-size: 12px; }
    .cms-stat-value { font-size: 12px; }

    .cms-card-visual-wrap { max-width: 240px; }
    .cms-card-visual-wrap .card-number {
        font-size: 11px;
        letter-spacing: 1px;
    }
    .cms-card-visual-wrap .card-holder { font-size: 9px; }
    .cms-card-visual-wrap .card-chip {
        width: 28px;
        height: 20px;
        top: 28%;
    }
    .cms-card-meta { grid-template-columns: 1fr 1fr; }

    .cms-list-item-credit-info { flex-direction: column; gap: 2px; }
}

/* ── Tablets (768–991px) ── */
@media (min-width: 768px) and (max-width: 991px) {
    .cms-content { grid-template-columns: 260px 1fr; }
    .cms-card-header { gap: 16px; padding: 16px; }
    .cms-card-visual-wrap { width: 240px; }
    .cms-card-visual-wrap .card-visual { max-width: 240px; }
    .cms-card-visual-wrap .card-number {
        font-size: 13px;
        letter-spacing: 1.5px;
        white-space: nowrap;
    }
    .cms-card-visual-wrap .card-holder { font-size: 10px; }
    .cms-card-visual-wrap .card-expiry-value { font-size: 11px; }
    .cms-card-visual-wrap .card-chip {
        width: 30px;
        height: 22px;
        top: 28%;
    }
    .cms-card-meta { grid-template-columns: 1fr 1fr; }
    .cms-data-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Desktop (992px+) ── */
@media (min-width: 992px) {
    .cms-content { grid-template-columns: 320px 1fr; }
}

/* ── Large desktop (1200px+) ── */
@media (min-width: 1200px) {
    .cms-content { grid-template-columns: 340px 1fr; }
}
