/* =============================================================================
   PRODUCTION-READY RESPONSIVE STYLES
   Mobile-First, Touch-Optimized Design for PlayDateApp
   ============================================================================= */

/* === MOBILE-FIRST BASE CONFIGURATION === */
:root {
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    
    /* Touch Targets (WCAG AAA compliant) */
    --touch-min: 48px;
    --touch-comfortable: 56px;
    
    /* UI Elements */
    --dropdown-arrow-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6"><path d="M0 0l6 6 6-6z" fill="%23333"/></svg>');
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Colors */
    --primary: #0f766e;
    --primary-dark: #0d6b63;
    --secondary: #0d9488;
    --success: #0891b2;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #6366f1;
    
    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Z-Index Scale */
    --z-modal: 1000;
    --z-sidebar: 999;
    --z-navbar: 998;
    --z-dropdown: 997;
    --z-tooltip: 996;
}

/* === GLOBAL RESET AND BASE STYLES === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    background: #faf9f7;
    min-height: 100vh;
}

/* === RESPONSIVE CONTAINER === */
.container,
.mobile-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

@media (min-width: 640px) {
    .container {
        padding: 0 var(--space-lg);
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 var(--space-xl);
    }
}

/* === RESPONSIVE GRID SYSTEM === */
.grid {
    display: grid;
    gap: var(--space-md);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 767px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* === RESPONSIVE TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-md);
    color: var(--gray-900);
}

h1 {
    font-size: var(--text-2xl);
}

h2 {
    font-size: var(--text-xl);
}

h3 {
    font-size: var(--text-lg);
}

@media (min-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
}

p {
    margin-bottom: var(--space-md);
    line-height: 1.6;
}

/* === RESPONSIVE CARDS === */
.card {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: var(--space-lg);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

@media (max-width: 767px) {
    .card {
        border-radius: var(--radius-lg);
        margin-bottom: var(--space-md);
    }
    
    .card-header,
    .card-body {
        padding: var(--space-md);
    }
    
    .card-footer {
        padding: var(--space-sm) var(--space-md);
    }
}

/* === RESPONSIVE FORMS === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--gray-700);
    font-size: var(--text-sm);
}

.form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0.75rem 1rem;
    font-size: var(--text-base);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

@media (max-width: 767px) {
    .form-control,
    input,
    select,
    textarea {
        min-height: var(--touch-comfortable);
        padding: 1rem 1.25rem;
        font-size: var(--text-lg);
    }
}

/* === RESPONSIVE BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    min-height: var(--touch-min);
    padding: 0.75rem 1.5rem;
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease, box-shadow 0.15s ease, transform 0.1s ease;
    text-decoration: none;
    touch-action: manipulation;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-600);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
}

.btn-lg {
    min-height: var(--touch-comfortable);
    padding: 1rem 2rem;
    font-size: var(--text-lg);
}

.btn-block {
    width: 100%;
}

@media (max-width: 767px) {
    .btn {
        min-height: var(--touch-comfortable);
        padding: 1rem 1.5rem;
        font-size: var(--text-lg);
    }
    
    .btn-block-mobile {
        width: 100%;
    }
}

/* === RESPONSIVE TABLES === */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

@media (max-width: 767px) {
    .table-responsive {
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
    }
    
    .table th,
    .table td {
        padding: var(--space-sm);
        font-size: var(--text-sm);
        min-width: 100px;
    }
}

/* === SYNCFUSION GRID RESPONSIVE OVERRIDES === */
@media (max-width: 767px) {
    .e-grid {
        font-size: var(--text-sm);
    }
    
    .e-grid .e-gridheader,
    .e-grid .e-gridcontent {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .e-grid .e-headercell,
    .e-grid .e-rowcell {
        padding: var(--space-sm);
        min-width: 100px;
    }
    
    .e-grid .e-toolbar {
        flex-wrap: wrap;
    }
    
    .e-grid .e-toolbar .e-toolbar-item {
        margin-bottom: var(--space-sm);
    }
    
    /* Make dialog full screen on mobile */
    .e-dialog {
        width: 95vw !important;
        max-width: 95vw !important;
        height: auto !important;
        max-height: 90vh !important;
    }
    
    .e-dialog .e-dlg-content {
        padding: var(--space-md);
    }
    
    .e-dialog .e-footer-content {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .e-dialog .e-footer-content .e-btn {
        width: 100%;
    }
}

/* === RESPONSIVE MODALS/DIALOGS === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-md);
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

@media (max-width: 767px) {
    .modal {
        align-items: flex-end;
        padding: 0;
    }
    
    .modal-content {
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 95vh;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* === RESPONSIVE ALERTS === */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid;
}

.alert-success {
    background: #ecfeff;
    border-color: #a5f3fc;
    color: #155e75;
}

.alert-danger {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* === RESPONSIVE NAVIGATION === */
@media (max-width: 767px) {
    .navbar {
        padding: var(--space-sm) var(--space-md);
    }
    
    .navbar-brand {
        font-size: var(--text-lg);
    }
    
    .nav-link {
        min-height: var(--touch-min);
        display: flex;
        align-items: center;
        padding: var(--space-md);
    }
    
    .sidebar {
        width: 85vw !important;
        max-width: 320px !important;
    }
}

/* === UTILITY CLASSES === */
/* Spacing */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-xs); }
.m-2 { margin: var(--space-sm); }
.m-3 { margin: var(--space-md); }
.m-4 { margin: var(--space-lg); }
.m-5 { margin: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }

/* Flexbox */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.gap-1 { gap: var(--space-xs); }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }
.gap-4 { gap: var(--space-lg); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Display */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }

@media (max-width: 767px) {
    .d-sm-none { display: none; }
    .d-sm-block { display: block; }
}

@media (min-width: 768px) {
    .d-md-none { display: none; }
    .d-md-block { display: block; }
}

/* === LOADING STATES === */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === ACCESSIBILITY === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* === SAFE AREA SUPPORT (iPhone X+) === */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-top: max(var(--space-md), env(safe-area-inset-top));
    }
    
    .page-body {
        padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    }
}

/* === PRINT STYLES === */
@media print {
    body {
        background: white;
    }
    
    .no-print,
    .navbar,
    .sidebar,
    .btn,
    button {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
        page-break-inside: avoid;
    }
}

/* === DARK MODE SUPPORT === */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: var(--gray-900);
        --bg-secondary: var(--gray-800);
        --text-primary: var(--gray-100);
        --text-secondary: var(--gray-300);
    }
    
    body {
        background: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .card {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
    
    .form-control,
    input,
    select,
    textarea {
        background: var(--bg-primary);
        border-color: var(--gray-700);
        color: var(--text-primary);
    }
}

/* === REDUCED MOTION === */
@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;
    }
}

/* =============================================================================
   TABLET-SPECIFIC RESPONSIVE ENHANCEMENTS
   Optimized for tablet devices (768px - 1024px)
   ============================================================================= */

/* === TABLET BREAKPOINT (768px - 1024px) === */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Container adjustments for tablets */
    .container {
        max-width: 100%;
        padding: 0 var(--space-lg);
    }
    
    /* Typography for tablets */
    h1 {
        font-size: 2.25rem;
    }
    
    h2 {
        font-size: 1.875rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    /* Grid adjustments for tablets */
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    /* Card adjustments for tablets */
    .card {
        margin-bottom: var(--space-lg);
    }
    
    .card-body {
        padding: var(--space-lg);
    }
    
    /* Button sizing for tablets */
    .btn {
        min-height: 52px;
        padding: 0.875rem 1.75rem;
        font-size: 1.05rem;
    }
    
    /* Form elements for tablets */
    .form-control,
    input,
    select,
    textarea {
        min-height: 52px;
        padding: 0.875rem 1.125rem;
        font-size: 1.05rem;
    }
    
    /* Table responsive improvements */
    .table th,
    .table td {
        padding: var(--space-md);
        font-size: 1rem;
    }
    
    /* Modal adjustments for tablets */
    .modal-content {
        max-width: 90%;
        padding: var(--space-lg);
    }
    
    /* Navigation adjustments for tablets */
    .navbar {
        padding: 1rem 1.5rem;
    }
    
    /* Sidebar for tablets */
    .sidebar {
        width: 280px;
    }
}

/* === LARGE TABLETS AND SMALL LAPTOPS (1024px - 1280px) === */
@media (min-width: 1024px) and (max-width: 1280px) {
    .container {
        max-width: 1024px;
        padding: 0 var(--space-xl);
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* === HORIZONTAL OVERFLOW PREVENTION === */
@media (max-width: 1024px) {
    body {
        overflow-x: hidden;
    }
    
    .container,
    .row,
    .card,
    .modal-content {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Ensure images don't cause horizontal scroll */
    img,
    video,
    iframe {
        max-width: 100%;
        height: auto;
    }
    
    /* Prevent pre and code blocks from overflowing */
    pre,
    code {
        max-width: 100%;
        overflow-x: auto;
        word-wrap: break-word;
        white-space: pre-wrap;
    }
    
    /* Ensure tables are responsive */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* === LANDSCAPE ORIENTATION (TABLETS) === */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    /* Optimize vertical space in landscape mode */
    .navbar {
        min-height: 60px;
        padding: 0.75rem 1.5rem;
    }
    
    .page-body {
        padding: 1.5rem;
    }
    
    .card-header {
        padding: 1rem 1.5rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    /* Reduce spacing to maximize content area */
    .mb-4,
    .my-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-4,
    .my-4 {
        margin-top: 1.5rem !important;
    }
}

/* === PORTRAIT ORIENTATION (TABLETS) === */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    /* Optimize horizontal space in portrait mode */
    .container {
        padding: 0 var(--space-md);
    }
    
    /* Two-column layout works well in portrait */
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    /* Adjust button groups for portrait */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: var(--space-sm);
    }
}

/* === TOUCH OPTIMIZATION FOR ALL TOUCH DEVICES === */
@media (hover: none) and (pointer: coarse) {
    /* Increase all interactive element sizes for touch */
    .btn,
    a,
    button,
    input[type="submit"],
    input[type="button"],
    .nav-link {
        min-height: var(--touch-min);
        min-width: var(--touch-min);
        padding: 0.75rem 1.25rem;
    }
    
    /* Increase spacing between interactive elements */
    .btn-group .btn {
        margin: var(--space-xs);
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none;
    }
    
    /* Add active states for better touch feedback */
    .btn:active,
    .card:active,
    .nav-link:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* === HIGH-DPI DISPLAYS (RETINA) === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure sharp text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Optimize icon rendering */
    .fas,
    .fa,
    .icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* === SMALL DESKTOP (1280px - 1440px) === */
@media (min-width: 1280px) and (max-width: 1440px) {
    .container {
        max-width: 1200px;
    }
    
    /* Optimize grid for small desktops */
    .grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* === LARGE DESKTOP (1440px+) === */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    /* Increase base font size for better readability on large screens */
    html {
        font-size: 17px;
    }
    
    /* Optimize spacing for large screens */
    .page-body {
        padding: 3rem;
    }
    
    .card {
        margin-bottom: 2.5rem;
    }
}

/* === ULTRA-WIDE SCREENS (1920px+) === */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
    
    html {
        font-size: 18px;
    }
    
    /* Increase grid columns for ultra-wide screens */
    .grid-cols-4 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    
    /* Optimize layout for very wide screens */
    .page-body {
        padding: 4rem;
    }
}

/* === ACCESSIBILITY - FOCUS VISIBLE === */
@media (prefers-reduced-motion: no-preference) {
    *:focus-visible {
        outline: 3px solid var(--primary);
        outline-offset: 3px;
        transition: outline 0.2s ease;
    }
}

/* === PRINT OPTIMIZATION === */
@media print {
    /* Remove all interactive elements */
    .btn,
    button,
    .nav-link,
    .navbar,
    .sidebar,
    .modal {
        display: none !important;
    }
    
    /* Optimize cards for printing */
    .card {
        break-inside: avoid;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        box-shadow: none;
    }
    
    /* Ensure readable text */
    body {
        color: #000;
        background: #fff;
        font-size: 12pt;
    }
    
    /* Show URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 90%;
        color: #666;
    }
}

/* =============================================================================
   CROSS-PLATFORM CONSISTENCY
   Ensures consistent experience across Web, Android, iOS, and Windows
   ============================================================================= */

/* === NORMALIZE FORM ELEMENTS ACROSS PLATFORMS === */
input,
textarea,
select,
button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* === FIX FOR iOS SAFARI === */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS input zoom */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
    
    /* Fix for iOS sticky hover states */
    .btn:hover,
    .card:hover,
    a:hover {
        -webkit-tap-highlight-color: transparent;
    }
}

/* === FIX FOR ANDROID === */
@media (max-width: 1024px) {
    /* Prevent text inflation on Android */
    body {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Fix for Android select elements */
    select {
        background-image: var(--dropdown-arrow-icon);
        background-repeat: no-repeat;
        background-position: right 10px center;
        padding-right: 30px;
    }
}

/* === WINDOWS HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    *:focus {
        outline: 3px solid currentColor;
        outline-offset: 3px;
    }
}

/* =============================================================================
   BOOTSTRAP GRID SYSTEM ENHANCEMENTS
   Additional responsive utilities to complement existing Bootstrap classes
   ============================================================================= */

/* === EXTRA SMALL DEVICES (< 576px) === */
@media (max-width: 575.98px) {
    .container {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }
    
    /* Stack all columns on extra small devices */
    [class*="col-"] {
        width: 100%;
        max-width: 100%;
    }
    
    /* Full-width buttons on small devices */
    .btn-block-xs {
        display: block;
        width: 100%;
    }
}

/* === SMALL DEVICES (576px - 767.98px) === */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        max-width: 540px;
    }
    
    /* Two-column layout for small devices */
    .col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* === ENSURE PROPER STACKING CONTEXT === */
.navbar {
    z-index: 1030;
}

.sidebar {
    z-index: 1020;
}

.modal {
    z-index: 1050;
}

.modal-backdrop {
    z-index: 1040;
}

.dropdown-menu {
    z-index: 1000;
}

.tooltip {
    z-index: 1070;
}
