/* ============ MOBILE-FIRST RESPONSIVE STYLES ============ */

/* ============ BASE MOBILE (up to 575px) ============ */
@media (max-width: 575px) {
    :root {
        --container-padding: 1rem;
        --section-padding: 3rem 0;
        --hero-height: 280px;
        --font-scale: 0.9;
    }

    .hero-slide { height: var(--hero-height); }
    .hero-content h1 { font-size: 1.4rem; }
    .hero-content p { font-size: 0.9rem; }
    .hero-buttons { flex-direction: column; gap: 8px; }
    .btn { padding: 12px 20px; font-size: 0.9rem; min-width: 100%; }

    .top-bar { font-size: 0.75rem; padding: 4px 0; }
    .top-bar-left, .top-bar-right { text-align: center !important; }
    .top-bar-left span { display: block; margin-bottom: 2px; }
    .social-links-top { margin-top: 5px; justify-content: center; }
    .theme-dropdown { min-width: 180px; right: -100px; }

    .navbar-brand .brand-text h1 { font-size: 0.9rem; }
    .brand-icon { width: 36px; height: 36px; font-size: 1rem; }
    .brand-text span { font-size: 0.7rem; }

    .welcome-card { padding: 1.5rem; }
    .welcome-img { flex: 0 0 100px; }
    .welcome-img img { width: 100px; height: 100px; }

    .section-title h2 { font-size: 1.5rem; }
    .section-padding { padding: 40px 0; }

    .highlight-card { padding: 20px 15px; }
    .highlight-icon { width: 60px; height: 60px; font-size: 1.5rem; }

    .counter-box .count { font-size: 1.8rem; }
    .counter-box i { font-size: 2rem; }

    .gallery-item img { height: 140px; }
    .gallery-overlay { padding: 10px; }

    .event-card .event-img { height: 160px; }
    .event-date-badge { padding: 4px 8px; }
    .event-date-badge .day { font-size: 1.1rem; }

    .staff-photo { width: 120px; height: 150px; }
    .staff-info h4 { font-size: 1rem; }

    .notice-item { padding: 10px; }
    .notice-item h5 { font-size: 0.9rem; }

    .faq-question { padding: 12px 16px; font-size: 0.85rem; }
    .faq-answer { padding: 0 16px 12px; font-size: 0.85rem; }

    .footer-social { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
    .footer-social a { width: 36px; height: 36px; font-size: 1rem; }

    .whatsapp-float { width: 50px; height: 50px; font-size: 1.5rem; bottom: 15px; right: 15px; }
    .back-to-top { right: 75px; width: 40px; height: 40px; bottom: 15px; }

    .visitor-counter { font-size: 0.7rem; padding: 4px 8px; }

    .theme-panel { width: 95vw; right: 0.5rem; top: 0.5rem; bottom: 0.5rem; padding: 1rem; }
    .theme-gear-wrapper { bottom: 1rem; left: 1rem; }
    .theme-gear-btn { width: 3rem; height: 3rem; }
}

/* ============ SMALL DEVICES (576px - 767px) ============ */
@media (min-width: 576px) and (max-width: 767px) {
    :root { --hero-height: 320px; --font-scale: 0.95; }
    .hero-slide { height: var(--hero-height); }
    .hero-content h1 { font-size: 1.6rem; }
    .hero-content p { font-size: 0.95rem; }
    .top-bar-left span { display: inline-block; margin-right: 12px; }
    .social-links-top { margin-top: 5px; }
    .theme-dropdown { min-width: 200px; right: -80px; }
}

/* ============ MEDIUM DEVICES (768px - 991px) ============ */
@media (min-width: 768px) and (max-width: 991px) {
    :root { --hero-height: 380px; }
    .hero-slide { height: var(--hero-height); }
    .hero-content h1 { font-size: 2rem; }

    .top-bar-left span { display: block; margin-bottom: 3px; margin-right: 0; }
    .top-bar-right { text-align: left !important; margin-top: 5px; }
    .brand-text h1 { font-size: 1.1rem; }
    .brand-text span { font-size: 0.6rem; }
    .brand-icon { width: 40px; height: 40px; font-size: 1.1rem; }

    .nav-menu { flex-direction: column; width: 100%; }
    .nav-item > a { padding: 10px 15px; border-bottom: none; }
    .nav-item .nav-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; background: transparent; padding-left: 1rem; }
    .nav-search { margin-top: 10px; width: 100%; }
    .nav-search .form-control { width: 100%; }

    .welcome-section { margin-top: -30px; }
    .welcome-card { flex-direction: column; text-align: center; }
    .counter-section .counter-box { margin-bottom: 20px; }
    .footer-widget { margin-bottom: 30px; }

    .admin-sidebar { width: 220px; }
    .admin-main { margin-left: 220px; }
    .about-intro { flex-direction: column; }
    .hero-owl .owl-nav .owl-prev { left: 10px; }
    .hero-owl .owl-nav .owl-next { right: 10px; }
    .hero-owl .owl-nav button { width: 40px; height: 40px; font-size: 1rem; }
}

/* ============ LARGE DEVICES (992px - 1199px) ============ */
@media (min-width: 992px) and (max-width: 1199px) {
    :root { --hero-height: 450px; }
    .hero-slide { height: var(--hero-height); }
    .hero-content h1 { font-size: 2.5rem; }
    .welcome-card { padding: 30px; }
    .welcome-img { flex: 0 0 150px; }
    .welcome-img img { width: 150px; height: 150px; }
}

/* ============ EXTRA LARGE (1200px+) ============ */
@media (min-width: 1200px) {
    :root { --hero-height: 500px; --container-padding: 1.5rem; }
    .hero-slide { height: var(--hero-height); }
    .container { max-width: 1280px; }
}

/* ============ TOUCH TARGETS (mobile) ============ */
@media (hover: none) and (pointer: coarse) {
    .btn, .nav-link, .dropdown-item, .theme-preset-link,
    .theme-color-row input[type="color"],
    .pagination .page-link,
    .social-links-top a,
    .top-bar-actions a,
    .footer-links a,
    .nav-item > a,
    .sidebar-toggler,
    .theme-gear-btn,
    .theme-gear-close,
    .theme-panel-close,
    .theme-reset-btn {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }

    .dropdown-menu { padding: 0.5rem; }
    .dropdown-item { padding: 12px 16px; font-size: 1rem; }
    .theme-preset-link { padding: 12px; }
    .theme-color-row { padding: 1rem; }
    .theme-color-row input[type="color"] { width: 3rem; height: 3rem; }

    /* Remove hover effects that don't work on touch */
    .highlight-card:hover,
    .counter-box:hover,
    .event-card:hover,
    .staff-card:hover,
    .gallery-item:hover,
    .testimonial-card:hover,
    .btn:hover,
    .nav-link:hover {
        transform: none;
        box-shadow: var(--shadow);
    }

    /* Active state for touch feedback */
    .btn:active, .nav-link:active, .dropdown-item:active,
    .theme-preset-link:active, .highlight-card:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

/* ============ TABLET SPECIFIC ============ */
@media (min-width: 768px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
    .admin-sidebar { width: 260px; transform: translateX(-100%); }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 1rem; }
    .admin-topbar { padding: 12px 15px; }
}

/* ============ ORIENTATION ============ */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-slide { height: 100vh; min-height: 300px; }
    .hero-content { padding-top: 2rem; }
    .theme-panel { top: 0.25rem; bottom: 0.25rem; }
}

/* ============ PRINT ============ */
@media print {
    .top-bar, #mainNav, .site-footer, .whatsapp-float, .back-to-top, .visitor-counter,
    .nav-search, .theme-gear-wrapper, .theme-panel-overlay, .theme-panel,
    .admin-sidebar, .admin-topbar, .sidebar-toggler,
    .btn-primary, .btn-secondary, .btn-outline,
    .alert .btn-close, .modal .btn-close { display: none !important; }

    .admin-main { margin-left: 0 !important; }
    body { font-size: 12pt; color: #000; background: #fff; }
    a { text-decoration: underline; color: #000 !important; }
    .page-header { background: #f0f0f0 !important; color: #000 !important; -webkit-print-color-adjust: exact; }
    .card, .admin-card { border: 1px solid #ddd !important; box-shadow: none !important; break-inside: avoid; }
    .table { border-collapse: collapse; }
    .table th, .table td { border: 1px solid #ddd !important; }
}

/* ============ ACCESSIBILITY ============ */
@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;
    }
    .owl-carousel .owl-item { transition: none !important; }
}

:focus-visible {
    outline: 3px solid var(--theme-primary, #2563eb) !important;
    outline-offset: 2px !important;
}

/* Skip to main content link */
.skip-link {
    position: absolute; top: -100%; left: 50%; transform: translateX(-50%);
    background: var(--theme-primary, #2563eb); color: #fff; padding: 12px 24px;
    border-radius: 8px; z-index: 10000; font-weight: 600;
}
.skip-link:focus { top: 10px; }

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --theme-primary: #0066ff;
        --theme-accent: #cc0000;
        --theme-text: #000;
        --theme-bg: #fff;
        --theme-border: #000;
    }
    .theme-dark { --theme-text: #fff; --theme-bg: #000; --theme-border: #fff; }
}

/* Dark mode media query (system) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --theme-bg: #0f172a;
        --theme-text: #f8fafc;
    }
}

/* ============ UTILITY CLASSES ============ */
.text-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.text-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.touch-target { min-height: 44px; min-width: 44px; }
.touch-target-lg { min-height: 48px; min-width: 48px; }

.safe-top { padding-top: env(safe-area-inset-top, 0); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.safe-left { padding-left: env(safe-area-inset-left, 0); }
.safe-right { padding-right: env(safe-area-inset-right, 0); }

/* Loading states */
.loading { opacity: 0.6; pointer-events: none; position: relative; }
.loading::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 24px; height: 24px; border: 3px solid var(--theme-border); border-top-color: var(--theme-primary);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* Offline indicator */
body.offline::before {
    content: '📴 Offline - Some features unavailable';
    position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
    background: #dc2626; color: #fff; text-align: center; padding: 8px;
    font-size: 0.8rem; font-weight: 600; animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }