/* ============================================
   COMPREHENSIVE RESPONSIVE STYLES
   Mobile (320px-767px), Tablet/iPad (768px-1024px), Desktop (1025px+)
   ============================================ */

/* ========== GLOBAL RESPONSIVE RULES ========== */

/* Ensure all images are responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Ensure all videos are responsive */
/* BUT preserve aspect ratio for videos inside ratio containers */
video {
    max-width: 100%;
}

/* Videos in ratio containers should fill the container */
.ratio video,
.ratio-16x9 video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Ensure all iframes are responsive */
iframe {
    max-width: 100%;
}

/* Iframes in ratio containers should fill the container */
.ratio iframe,
.ratio-16x9 iframe {
    width: 100%;
    height: 100%;
}

/* Prevent horizontal scrolling */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* ========== MOBILE FIRST (320px - 767px) ========== */
@media (max-width: 767px) {
    /* Typography */
    .hero-title,
    h1.hero-title,
    .display-4 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-subtitle,
    .lead {
        font-size: 1rem !important;
        line-height: 1.4 !important;
    }
    
    .section-title,
    h2.section-title {
        font-size: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    h5 {
        font-size: 1rem !important;
    }
    
    /* Spacing */
    .section-padding {
        padding: 3rem 0 !important;
    }
    
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Navigation */
    .navbar {
        padding: 0.5rem 0 !important;
        min-height: 60px !important;
        max-height: none !important;
    }
    
    .navbar-brand {
        padding: 0.4rem 0.8rem !important;
        max-height: 60px !important;
        min-height: 50px !important;
    }
    
    .logo-img {
        height: 40px !important;
        max-height: 40px !important;
        margin-right: 8px !important;
    }
    
    .site-name {
        font-size: 1rem !important;
    }
    
    /* Navbar Toggle Button - Mobile - CRITICAL: Must always be clickable */
    .navbar-toggler {
        border: 2px solid #FFFFFF !important;
        border-radius: 4px !important;
        padding: 0.4rem 0.6rem !important;
        background-color: #FFFFFF !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        order: 2 !important;
        z-index: 1051 !important;
        position: relative !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.5) !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }
    
    .navbar-toggler:hover {
        background-color: #f0f0f0 !important;
        border-color: #FFFFFF !important;
    }
    
    .navbar-toggler:focus {
        box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.5) !important;
        outline: none !important;
        background-color: #f0f0f0 !important;
    }
    
    .navbar-toggler:active {
        background-color: #e0e0e0 !important;
        transform: scale(0.95) !important;
    }
    
    /* Ensure toggle button is always on top */
    .navbar-toggler,
    .navbar-toggler * {
        pointer-events: auto !important;
    }
    
    .navbar-toggler-icon {
        width: 24px !important;
        height: 24px !important;
        background-size: 24px 24px !important;
        display: block !important;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(59, 130, 246, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    }
    
    /* Navbar Container - Mobile */
    .navbar .container {
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Navbar Collapse - Mobile */
    .navbar-collapse {
        flex-basis: 100% !important;
        flex-grow: 1 !important;
        order: 3 !important;
        width: 100% !important;
        margin-top: 1rem !important;
        padding: 1rem 0 !important;
        background-color: rgba(59, 130, 246, 0.95) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
        max-height: calc(100vh - 80px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: none !important;
        transform: none !important;
        will-change: auto !important;
        z-index: 1049 !important;
        position: relative !important;
    }
    
    /* Ensure dropdowns don't interfere with toggle button */
    .navbar-collapse .dropdown-menu {
        z-index: 1050 !important;
        position: static !important;
    }
    
    .navbar-collapse.collapsing {
        display: block !important;
        transition: height 0.3s ease !important;
        overflow: hidden !important;
    }
    
    .navbar-collapse.show,
    .navbar-collapse.collapse.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        will-change: auto !important;
    }
    
    .navbar-collapse:not(.show):not(.collapsing) {
        display: none !important;
    }
    
    /* Force visibility when menu is open - MOBILE ONLY */
    .navbar-collapse.show .navbar-nav,
    .navbar-collapse.show .navbar-nav .nav-item,
    .navbar-collapse.show .navbar-nav .nav-link,
    .navbar-collapse.show .navbar-nav .dropdown-menu,
    .navbar-collapse.show .navbar-nav .dropdown-item,
    .navbar-collapse.collapse.show .navbar-nav,
    .navbar-collapse.collapse.show .navbar-nav .nav-item,
    .navbar-collapse.collapse.show .navbar-nav .nav-link,
    .navbar-collapse.collapse.show .navbar-nav .dropdown-menu,
    .navbar-collapse.collapse.show .navbar-nav .dropdown-item {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .navbar-collapse.show .navbar-nav,
    .navbar-collapse.collapse.show .navbar-nav {
        display: flex !important;
        width: 100% !important;
        flex-direction: column !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
    }
    
    /* Navbar Nav - Mobile */
    .navbar-nav {
        width: 100% !important;
        flex-direction: column !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .navbar-nav .nav-item {
        width: 100% !important;
        margin: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
    }
    
    .navbar-nav .nav-item:last-child {
        border-bottom: none !important;
    }
    
    .navbar-nav .nav-link {
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
        width: 100% !important;
        display: block !important;
        color: #FFFFFF !important;
        text-align: left !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
    }
    
    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:focus {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: #b6862a !important;
    }
    
    /* Dropdown menus on mobile */
    .navbar-nav .dropdown-menu {
        width: 100% !important;
        position: static !important;
        float: none !important;
        margin: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        background-color: rgba(30, 64, 175, 0.3) !important;
        border-radius: 0 !important;
        display: none !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
        transform: none !important;
        will-change: auto !important;
        transition: none !important;
    }
    
    .navbar-nav .dropdown-menu.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
        transform: none !important;
        will-change: auto !important;
    }
    
    /* Ensure dropdown toggle is clickable on mobile */
    .navbar-nav .dropdown-toggle {
        pointer-events: auto !important;
        cursor: pointer !important;
        user-select: none !important;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3) !important;
    }
    
    /* Prevent text selection during dropdown toggle */
    .navbar-nav .dropdown-toggle:active {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }
    
    .navbar-nav .dropdown-item {
        padding: 0.875rem 2.5rem !important;
        font-size: 0.95rem !important;
        color: #FFFFFF !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
    }
    
    .navbar-nav .dropdown-item:last-child {
        border-bottom: none !important;
    }
    
    .navbar-nav .dropdown-item:hover,
    .navbar-nav .dropdown-item:focus {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: #b6862a !important;
    }
    
    /* Language Dropdown - Ensure visibility on mobile */
    #languageDropdown + .dropdown-menu {
        display: none !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    #languageDropdown + .dropdown-menu.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    #languageDropdown + .dropdown-menu .dropdown-item {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Dropdown Toggle Icon - Mobile */
    .navbar-nav .dropdown-toggle::after {
        float: right !important;
        margin-top: 0.5rem !important;
        margin-left: 0.5rem !important;
    }
    
    /* Hero Section */
    .hero-section,
    .page-header {
        height: 60vh !important;
        min-height: 400px !important;
    }
    
    .hero-img {
        height: 60vh !important;
        min-height: 400px !important;
    }
    
    .hero-content {
        padding: 2rem 1rem !important;
    }
    
    .hero-buttons {
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }
    
    .hero-buttons .btn {
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Page Header with carousel */
    .page-header {
        position: relative !important;
        height: 50vh !important;
        min-height: 350px !important;
    }
    
    .page-header .carousel-item img {
        height: 50vh !important;
        min-height: 350px !important;
    }
    
    /* Director section */
    .director-section .row {
        flex-direction: column-reverse !important;
    }
    
    .director-img {
        max-width: 100% !important;
        margin-bottom: 2rem !important;
    }
    
    /* About section images */
    .about-image {
        margin-top: 2rem !important;
    }
    
    .about-content {
        margin-bottom: 2rem !important;
    }
    
    /* Mission cards */
    .mission-card {
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
    }
    
    /* Leader cards */
    .leader-card {
        margin-bottom: 2rem !important;
    }
    
    .leader-image {
        max-width: 150px !important;
        margin: 0 auto 1rem !important;
    }
    
    /* History section */
    .history-content {
        padding: 1.5rem !important;
    }
    
    .history-text {
        font-size: 0.95rem !important;
    }
    
    /* Cards */
    .card {
        margin-bottom: 1.5rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    /* Grid Layouts */
    .row > [class*='col-'] {
        margin-bottom: 1.5rem;
    }
    
    /* Tables - Force horizontal scroll on mobile */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
        width: 100% !important;
        margin-bottom: 1rem !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 0.375rem !important;
    }
    
    .table {
        font-size: 0.85rem !important;
        min-width: 600px !important;
        margin-bottom: 0 !important;
    }
    
    .table th,
    .table td {
        padding: 0.5rem !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
    }
    
    .table thead th {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
    }
    
    /* Ensure all tables are wrapped */
    table:not(.table-responsive table) {
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
    }
    
    /* DataTables responsive */
    .dataTables_wrapper {
        overflow-x: auto !important;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 0.5rem !important;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem !important;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
    }
    
    .form-label {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .btn {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.95rem !important;
    }
    
    /* Footer */
    footer {
        padding: 3rem 0 1.5rem !important;
    }
    
    .footer-heading {
        font-size: 1.1rem !important;
        margin-top: 2rem !important;
        margin-bottom: 1rem !important;
    }
    
    .footer-heading:first-child {
        margin-top: 0 !important;
    }
    
    .footer-links {
        margin-bottom: 1.5rem !important;
    }
    
    .social-icons a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        margin-right: 8px !important;
        margin-bottom: 8px !important;
    }
    
    /* Back to top button */
    .back-to-top {
        width: 45px !important;
        height: 45px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
    
    /* Video player overlay */
    .video-play-overlay {
        width: 50px !important;
        height: 50px !important;
    }
    
    .video-play-overlay i {
        font-size: 20px !important;
    }
    
    /* Director section */
    .director-img {
        margin-bottom: 2rem !important;
        max-width: 100% !important;
    }
    
    /* Quick access cards */
    .quick-link-card .card {
        margin-bottom: 1rem !important;
    }
    
    .quick-link-icon {
        font-size: 2rem !important;
    }
    
    .quick-link-card .card-body h5 {
        font-size: 1rem !important;
    }
    
    /* News cards */
    .news-card {
        margin-bottom: 1.5rem !important;
    }
    
    .news-image img {
        height: 200px !important;
        object-fit: cover !important;
        width: 100% !important;
    }
    
    .news-content {
        padding: 1rem !important;
    }
    
    .news-title {
        font-size: 1.1rem !important;
    }
    
    .news-excerpt {
        font-size: 0.9rem !important;
    }
    
    /* Filter sections */
    .filter-section {
        padding: 1.5rem !important;
    }
    
    .filter-group {
        flex-direction: column !important;
    }
    
    .filter-select {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
    
    /* Stats boxes */
    .stats-box {
        padding: 1.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    .stats-number {
        font-size: 2rem !important;
    }
    
    .stats-label {
        font-size: 0.9rem !important;
    }
    
    /* Page title sections */
    .page-title-section {
        padding: 2rem 0 1rem !important;
    }
    
    .page-title-section h1 {
        font-size: 1.75rem !important;
    }
    
    .page-title-section .lead {
        font-size: 1rem !important;
    }
    
    /* Services pages */
    .step-card {
        margin-bottom: 1.5rem !important;
        padding: 1.5rem !important;
    }
    
    .category-card {
        margin-bottom: 1.5rem !important;
        padding: 1.5rem !important;
    }
    
    .category-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }
    
    /* Contact pages */
    .head-office-card,
    .province-card {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .contact-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .contact-item {
        padding: 1rem !important;
    }
    
    .contact-form-card {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .map-container iframe {
        height: 250px !important;
    }
    
    /* Mine profile pages */
    .mine-card {
        margin-bottom: 1.5rem !important;
        padding: 1.5rem !important;
    }
    
    .stat-card {
        margin-bottom: 1rem !important;
        padding: 1.5rem !important;
    }
    
    .chart-wrapper,
    .chart-container {
        height: 250px !important;
    }
    
    /* Forms and guidelines */
    .form-item {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .guideline-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .category-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .category-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.2rem !important;
    }
    
    /* Events page */
    .event-card {
        margin-bottom: 1.5rem !important;
    }
    
    .event-date {
        width: 60px !important;
        height: 60px !important;
        font-size: 0.85rem !important;
    }
    
    /* Calendar view on mobile */
    .calendar-view {
        padding: 1rem !important;
    }
    
    .calendar {
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 5px !important;
    }
    
    .calendar-day {
        padding: 5px !important;
        font-size: 0.75rem !important;
    }
    
    .calendar-weekday {
        padding: 5px !important;
        font-size: 0.75rem !important;
    }
    
    .calendar-header {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .calendar-header h5 {
        font-size: 1rem !important;
    }
    
    /* View toggle buttons */
    .view-toggle {
        flex-wrap: wrap !important;
    }
    
    .view-toggle .btn {
        flex: 1 1 calc(50% - 5px) !important;
        min-width: calc(50% - 5px) !important;
    }
    
    /* Event actions on mobile */
    .event-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }
    
    .event-actions .btn {
        width: 100% !important;
    }
    
    /* Event card content on mobile */
    .event-card .row {
        margin: 0 !important;
    }
    
    .event-card .col-md-6 {
        padding: 0.25rem 0 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Video gallery */
    .video-card {
        margin-bottom: 1.5rem !important;
    }
    
    .video-thumbnail {
        height: 200px !important;
        object-fit: cover !important;
    }
    
    /* Photo gallery */
    .photo-grid,
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    .photo-item img,
    .gallery-card img {
        height: 200px !important;
        object-fit: cover !important;
        width: 100% !important;
    }
    
    /* Gallery grid responsive */
    .gallery-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Job cards */
    .job-card {
        margin-bottom: 1.5rem !important;
    }
    
    .job-card .card-img-top {
        height: 180px !important;
    }
    
    /* Content submission form */
    .form-section {
        padding: 1.5rem !important;
    }
    
    /* Search boxes */
    .search-box {
        margin-bottom: 1rem !important;
    }
    
    .search-box input {
        padding: 0.75rem !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Carousel controls */
    .carousel-control-prev,
    .carousel-control-next {
        width: 40px !important;
        height: 40px !important;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* CTA sections */
    .cta-section {
        padding: 3rem 1rem !important;
    }
    
    .sticky-cta-btn {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Province cards */
    .provincial-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .province-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .province-name {
        font-size: 1.2rem !important;
    }
    
    /* View map button */
    .view-map-btn {
        width: 100% !important;
        justify-content: center !important;
        margin-top: 1rem !important;
    }
    
    /* Newsletter form */
    .newsletter-form {
        flex-direction: column !important;
    }
    
    .newsletter-form input {
        border-radius: 4px !important;
        margin-bottom: 0.5rem !important;
    }
    
    .newsletter-form button {
        position: static !important;
        width: 100% !important;
        border-radius: 4px !important;
    }
    
    /* Support section */
    .support-section {
        padding: 2rem 1rem !important;
    }
    
    .support-title {
        font-size: 1.5rem !important;
    }
    
    .support-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .support-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }
}

/* ========== TABLET / iPad (768px - 1024px) ========== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Typography */
    .hero-title,
    h1.hero-title,
    .display-4 {
        font-size: 2.25rem !important;
    }
    
    .hero-subtitle,
    .lead {
        font-size: 1.1rem !important;
    }
    
    .section-title,
    h2.section-title {
        font-size: 1.75rem !important;
    }
    
    /* Spacing */
    .section-padding {
        padding: 4rem 0 !important;
    }
    
    /* Navigation */
    .logo-img {
        height: 18px !important;
    }
    
    .site-name {
        font-size: 1.3rem !important;
    }
    
    /* Hero Section */
    .hero-section,
    .page-header {
        height: 70vh !important;
    }
    
    .hero-img {
        height: 70vh !important;
    }
    
    /* Cards - 2 columns on tablet */
    .col-md-6 {
        margin-bottom: 1.5rem;
    }
    
    /* Tables */
    .table {
        font-size: 0.9rem !important;
    }
    
    /* Modals */
    .modal-dialog {
        max-width: 90% !important;
    }
    
    /* Footer */
    footer {
        padding: 4rem 0 2rem !important;
    }
    
    .footer-heading {
        margin-top: 1.5rem !important;
    }
    
    .footer-heading:first-child {
        margin-top: 0 !important;
    }
    
    /* News cards - 2 columns on tablet */
    .news-card {
        margin-bottom: 1.5rem !important;
    }
    
    .news-image img {
        height: 220px !important;
    }
    
    /* Quick access cards */
    .quick-link-card .card {
        height: 100% !important;
    }
    
    /* Photo gallery - 3 columns on tablet */
    .photo-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Video gallery */
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Events grid */
    .events-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Contact grid */
    .contact-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Provincial grid */
    .provincial-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    /* Calendar grid adjustments */
    .calendar {
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 8px !important;
    }
    
    /* Gallery grid adjustments */
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Video grid adjustments */
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Events grid adjustments */
    .events-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Category cards */
    .category-card {
        padding: 2rem !important;
    }
    
    /* Forms and guidelines */
    .form-item {
        padding: 1.25rem !important;
    }
    
    /* Charts */
    .chart-wrapper,
    .chart-container {
        height: 300px !important;
    }
}

/* ========== DESKTOP (1025px+) ========== */
@media (min-width: 1025px) {
    /* Ensure max-width containers on large screens */
    .container {
        max-width: 1200px;
    }
    
    /* Hero Section */
    .hero-section,
    .page-header {
        height: 100vh !important;
    }
    
    .hero-img {
        height: 100vh !important;
    }
}

/* ========== LARGE DESKTOP (1400px+) ========== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ========== ORIENTATION SPECIFIC ========== */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-section,
    .page-header {
        height: 100vh !important;
        min-height: auto !important;
    }
    
    .hero-img {
        height: 100vh !important;
        min-height: auto !important;
    }
}

/* ========== ADDITIONAL RESPONSIVE FIXES ========== */

/* Ensure all images are responsive */
img:not([width]):not([height]),
img.img-fluid,
.about-image,
.director-img,
.leader-image,
.news-image img,
.photo-item img,
.video-thumbnail,
.card-img-top,
.hero-img {
    max-width: 100% !important;
    height: auto !important;
}

/* Fixed height images should use object-fit */
img[style*="height"],
.card-img-top,
.news-image img,
.photo-item img {
    object-fit: cover !important;
}

/* Ensure videos are responsive */
video,
.ratio {
    max-width: 100% !important;
}

/* Ensure iframes are responsive */
iframe {
    max-width: 100% !important;
    width: 100% !important;
}

/* Form responsiveness */
.form-row {
    flex-direction: column !important;
}

.form-row > * {
    width: 100% !important;
    margin-bottom: 1rem !important;
}

/* Button groups on mobile */
.btn-group {
    flex-direction: column !important;
    width: 100% !important;
}

.btn-group .btn {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
}

/* Ensure all inputs are touch-friendly on mobile */
/* BUT exclude icons from this rule */
input:not(i):not([class*="fa-"]),
textarea:not(i):not([class*="fa-"]),
select:not(i):not([class*="fa-"]) {
    min-height: 44px !important; /* Apple's recommended touch target size */
}

/* Ensure icons are NEVER affected by input styles */
i.fas, i.far, i.fab, i.fal, i.fad, i.fa,
i[class*="fa-"],
[class*="fa-"] {
    min-height: auto !important;
    height: auto !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* Modal improvements for mobile */
@media (max-width: 767px) {
    .modal-fullscreen,
    .modal-xl,
    .modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        max-width: calc(100% - 1rem) !important;
        margin: 0.5rem auto !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 200px) !important;
        overflow-y: auto !important;
        padding: 1rem !important;
    }
    
    .modal-header {
        padding: 1rem !important;
    }
    
    .modal-header h5 {
        font-size: 1.1rem !important;
    }
    
    .modal-footer {
        padding: 1rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Video modals */
    .modal-body .ratio {
        margin-bottom: 1rem !important;
    }
    
    /* Keep video aspect ratio within ratio containers */
    .modal-body .ratio video,
    .ratio video {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }
    
    /* Ensure youtube player also fits properly */
    .modal-body .ratio #youtube-player,
    .ratio #youtube-player {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Modal tables */
    .modal-body .table-responsive {
        margin: -1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Fix carousel on mobile */
@media (max-width: 767px) {
    .carousel {
        touch-action: pan-y !important;
    }
    
    .carousel-inner {
        min-height: 300px !important;
    }
}

/* Fix DataTables on mobile */
@media (max-width: 767px) {
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        margin-bottom: 1rem !important;
    }
    
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
    }
}

/* Fix charts on mobile */
@media (max-width: 767px) {
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
    
    .chart-container,
    .chart-wrapper {
        width: 100% !important;
        overflow-x: auto !important;
    }
    
    .chart-container canvas,
    .chart-wrapper canvas {
        max-width: 100% !important;
        height: 250px !important;
    }
}

/* List view responsive fixes */
@media (max-width: 767px) {
    .gallery-grid.list-view .gallery-card {
        flex-direction: column !important;
        height: auto !important;
    }
    
    .gallery-grid.list-view .gallery-card .card-img-top {
        width: 100% !important;
        height: 200px !important;
    }
    
    .list-view .video-thumbnail {
        width: 100% !important;
    }
    
    .list-view .video-thumbnail img {
        height: 200px !important;
        object-fit: cover !important;
    }
    
    .list-view .video-details {
        padding: 1rem !important;
    }
}

/* ========== ADDITIONAL MOBILE FIXES ========== */

/* Fix overflow issues on mobile */
@media (max-width: 767px) {
    /* Ensure containers don't overflow */
    .container,
    .container-fluid {
        overflow-x: hidden !important;
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix flex containers */
    .d-flex {
        flex-wrap: wrap !important;
    }
    
    /* Fix justify-content on mobile */
    .justify-content-between {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    /* Fix align-items on mobile */
    .align-items-center {
        align-items: flex-start !important;
    }
    
    /* Fix text alignment */
    .text-center {
        text-align: center !important;
    }
    
    .text-md-start {
        text-align: center !important;
    }
    
    .text-md-end {
        text-align: center !important;
    }
    
    /* Fix buttons in rows */
    .row .btn {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Fix card footers */
    .card-footer {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .card-footer .btn {
        width: 100% !important;
    }
    
    /* Fix application modal form */
    .application-modal .modal-body .row {
        margin: 0 !important;
    }
    
    .application-modal .col-md-6 {
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 1rem !important;
    }
    
    /* Fix progress bar container */
    .progress-bar-container {
        margin-bottom: 1.5rem !important;
    }
    
    /* Fix step navigation */
    .step-nav {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    /* Fix resource items */
    .resource-item {
        padding: 1rem !important;
    }
    
    /* Fix category headers */
    .category-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    
    /* Fix mine headers */
    .mine-header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .mine-icon {
        margin-bottom: 1rem !important;
        margin-right: 0 !important;
    }
    
    /* Fix contact cards */
    .contact-card {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Fix filter cards */
    .filter-card {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Fix CTA sections */
    .cta-section {
        padding: 2rem 1rem !important;
    }
    
    .cta-title {
        font-size: 1.5rem !important;
    }
    
    .cta-description {
        font-size: 1rem !important;
    }
    
    .cta-button {
        width: 100% !important;
        padding: 0.75rem !important;
    }
    
    /* Fix sticky CTA */
    .sticky-cta {
        flex-direction: column !important;
        padding: 1rem !important;
    }
    
    .sticky-cta-content {
        text-align: center !important;
        margin-bottom: 1rem !important;
    }
    
    .sticky-cta-btn {
        width: 100% !important;
    }
    
    /* Fix page headers with absolute positioning */
    .page-header .container {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        padding: 2rem 1rem !important;
    }
    
    /* Fix carousel captions */
    .carousel-caption {
        padding: 1rem !important;
        bottom: 0 !important;
    }
    
    .carousel-caption h1 {
        font-size: 1.5rem !important;
    }
    
    .carousel-caption p {
        font-size: 0.9rem !important;
    }
    
    /* Fix dropdowns on mobile */
    .dropdown-toggle::after {
        margin-left: 0.5rem !important;
    }
    
    /* Performance optimizations for mobile */
    .navbar-nav,
    .navbar-nav .nav-item {
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
    }
    
    /* Optimize dropdown menu rendering */
    .navbar-nav .dropdown-menu {
        will-change: auto !important;
        transform: none !important;
    }
    
    /* Optimize scrolling in navbar collapse */
    .navbar-collapse {
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        contain: layout style paint !important;
    }
    
    /* Fix navbar collapse */
    .navbar-collapse {
        padding: 1rem 0 !important;
    }
    
    /* Fix navbar toggler - Additional mobile styles */
    .navbar-toggler {
        border: 2px solid #FFFFFF !important;
        border-radius: 4px !important;
        padding: 0.4rem 0.6rem !important;
        background-color: #FFFFFF !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
    }
    
    .navbar-toggler:hover {
        background-color: #f0f0f0 !important;
        border-color: #FFFFFF !important;
    }
    
    .navbar-toggler:active {
        background-color: #e0e0e0 !important;
    }
    
    .navbar-toggler-icon {
        width: 24px !important;
        height: 24px !important;
        background-size: 24px 24px !important;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(59, 130, 246, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    }
    
    /* Fix language switcher */
    .language-switcher-basic {
        margin: 0 !important;
        width: 100% !important;
    }
    
    .language-switcher-basic .dropdown-toggle {
        width: 100% !important;
        text-align: left !important;
        padding: 1rem 1.5rem !important;
    }
    
    .language-switcher-basic .dropdown-menu {
        width: 100% !important;
        position: static !important;
        margin: 0 !important;
        border: none !important;
        background-color: rgba(30, 64, 175, 0.3) !important;
    }
    
    /* Fix social icons */
    .social-icons {
        margin-top: 1rem !important;
    }
    
    .social-icons a {
        margin-bottom: 0.5rem !important;
    }
}

/* ========== TABLET FIXES ========== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Fix two-column layouts on tablet */
    .col-md-6 {
        margin-bottom: 1.5rem;
    }
    
    /* Fix three-column layouts */
    .col-lg-4 {
        margin-bottom: 1.5rem;
    }
    
    /* Fix card layouts */
    .card {
        height: auto !important;
    }
    
    /* Fix gallery grids */
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Fix video grids */
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Fix event grids */
    .events-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Fix provincial grid */
    .provincial-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Fix contact grid */
    .contact-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Fix forms */
    .form-row .col-md-6 {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
}

/* PRINT STYLES */
@media print {
    .navbar,
    footer,
    .back-to-top,
    .btn,
    .modal,
    .carousel-control-prev,
    .carousel-control-next {
        display: none !important;
    }
    
    body {
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
    
    .section-padding {
        padding: 1rem 0 !important;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid !important;
    }
    
    .card,
    .news-card,
    .mine-card {
        page-break-inside: avoid !important;
    }
    
    .table-responsive {
        overflow: visible !important;
    }
    
    .table {
        min-width: auto !important;
    }
}

