/* ============================================
   MOBILE-FIRST RESPONSIVE STYLES
   Enhanced for better UX and accessibility
   ============================================ */

/* ============================================
   GLOBAL RESPONSIVE FIXES
   ============================================ */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Prevent horizontal scroll */
.container,
.container-fluid {
    overflow-x: hidden;
    max-width: 100%;
}

/* ============================================
   MOBILE STYLES (max-width: 575.98px)
   ============================================ */
@media (max-width: 575.98px) {
    /* Base Typography - Ensure readable without zooming */
    html {
        font-size: 16px; /* Prevents iOS zoom on input focus */
    }
    
    body {
        font-size: 16px; /* Minimum readable size */
        line-height: 1.6;
    }
    
    /* Typography Scaling */
    h1, .display-1 {
        font-size: 1.875rem; /* 30px */
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    h2, .display-2 {
        font-size: 1.5rem; /* 24px */
        line-height: 1.3;
        margin-bottom: 0.875rem;
    }
    
    h3, .display-3 {
        font-size: 1.25rem; /* 20px */
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    h4, .display-4 {
        font-size: 1.125rem; /* 18px */
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    h5, .display-5 {
        font-size: 1rem; /* 16px */
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }
    
    h6 {
        font-size: 0.9375rem; /* 15px */
        line-height: 1.5;
    }
    
    p, .lead {
        font-size: 16px; /* Readable without zoom */
        line-height: 1.6;
        margin-bottom: 1rem;
    }
    
    .lead {
        font-size: 18px;
    }
    
    /* Mobile: Container & Spacing - consistent 12-16px padding */
    .container {
        padding-left: 1rem; /* 16px */
        padding-right: 1rem; /* 16px */
        max-width: 100%;
    }
    
    /* Mobile: Prevent sticky header covering content */
    main.container {
        padding-top: 1rem; /* Extra top padding for sticky header */
    }
    
    section {
        padding: 2.5rem 0;
        overflow-x: hidden;
    }
    
    .section-header {
        margin-bottom: 2rem;
        padding: 0 1rem; /* 16px horizontal padding */
    }
    
    /* Mobile: Consistent spacing between elements */
    .mb-3, .mb-4 {
        margin-bottom: 1rem !important; /* 16px */
    }
    
    .mt-3, .mt-4 {
        margin-top: 1rem !important; /* 16px */
    }
    
    /* Mobile: Cards - improved spacing, no edge-to-edge */
    .card {
        margin-bottom: 1.5rem;
        border-radius: 12px;
        overflow: hidden;
        margin-left: 0.5rem; /* 8px left margin */
        margin-right: 0.5rem; /* 8px right margin */
        width: calc(100% - 1rem); /* Prevents edge-to-edge */
    }
    
    .card-body {
        padding: 1rem; /* 16px - consistent spacing */
    }
    
    .card-header {
        padding: 1rem; /* 16px */
    }
    
    .card-footer {
        padding: 1rem; /* 16px */
    }
    
    /* Mobile: Card titles and text - prevent overflow */
    .card-title {
        font-size: 1.125rem; /* 18px */
        line-height: 1.4;
        margin-bottom: 0.75rem;
        word-wrap: break-word;
    }
    
    .card-text {
        font-size: 16px;
        line-height: 1.6;
        word-wrap: break-word;
    }
    
    /* Hero Section Mobile */
    .hero-section {
        padding: 2.5rem 0;
    }
    
    .hero-section h1 {
        font-size: 1.875rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }
    
    .hero-section .lead {
        font-size: 16px;
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }
    
    .hero-feature-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-feature-card i {
        font-size: 2rem !important;
        margin-bottom: 0.5rem;
    }
    
    .hero-feature-card h5 {
        font-size: 0.875rem;
    }
    
    /* Mobile: Buttons - Touch Friendly (minimum 44px tap target) */
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem 1.25rem;
        font-size: 16px; /* Prevents iOS zoom */
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        touch-action: manipulation; /* Prevents double-tap zoom */
    }
    
    .btn-lg {
        min-height: 52px;
        padding: 0.875rem 1.5rem;
        font-size: 18px;
    }
    
    /* Mobile: Ensure btn-sm meets minimum 44px tap size */
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 0.625rem 1rem;
        font-size: 15px; /* Increased from 14px for readability */
        line-height: 1.5;
    }
    
    /* Mobile: Icon-only buttons need minimum size */
    .btn i:only-child,
    .btn:has(i:only-child) {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Button Groups */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.75rem;
        margin-right: 0;
    }
    
    .btn-group .btn:last-child {
        margin-bottom: 0;
    }
    
    .d-flex.gap-3 {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    
    .d-flex.gap-3 .btn {
        width: 100%;
    }
    
    /* Gamification Cards */
    .gamification-card {
        padding: 1rem !important;
    }
    
    .gamification-card .row {
        flex-direction: column;
    }
    
    .gamification-card .col-md-3,
    .gamification-card .col-md-6,
    .gamification-card .col-md-4 {
        margin-bottom: 1rem;
        text-align: center;
    }
    
    /* Mobile: Badge Grid - proper spacing and alignment */
    .badge-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem; /* 12px gap */
        margin-bottom: 1rem;
    }
    
    .badge-grid .card {
        margin: 0;
        width: 100%;
    }
    
    /* Mobile: Challenge Cards - improved spacing */
    .challenge-card {
        margin-bottom: 1rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        width: calc(100% - 1rem);
    }
    
    /* Mobile: Challenge card content - readable text */
    .challenge-card .card-body {
        padding: 1rem;
    }
    
    .challenge-card .card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .challenge-card .progress {
        margin-bottom: 0.75rem;
    }
    
    /* Statistics Cards */
    .stat-card {
        margin-bottom: 1rem;
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    /* Buttons */
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
    
    /* Mobile: Navigation - sticky header fixes, proper spacing */
    .navbar {
        padding: 0.75rem 1rem; /* 12px vertical, 16px horizontal */
        position: sticky;
        top: 0;
        z-index: 1030;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Mobile: Prevent header covering content */
    body {
        padding-top: 0; /* Navbar handles its own spacing */
    }
    
    .navbar-brand {
        font-size: 1.125rem; /* 18px */
        padding: 0.5rem 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        font-size: 1.25rem;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        min-height: 44px; /* Minimum tap size */
        min-width: 44px;
        touch-action: manipulation;
    }
    
    .navbar-collapse {
        margin-top: 1rem; /* 16px spacing */
        padding: 1rem; /* 16px internal padding */
        background: var(--bg-light);
        border-radius: 12px;
        box-shadow: var(--shadow-md);
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .navbar-nav {
        text-align: left;
        width: 100%;
    }
    
    .navbar-nav .nav-item {
        width: 100%;
        margin-bottom: 0.5rem; /* 8px spacing between items */
    }
    
    .navbar-nav .nav-link {
        padding: 0.875rem 1rem !important; /* 14px vertical, 16px horizontal */
        min-height: 48px; /* Minimum tap size */
        display: flex;
        align-items: center;
        border-radius: 8px;
        width: 100%;
        font-size: 16px;
        touch-action: manipulation;
    }
    
    .navbar-nav .nav-link i {
        margin-right: 0.75rem; /* 12px spacing */
        width: 20px;
        text-align: center;
        flex-shrink: 0; /* Prevent icon from shrinking */
    }
    
    /* Mobile: User menu in navbar - visual separation */
    .navbar-nav:last-child {
        border-top: 1px solid var(--border-color);
        padding-top: 0.75rem; /* 12px */
        margin-top: 0.75rem; /* 12px */
    }
    
    /* Mobile: Navbar button links - ensure tap size */
    .navbar-nav .btn-link {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
    
    /* Mobile: Dashboard - improved grid spacing */
    .dashboard-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem; /* 12px gap */
        margin-bottom: 1rem;
    }
    
    .stat-card {
        margin-bottom: 0;
    }
    
    /* Mobile: Course Cards - proper spacing, no edge-to-edge */
    .course-card {
        margin-bottom: 1rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        width: calc(100% - 1rem);
    }
    
    /* Mobile: Course card images - proper aspect ratio */
    .course-thumbnail-sm {
        width: 100%;
        height: 150px;
        object-fit: cover;
    }
    
    /* Mobile: Gamification card - improved mobile layout */
    .gamification-card {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        width: calc(100% - 1rem);
    }
    
    .gamification-card .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .gamification-card .col-md-3,
    .gamification-card .col-md-6,
    .gamification-card .col-md-4 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        margin-bottom: 1rem;
    }
    
    /* Mobile: Progress Bars - readable and touch-friendly */
    .progress {
        height: 1.25rem; /* 20px - visible on mobile */
        font-size: 0.875rem; /* 14px - readable */
        border-radius: 8px;
        margin-bottom: 0.75rem; /* 12px spacing */
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    .progress-bar {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 500;
        min-height: 1.25rem;
    }
    
    /* Mobile: Small progress bars in cards */
    .card .progress {
        height: 1rem; /* 16px for compact cards */
        font-size: 0.75rem; /* 12px */
    }
    
    /* Leaderboard */
    .leaderboard-table {
        font-size: 0.8rem;
    }
    
    .leaderboard-table .avatar-circle {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    /* Mobile: Forms - Prevent zoom on iOS, proper spacing */
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 48px; /* Minimum tap size */
        padding: 0.75rem 1rem; /* 12px vertical, 16px horizontal */
        border-radius: 8px;
        margin-bottom: 1rem; /* 16px spacing between fields */
        width: 100%;
    }
    
    .form-label {
        font-size: 16px;
        margin-bottom: 0.5rem; /* 8px spacing */
        font-weight: 500;
        display: block;
    }
    
    .form-text {
        font-size: 14px;
        margin-top: 0.5rem; /* 8px spacing */
    }
    
    /* Mobile: Form groups - consistent spacing */
    .mb-3 {
        margin-bottom: 1rem !important; /* 16px */
    }
    
    /* Mobile: Form checkboxes and radios - larger tap targets */
    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        min-width: 1.5rem;
        min-height: 1.5rem;
        margin-top: 0.25rem;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Mobile: Form cards - proper padding */
    .card .card-body.p-5 {
        padding: 1.5rem !important; /* Reduced from p-5 for mobile */
    }
    
    /* Statistics Section */
    .stats-section {
        padding: 2.5rem 0;
    }
    
    .stat-item {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .stat-label {
        font-size: 14px;
    }
    
    /* Testimonials */
    .testimonial-card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .testimonial-text {
        font-size: 16px;
        margin-bottom: 1rem;
    }
    
    /* Feature Cards Grid */
    .row.g-3,
    .row.g-4 {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .row.g-3 > *,
    .row.g-4 > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        margin-bottom: 1rem;
    }
    
    /* Mobile: Tables - horizontal scroll, readable text */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        display: block;
        width: 100%;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .table {
        font-size: 14px;
        min-width: 600px; /* Ensures horizontal scroll instead of text shrinking */
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem; /* 12px vertical, 8px horizontal */
        white-space: nowrap;
        vertical-align: middle;
    }
    
    .table th {
        font-weight: 600;
        background-color: var(--bg-light);
        position: sticky;
        left: 0;
        z-index: 10;
    }
    
    /* Mobile: Table wrapper for better scrolling */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    /* Mobile: Modals - fit on screen, proper spacing */
    .modal-dialog {
        margin: 0.5rem; /* 8px margin from edges */
        max-width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
        display: flex;
        flex-direction: column;
    }
    
    .modal-content {
        border-radius: 12px;
        padding: 0;
        max-height: calc(100vh - 1rem);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .modal-header {
        padding: 1rem; /* 16px */
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .modal-body {
        padding: 1rem; /* 16px */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto;
    }
    
    .modal-footer {
        padding: 1rem; /* 16px */
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Mobile: Alert spacing - consistent padding */
    .alert {
        padding: 1rem; /* 16px */
        margin-bottom: 1rem; /* 16px */
        border-radius: 8px;
        word-wrap: break-word;
    }
    
    .alert .d-flex {
        gap: 0.75rem; /* 12px gap between icon and content */
    }
    
    .alert i {
        flex-shrink: 0; /* Prevent icon from shrinking */
        margin-top: 0.125rem; /* Align icon with text */
    }
    
    /* Mobile: Footer - proper spacing and alignment */
    .footer {
        padding: 2rem 1rem 1rem; /* 32px top, 16px sides, 16px bottom */
        text-align: center;
        margin-top: 2rem;
    }
    
    .footer .row {
        flex-direction: column;
        margin-left: 0;
        margin-right: 0;
    }
    
    .footer .col-md-6 {
        margin-bottom: 1rem; /* 16px spacing */
        text-align: center !important;
        padding-left: 0;
        padding-right: 0;
    }
    
    .footer p {
        margin-bottom: 0.75rem; /* 12px spacing */
        font-size: 14px;
    }
    
    .footer a {
        min-height: 44px; /* Minimum tap size */
        display: inline-flex;
        align-items: center;
        padding: 0.5rem;
    }
    
    /* Overflow Fixes */
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Text Overflow */
    .text-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Prevent text overflow in cards */
    .card-title,
    .card-text {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Mobile: Grid Fixes - consistent spacing, prevent overflow */
    .row {
        margin-left: -0.5rem; /* Reduced negative margin */
        margin-right: -0.5rem;
        display: flex;
        flex-wrap: wrap;
    }
    
    .row > * {
        padding-left: 0.5rem; /* 8px padding */
        padding-right: 0.5rem;
        margin-bottom: 1rem; /* 16px bottom margin */
    }
    
    /* Mobile: Prevent horizontal scroll from row negative margins */
    .container .row {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Mobile: Column spacing - ensure no edge-to-edge */
    .col-12,
    .col-md-12 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Mobile: Stack columns on small screens */
    .col-md-4,
    .col-md-6,
    .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
}

/* ============================================
   TABLET STYLES (576px - 767.98px)
   ============================================ */
@media (min-width: 576px) and (max-width: 767.98px) {
    html {
        font-size: 16px;
    }
    
    body {
        font-size: 16px;
    }
    
    /* Typography */
    h1, .display-1 {
        font-size: 2.25rem;
    }
    
    h2, .display-2 {
        font-size: 1.875rem;
    }
    
    h3, .display-3 {
        font-size: 1.5rem;
    }
    
    /* Container */
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    section {
        padding: 3rem 0;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 3rem 0;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    /* Navigation */
    .navbar-collapse {
        padding: 1.25rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem !important;
    }
    
    /* Cards */
    .card-body {
        padding: 1.5rem;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .btn-group .btn {
        width: auto;
        margin-right: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .d-flex.gap-3 {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .d-flex.gap-3 .btn {
        width: auto;
        flex: 0 1 auto;
    }
    
    /* Grids */
    .badge-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .dashboard-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Statistics */
    .stat-number {
        font-size: 2.5rem;
    }
    
    /* Feature Cards */
    .row.g-3 > *,
    .row.g-4 > * {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Tables */
    .table {
        font-size: 15px;
    }
    
    /* Footer */
    .footer .row {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .footer .col-md-6 {
        text-align: left;
    }
    
    .footer .col-md-6:last-child {
        text-align: right;
    }
}

/* ============================================
   TOUCH-FRIENDLY ELEMENTS
   WCAG 2.5.5 Target Size Compliance
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets - minimum 44x44px for accessibility */
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem 1.5rem;
        touch-action: manipulation;
    }
    
    .btn-lg {
        min-height: 52px;
    }
    
    .btn-sm {
        min-height: 44px;
    }
    
    .nav-link {
        padding: 0.875rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    /* Better spacing for touch */
    .card {
        margin-bottom: 1.5rem;
    }
    
    /* Prevent text selection on buttons */
    .btn,
    .nav-link,
    .navbar-toggler {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Increase spacing between interactive elements */
    .btn + .btn {
        margin-left: 0.75rem;
    }
    
    .nav-link + .nav-link {
        margin-left: 0;
    }
    
    /* Larger form controls for easier interaction */
    .form-control,
    .form-select,
    .form-check-input {
        min-height: 48px;
        font-size: 16px !important; /* Prevents zoom on iOS */
        touch-action: manipulation;
    }
    
    /* Checkboxes and radios */
    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        min-height: 1.5rem;
    }
    
    /* Links */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    /* Prevent accidental zoom on double tap */
    * {
        touch-action: manipulation;
    }
    
    /* Better tap feedback */
    .btn:active,
    .nav-link:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

/* ============================================
   LANDSCAPE MOBILE (max-width: 767.98px)
   ============================================ */
@media (max-width: 767.98px) and (orientation: landscape) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    /* Optimize hero section for landscape */
    .hero-section {
        padding: 2rem 0 !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-section .lead {
        font-size: 16px;
        margin-bottom: 1rem;
    }
    
    /* Reduce vertical spacing */
    section {
        padding: 2rem 0 !important;
    }
    
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Compact cards */
    .card-body {
        padding: 1rem;
    }
    
    /* Compact stats */
    .stats-section {
        padding: 2rem 0;
    }
    
    .stat-item {
        padding: 1rem;
    }
    
    /* Navigation - Horizontal layout */
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Will be implemented if needed */
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders and shadows */
    .card {
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .card {
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* Accessibility - 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;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .nav-link {
        border-bottom: 2px solid transparent;
    }
    
    .nav-link:hover,
    .nav-link:focus {
        border-bottom-color: currentColor;
    }
}

/* Utility Classes for Mobile */
.mobile-center {
    text-align: center;
}

.mobile-full-width {
    width: 100%;
}

.mobile-hidden {
    display: none !important;
}

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

.mobile-only {
    display: block !important;
}

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

/* Sticky Sidebar for Mobile */
@media (max-width: 991px) {
    .mobile-sticky-sidebar {
        position: relative !important;
        top: 0 !important;
    }
}

/* ============================================
   DESKTOP STYLES (768px+)
   ============================================ */
@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
    
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    /* Navigation - Desktop */
    .navbar-nav .nav-link {
        padding: 0.5rem 1rem !important;
    }
    
    .navbar-collapse {
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin-top: 0;
    }
    
    /* Button Groups - Horizontal */
    .btn-group {
        flex-direction: row;
    }
    
    .btn-group .btn {
        margin-bottom: 0;
    }
    
    .d-flex.gap-3 {
        flex-direction: row;
    }
    
    .d-flex.gap-3 .btn {
        width: auto;
    }
    
    /* Footer */
    .footer .row {
        flex-direction: row;
    }
    
    .footer .col-md-6:last-child {
        text-align: right;
    }
}

/* ============================================
   LARGE DESKTOP (992px+)
   ============================================ */
@media (min-width: 992px) {
    .container {
        max-width: 1140px;
    }
    
    section {
        padding: 4rem 0;
    }
    
    .hero-section {
        padding: 5rem 0;
    }
}

/* ============================================
   VIDEO PLAYER OPTIMIZATIONS
   ============================================ */
@media (max-width: 767.98px) {
    .ratio-16x9 {
        min-height: 200px;
        max-height: 50vh;
    }
    
    video {
        object-fit: contain;
        width: 100%;
        height: auto;
    }
    
    .video-controls-info {
        font-size: 14px;
        padding: 0.75rem !important;
    }
    
    .video-controls-info kbd {
        font-size: 12px;
        padding: 0.25rem 0.5rem;
        min-height: 32px;
    }
    
    /* Video wrapper */
    .video-wrapper {
        position: relative;
        width: 100%;
        overflow: hidden;
    }
}

/* ============================================
   MOBILE: OVERFLOW & ALIGNMENT FIXES
   ============================================ */
/* Mobile: Prevent horizontal overflow */
body,
html {
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}

/* Mobile: Fix container overflow */
.container,
.container-fluid {
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
    padding-left: 1rem; /* 16px */
    padding-right: 1rem; /* 16px */
}

/* Mobile: Fix row overflow - no negative margins on mobile */
@media (max-width: 575.98px) {
    .row {
        margin-left: 0;
        margin-right: 0;
        overflow-x: hidden;
    }
    
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Tablet: Restore negative margins */
@media (min-width: 576px) {
    .row {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
    
    .row > * {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Mobile: Text alignment fixes */
.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

/* Mobile: Icon alignment */
i.fas,
i.far,
i.fab {
    vertical-align: middle;
    line-height: 1;
}

/* Mobile: Icon + text alignment */
.d-flex.align-items-center i {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* Text alignment fixes */
.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

@media (max-width: 575.98px) {
    .text-md-left {
        text-align: left !important;
    }
    
    .text-md-center {
        text-align: center !important;
    }
    
    .text-md-right {
        text-align: right !important;
    }
}

/* Flex alignment */
.d-flex {
    flex-wrap: wrap;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

/* Swipe Gestures Support */
.swipeable {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Prevent text overflow */
.text-nowrap {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Word wrapping */
.word-wrap {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Image responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Table responsive wrapper */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
}

/* Fix for long text in cards */
.card-title,
.card-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Fix for long URLs */
a {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top-color: #007bff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pull to Refresh Indicator */
.pull-to-refresh {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.875rem;
}

