/**
 * Mobile Native UI/UX Styles
 * Transforms web app into native phone app experience
 */

/* ============================================
   VARIABLES - iOS Design Language
   ============================================ */
:root {
    /* iOS System Colors */
    --ios-blue: #007AFF;
    --ios-blue-dark: #0051D5;
    --ios-green: #34C759;
    --ios-indigo: #5856D6;
    --ios-orange: #FF9500;
    --ios-pink: #FF2D55;
    --ios-purple: #AF52DE;
    --ios-red: #FF3B30;
    --ios-teal: #5AC8FA;
    --ios-yellow: #FFCC00;

    /* iOS System Grays */
    --ios-gray: #8E8E93;
    --ios-gray2: #AEAEB2;
    --ios-gray3: #C7C7CC;
    --ios-gray4: #D1D1D6;
    --ios-gray5: #E5E5EA;
    --ios-gray6: #F2F2F7;

    /* Primary colors */
    --primary-color: var(--ios-blue);
    --primary-dark: var(--ios-blue-dark);
    --success-color: var(--ios-green);
    --warning-color: var(--ios-orange);
    --danger-color: var(--ios-red);
    --info-color: var(--ios-teal);

    /* iOS Backgrounds */
    --bg-primary: #FFFFFF;
    --bg-secondary: var(--ios-gray6);  /* System Grouped Background */
    --bg-tertiary: var(--ios-gray5);

    /* iOS Text Colors */
    --text-primary: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);  /* Secondary Label */
    --text-tertiary: rgba(60, 60, 67, 0.3);   /* Tertiary Label */
    --text-muted: var(--ios-gray);

    /* iOS Separators and Borders */
    --separator-color: rgba(60, 60, 67, 0.29);  /* iOS Separator */
    --border-color: var(--separator-color);

    /* iOS Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* iOS Corner Radius */
    --border-radius-sm: 8px;
    --border-radius-md: 10px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* iOS Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-medium: 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);

    /* Safe area insets for iOS notch/home indicator */
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);

    /* Bottom nav height (iOS standard tab bar) */
    --bottom-nav-height: 50px;
}

/* ============================================
   GLOBAL MOBILE STYLES
   ============================================ */
html {
    font-size: 16px; /* Prevent iOS zoom on input focus */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding-bottom: calc(var(--bottom-nav-height) + var(--sab));
    overscroll-behavior-y: contain; /* Prevent pull-to-refresh on iOS Chrome */
}

/* iOS Light Mode Background - Always visible */
@media (max-width: 767px) {
    body {
        background-color: var(--bg-secondary) !important; /* iOS grouped background */
    }

    /* Hide desktop navbar on mobile */
    header nav.navbar {
        display: none;
    }

    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* iOS-style page background for all main content */
    main {
        background-color: var(--bg-secondary) !important;
    }

    /* Ensure all page containers have iOS background */
    .container-fluid,
    main > .container,
    main > .container-fluid {
        background-color: transparent !important;
    }

    /* Override any white backgrounds in page sections */
    .row {
        background-color: transparent;
    }
}

/* ============================================
   BOTTOM NAVIGATION BAR - iOS Tab Bar Style
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--sab));
    background: rgba(255, 255, 255, 0.72);  /* iOS translucent tab bar */
    border-top: 0.5px solid var(--separator-color);  /* Thin iOS separator */
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    z-index: 1000;
    padding-top: 4px;
    padding-bottom: var(--sab);
    box-shadow: 0 -0.5px 0 0 var(--separator-color);
    backdrop-filter: saturate(180%) blur(20px);  /* iOS frosted glass effect */
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

/* Hide on desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }

    body {
        padding-bottom: 60px; /* Reset to original */
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    padding: 2px 0 0 0;
    text-decoration: none;
    color: var(--ios-gray);  /* iOS inactive tab color */
    transition: color var(--transition-fast);
    position: relative;
    min-height: 44px; /* Touch target minimum */
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.bottom-nav-item.active {
    color: var(--ios-blue);  /* iOS active tab color */
}

.bottom-nav-item i {
    font-size: 26px;
    margin-bottom: 2px;
    transition: transform var(--transition-fast);
}

.bottom-nav-item span {
    font-size: 10px;
    font-weight: 400;  /* iOS uses regular weight for tab labels */
    letter-spacing: -0.08px;  /* iOS-style letter spacing */
}

/* Ripple effect on tap */
.bottom-nav-item::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: currentColor;
    opacity: 0;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.3s, opacity 0.5s;
    pointer-events: none;
}

.bottom-nav-item:active::before {
    transform: scale(2);
    opacity: 0.1;
    transition: 0s;
}

.bottom-nav-item:active i {
    transform: scale(0.9);
}

/* Badge for notifications - iOS Style */
.bottom-nav-item .badge {
    position: absolute;
    top: 0;
    right: calc(50% - 22px);
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    background-color: var(--ios-red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.72);  /* Match tab bar background */
}

/* ============================================
   NATIVE-STYLE APP HEADER - iOS Navigation Bar
   ============================================ */
.app-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: calc(44px + var(--sat));  /* iOS standard nav bar height */
    background: rgba(248, 248, 248, 0.94);  /* iOS translucent nav bar */
    border-bottom: 0.5px solid var(--separator-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    padding-top: var(--sat);
    z-index: 999;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.app-header-back {
    position: absolute;
    left: 0;
    top: var(--sat);
    padding: 0 8px;
    height: 44px;
    color: var(--ios-blue);
    font-size: 17px;  /* iOS standard font size */
    font-weight: 400;
    text-decoration: none;
    display: flex;
    align-items: center;
    letter-spacing: -0.41px;  /* iOS letter spacing */
}

.app-header-back:active {
    opacity: 0.3;  /* iOS standard active opacity */
}

.app-header-back i {
    font-size: 22px;
    margin-right: 2px;
}

.app-header-title {
    font-size: 17px;
    font-weight: 600;  /* iOS uses semibold for titles */
    flex: 1;
    text-align: center;
    color: var(--text-primary);
    letter-spacing: -0.41px;
}

.app-header-action {
    position: absolute;
    right: 8px;
    top: var(--sat);
    height: 44px;
    padding: 0 8px;
    color: var(--ios-blue);
    font-size: 17px;
    font-weight: 400;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.41px;
}

.app-header-action:active {
    opacity: 0.3;
}

/* Hide on desktop */
@media (min-width: 768px) {
    .app-header {
        display: none;
    }
}

/* ============================================
   TOUCH TARGET SIZING
   ============================================ */
.btn,
.nav-link,
.list-group-item-action,
a.card,
button,
input[type="submit"],
input[type="button"],
.form-check-input,
.dropdown-toggle {
    min-height: 44px;
    min-width: 44px;
}

/* Large, finger-friendly buttons - iOS Style */
.btn-mobile {
    padding: 11px 16px;
    font-size: 17px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    min-height: 44px;  /* iOS minimum */
    letter-spacing: -0.41px;
    transition: opacity var(--transition-fast);
}

.btn-mobile:active {
    opacity: 0.6;  /* iOS button press feedback */
}

/* Full-width mobile buttons - iOS Style */
.btn-mobile-full {
    width: 100%;
    padding: 13px 16px;
    font-size: 17px;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    letter-spacing: -0.41px;
    transition: opacity var(--transition-fast);
}

.btn-mobile-full:active {
    opacity: 0.6;
}

/* iOS Primary Button */
.btn-primary.btn-mobile-full,
.btn-primary.btn-mobile {
    background-color: var(--ios-blue);
    border-color: var(--ios-blue);
}

/* iOS Outline Buttons */
.btn-outline-primary.btn-mobile-full,
.btn-outline-primary.btn-mobile {
    color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.btn-outline-warning.btn-mobile-full,
.btn-outline-warning.btn-mobile {
    color: var(--ios-orange);
    border-color: var(--ios-orange);
}

.btn-outline-info.btn-mobile-full,
.btn-outline-info.btn-mobile {
    color: var(--ios-teal);
    border-color: var(--ios-teal);
}

.btn-outline-success.btn-mobile-full,
.btn-outline-success.btn-mobile {
    color: var(--ios-green);
    border-color: var(--ios-green);
}

/* iOS Danger/Destructive Button (Logout) */
.btn-danger.btn-mobile-full,
.btn-danger.btn-mobile {
    background-color: var(--ios-red);
    border-color: var(--ios-red);
    color: #FFFFFF;
    font-weight: 600;
}

.btn-danger.btn-mobile-full:hover,
.btn-danger.btn-mobile:hover {
    background-color: #D70015;  /* Darker red on hover */
    border-color: #D70015;
}

.btn-danger.btn-mobile-full:active,
.btn-danger.btn-mobile:active {
    opacity: 0.6;
    background-color: var(--ios-red);
}

/* ============================================
   ACTIVE/PRESS STATES
   ============================================ */
/* iOS-style press feedback */
.card-tap,
.list-group-item-action,
.btn-tap {
    transition: transform var(--transition-fast),
                background-color var(--transition-fast),
                opacity var(--transition-fast);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.card-tap:active,
.list-group-item-action:active,
.btn:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* Material Design ripple effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    pointer-events: none;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Dark ripple for light backgrounds */
.ripple-dark::after {
    background: rgba(0, 0, 0, 0.1);
}

/* Card press effect */
.card.card-tap:active {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ============================================
   MOBILE-OPTIMIZED CARDS - iOS Grouped List Style
   ============================================ */
.card-mobile {
    border-radius: var(--border-radius-md);  /* iOS uses 10px for cards */
    border: none;
    background: var(--bg-primary) !important;  /* Pure white for contrast */
    box-shadow: none;  /* iOS doesn't use shadows on cards in grouped style */
    margin-bottom: 10px;  /* iOS standard spacing */
    overflow: hidden;
}

@media (max-width: 767px) {
    .card-mobile {
        margin-left: 0;
        margin-right: 0;
        border-radius: var(--border-radius-md);
    }

    /* Ensure all cards on mobile have white background for contrast */
    .card,
    .card-mobile {
        background-color: var(--bg-primary) !important;
        color: var(--text-primary);
    }

    /* Card headers should be white too for consistency */
    .card-header,
    .card-mobile .card-header {
        background-color: var(--bg-primary) !important;
    }

    /* Card footers */
    .card-footer,
    .card-mobile .card-footer {
        background-color: var(--bg-primary) !important;
    }
}

.card-mobile:active {
    opacity: 0.9;
}

.card-mobile .card-body {
    padding: 12px 16px;  /* iOS standard padding */
    background-color: var(--bg-primary);
}

.card-mobile .card-header {
    background: var(--bg-primary);
    border: none;
    padding: 16px;
    padding-bottom: 12px;
}

.card-mobile .card-footer {
    background: var(--bg-primary);
    border: none;
    padding: 16px;
    padding-top: 12px;
}

/* ============================================
   MOBILE FORMS - iOS Input Style
   ============================================ */
.form-control-mobile {
    appearance: none;
    -webkit-appearance: none;
    border: 0.5px solid var(--separator-color);  /* iOS thin border */
    background: var(--bg-primary);
    border-radius: var(--border-radius-md);
    padding: 11px 16px;  /* iOS standard padding */
    font-size: 17px; /* iOS standard text size */
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast);
    min-height: 44px;  /* iOS minimum tap target */
    letter-spacing: -0.41px;
}

.form-control-mobile:focus {
    background: var(--bg-primary);
    border-color: var(--ios-blue);
    outline: none;
    box-shadow: none;  /* iOS doesn't use focus shadows */
}

/* iOS-style form group spacing */
.form-group-mobile {
    margin-bottom: 16px;  /* iOS standard spacing */
}

.form-label-mobile {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;  /* iOS section headers are uppercase */
    letter-spacing: -0.08px;
}

/* ============================================
   LIST ITEMS - iOS Grouped List Style
   ============================================ */
.list-mobile {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg-primary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.list-mobile-item {
    padding: 11px 16px;  /* iOS standard list padding */
    border-bottom: 0.5px solid var(--separator-color);  /* iOS thin separator */
    display: flex;
    align-items: center;
    min-height: 44px;
    transition: background-color var(--transition-fast);
}

.list-mobile-item:last-child {
    border-bottom: none;
}

.list-mobile-item:active {
    background-color: var(--ios-gray5);  /* iOS press state */
}

.list-mobile-item-icon {
    width: 28px;
    height: 28px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary-color);
}

.list-mobile-item-content {
    flex: 1;
}

.list-mobile-item-title {
    font-size: 17px;  /* iOS standard text size */
    font-weight: 400;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.41px;
}

.list-mobile-item-subtitle {
    font-size: 15px;  /* iOS standard secondary text */
    color: var(--text-secondary);
    margin: 2px 0 0 0;
    letter-spacing: -0.24px;
}

.list-mobile-item-chevron {
    color: var(--ios-gray3);  /* iOS chevron color */
    font-size: 16px;
}

/* ============================================
   PULL TO REFRESH INDICATOR
   ============================================ */
.refresh-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top var(--transition-medium);
    z-index: 998;
}

.refresh-indicator.active {
    top: 20px;
}

.refresh-indicator i {
    font-size: 24px;
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   SAFE AREA UTILITIES
   ============================================ */
.safe-top {
    padding-top: var(--sat);
}

.safe-bottom {
    padding-bottom: var(--sab);
}

.safe-left {
    padding-left: var(--sal);
}

.safe-right {
    padding-right: var(--sar);
}

/* ============================================
   TOAST NOTIFICATIONS - iOS HUD Style
   ============================================ */
.toast-native {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px + var(--sab));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(58, 58, 60, 0.95);  /* iOS HUD background */
    color: white;
    padding: 13px 24px;
    border-radius: var(--border-radius-lg);
    font-size: 15px;  /* iOS standard */
    font-weight: 400;
    z-index: 10000;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    max-width: calc(100% - 40px);
    text-align: center;
    letter-spacing: -0.24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
}

.toast-native.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   TEXT CONTRAST OPTIMIZATION
   ============================================ */
@media (max-width: 767px) {
    /* Ensure high contrast text on all backgrounds */
    .text-muted {
        color: var(--text-secondary) !important;
    }

    /* Primary text should always be black on light mode */
    h1, h2, h3, h4, h5, h6,
    .card-title,
    .list-mobile-item-title {
        color: var(--text-primary) !important;
    }

    /* Secondary text for subtitles */
    .card-subtitle,
    .text-secondary,
    .list-mobile-item-subtitle {
        color: var(--text-secondary) !important;
    }

    /* Ensure badges have good contrast */
    .badge {
        font-weight: 600;
    }

    .badge.bg-success {
        background-color: var(--ios-green) !important;
        color: #FFFFFF !important;
    }

    .badge.bg-warning {
        background-color: var(--ios-orange) !important;
        color: #FFFFFF !important;
    }

    .badge.bg-danger {
        background-color: var(--ios-red) !important;
        color: #FFFFFF !important;
    }

    .badge.bg-info {
        background-color: var(--ios-teal) !important;
        color: #FFFFFF !important;
    }

    /* Links should be iOS Blue with good contrast */
    a:not(.btn):not(.nav-link):not(.bottom-nav-item) {
        color: var(--ios-blue);
        text-decoration: none;
    }

    a:not(.btn):not(.nav-link):not(.bottom-nav-item):hover {
        opacity: 0.7;
    }

    /* Alerts with proper contrast */
    .alert {
        border-radius: var(--border-radius-md);
        border: none;
        font-weight: 400;
    }

    .alert-success {
        background-color: rgba(52, 199, 89, 0.1) !important;
        color: #1B5E20 !important;  /* Darker green for readability */
    }

    .alert-warning {
        background-color: rgba(255, 149, 0, 0.1) !important;
        color: #E65100 !important;  /* Darker orange for readability */
    }

    .alert-danger {
        background-color: rgba(255, 59, 48, 0.1) !important;
        color: #C62828 !important;  /* Darker red for readability */
    }

    .alert-info {
        background-color: rgba(90, 200, 250, 0.1) !important;
        color: #01579B !important;  /* Darker teal for readability */
    }

    /* Ensure input placeholders are visible but not too dark */
    .form-control::placeholder,
    .form-control-mobile::placeholder {
        color: var(--text-tertiary);
        opacity: 1;
    }

    /* Table text contrast - Enhanced for iOS */
    .table {
        color: var(--text-primary) !important;
        background-color: var(--bg-primary);
    }

    /* Table headers */
    .table thead th {
        color: var(--text-primary) !important;
        background-color: var(--ios-gray6) !important;
        font-weight: 600;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: -0.08px;
        border-bottom: 1px solid var(--separator-color) !important;
        padding: 12px 8px;
    }

    /* Table body - ensure black text on white */
    .table tbody td {
        color: var(--text-primary) !important;
        background-color: var(--bg-primary) !important;
        font-size: 15px;
        padding: 12px 8px;
        border-bottom: 0.5px solid var(--separator-color) !important;
    }

    /* Table striping - subtle iOS style */
    .table-striped tbody tr:nth-of-type(odd) td {
        background-color: rgba(242, 242, 247, 0.3) !important;
    }

    /* Table hover - iOS press style */
    .table-hover tbody tr:hover td {
        background-color: var(--ios-gray5) !important;
    }

    /* Table footer (Totals row) */
    .table tfoot td,
    .table tfoot th {
        color: var(--text-primary) !important;
        background-color: var(--ios-gray6) !important;
        font-weight: 600;
        font-size: 15px;
        padding: 12px 8px;
        border-top: 2px solid var(--separator-color) !important;
    }

    /* Override Bootstrap table-light */
    .table-light {
        background-color: var(--ios-gray6) !important;
        color: var(--text-primary) !important;
    }

    /* Override Bootstrap table-secondary */
    .table-secondary {
        background-color: var(--ios-gray5) !important;
        color: var(--text-primary) !important;
    }

    /* Table responsive wrapper - iOS Safari Fix */
    .table-responsive {
        background-color: var(--bg-primary);
        border-radius: var(--border-radius-md);
        overflow-x: scroll !important;  /* Force scroll, not auto */
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch !important;
        width: 100%;
        position: relative;
        /* Enable GPU acceleration */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        /* Show scrollbar on iOS (non-standard but works) */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;  /* Firefox */
    }

    /* Force iOS to show scrollbar indicator */
    .table-responsive::-webkit-scrollbar {
        -webkit-appearance: none;
        height: 8px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        border-radius: 4px;
        background-color: rgba(0, 0, 0, 0.3);
    }

    /* Force table to be wide - don't let it shrink */
    .table-responsive > .table {
        margin-bottom: 0;
        /* Force minimum width - MUST be wider than mobile viewport */
        min-width: 800px !important;  /* Forces horizontal scroll */
        width: auto;
        table-layout: auto;
        white-space: nowrap;  /* Prevent text wrapping */
    }

    /* Prevent table cells from wrapping */
    .table-responsive .table th,
    .table-responsive .table td {
        white-space: nowrap;
        min-width: 80px;  /* Minimum column width */
    }

    /* Specific column widths to ensure wide table */
    .table-responsive .table th:nth-child(1),
    .table-responsive .table td:nth-child(1) {
        min-width: 100px;  /* Date column */
    }

    .table-responsive .table th:nth-child(2),
    .table-responsive .table td:nth-child(2) {
        min-width: 80px;  /* Time column */
    }

    .table-responsive .table th:nth-child(3),
    .table-responsive .table td:nth-child(3) {
        min-width: 120px;  /* Customer column */
    }

    .table-responsive .table th:nth-child(4),
    .table-responsive .table td:nth-child(4) {
        min-width: 150px;  /* Service column */
    }

    /* Add visible scroll indicator - iOS style */
    .table-responsive::after {
        content: '← Swipe to see more →';
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s;
        z-index: 10;
    }

    .table-responsive.has-scroll::after {
        opacity: 1;
    }

    /* Hide hint after first scroll */
    .table-responsive.scrolled::after {
        opacity: 0;
    }

    /* Add right edge shadow indicator */
    .table-responsive::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to left, rgba(0,0,0,0.15), transparent);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s;
        z-index: 5;
    }

    .table-responsive.has-scroll::before {
        opacity: 1;
    }

    .table-responsive.scrolled-end::before {
        opacity: 0;
    }

    /* Ensure text alignment classes work */
    .table .text-end {
        text-align: right !important;
    }

    .table .text-start {
        text-align: left !important;
    }

    .table .text-center {
        text-align: center !important;
    }

    /* Ensure all text elements have proper contrast */
    p, span, div, label {
        color: inherit;
    }

    /* Strong emphasis */
    strong, b {
        font-weight: 600;
        color: var(--text-primary);
    }
}

/* ============================================
   DARK MODE SUPPORT - iOS Dark Mode
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        /* iOS Dark Mode Backgrounds */
        --bg-primary: #000000;  /* System Background */
        --bg-secondary: #1C1C1E;  /* Secondary System Background */
        --bg-tertiary: #2C2C2E;  /* Tertiary System Background */

        /* iOS Dark Mode Text Colors */
        --text-primary: #FFFFFF;
        --text-secondary: rgba(235, 235, 245, 0.6);  /* Secondary Label Dark */
        --text-tertiary: rgba(235, 235, 245, 0.3);   /* Tertiary Label Dark */

        /* iOS Dark Mode Separators */
        --separator-color: rgba(84, 84, 88, 0.65);  /* iOS Separator Dark */
        --border-color: var(--separator-color);

        /* iOS Dark Mode System Grays */
        --ios-gray: #8E8E93;
        --ios-gray2: #636366;
        --ios-gray3: #48484A;
        --ios-gray4: #3A3A3C;
        --ios-gray5: #2C2C2E;
        --ios-gray6: #1C1C1E;
    }

    @media (max-width: 767px) {
        body {
            background-color: var(--bg-primary) !important;
            color: var(--text-primary);
        }

        main {
            background-color: var(--bg-primary) !important;
        }

        .card, .card-mobile {
            background-color: var(--bg-secondary) !important;
            color: var(--text-primary);
        }

        .card-header, .card-footer {
            background-color: var(--bg-secondary) !important;
            border-color: var(--separator-color) !important;
        }

        .card-body {
            background-color: var(--bg-secondary) !important;
            color: var(--text-primary);
        }

        /* Preserve Bootstrap primary header in dark mode */
        .card-header.bg-primary {
            background-color: var(--ios-blue) !important;
            color: #FFFFFF !important;
        }

        .card-header.bg-primary p,
        .card-header.bg-primary h1,
        .card-header.bg-primary h2,
        .card-header.bg-primary h3,
        .card-header.bg-primary h4,
        .card-header.bg-primary h5,
        .card-header.bg-primary h6 {
            color: #FFFFFF !important;
        }

        .bottom-nav {
            background: rgba(28, 28, 30, 0.72) !important;  /* iOS dark translucent tab bar */
            border-top-color: var(--separator-color);
        }

        .app-header {
            background: rgba(28, 28, 30, 0.94) !important;  /* iOS dark translucent nav bar */
            border-bottom-color: var(--separator-color);
        }

        .form-control-mobile {
            background: var(--bg-tertiary) !important;
            border-color: var(--separator-color);
            color: var(--text-primary);
        }

        .form-control-mobile:focus {
            background: var(--bg-secondary) !important;
            border-color: var(--ios-blue);
        }

        /* Form labels in dark mode */
        .form-label,
        .form-floating > label,
        label {
            color: var(--text-primary) !important;
        }

        /* Form controls in dark mode */
        .form-control,
        .form-select {
            background-color: var(--bg-tertiary) !important;
            border-color: var(--separator-color) !important;
            color: var(--text-primary) !important;
        }

        .form-control:focus,
        .form-select:focus {
            background-color: var(--bg-secondary) !important;
            border-color: var(--ios-blue) !important;
            color: var(--text-primary) !important;
        }

        .form-control::placeholder {
            color: var(--text-secondary) !important;
        }

        /* Form text (helper text) in dark mode */
        .form-text,
        small.text-muted {
            color: var(--text-secondary) !important;
        }

        /* Validation messages */
        .text-danger {
            color: #FF453A !important;  /* iOS red in dark mode */
        }

        .text-success {
            color: #32D74B !important;  /* iOS green in dark mode */
        }

        /* Password strength bar */
        .progress {
            background-color: var(--bg-tertiary) !important;
        }

        /* Ensure badges remain visible */
        .badge {
            color: #FFFFFF !important;
        }

        /* Links in dark mode */
        a {
            color: var(--ios-blue) !important;
        }

        a:hover {
            color: #409CFF !important;  /* Lighter blue on hover */
        }

        .list-mobile-item {
            border-bottom-color: var(--separator-color);
        }

        .list-mobile-item:active {
            background-color: var(--bg-tertiary);
        }

        /* Ensure text is white in dark mode */
        h1, h2, h3, h4, h5, h6,
        .card-title,
        .list-mobile-item-title,
        p {
            color: var(--text-primary) !important;
        }

        /* Dark mode table styling */
        .table {
            color: var(--text-primary) !important;
            background-color: var(--bg-secondary);
        }

        .table thead th {
            color: var(--text-primary) !important;
            background-color: var(--bg-tertiary) !important;
            border-bottom-color: var(--separator-color) !important;
        }

        .table tbody td {
            color: var(--text-primary) !important;
            background-color: var(--bg-secondary) !important;
            border-bottom-color: var(--separator-color) !important;
        }

        .table-striped tbody tr:nth-of-type(odd) td {
            background-color: rgba(44, 44, 46, 0.5) !important;
        }

        .table tfoot td,
        .table tfoot th {
            color: var(--text-primary) !important;
            background-color: var(--bg-tertiary) !important;
            border-top-color: var(--separator-color) !important;
        }

        .table-light,
        .table-secondary {
            background-color: var(--bg-tertiary) !important;
            color: var(--text-primary) !important;
        }
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.no-scroll {
    overflow: hidden;
}

.text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.divider-mobile {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
