/* ===================================================
   ALFA TECH GROUP — Responsive Styles
   =================================================== */

/* --- Large desktop (1280px+) handled in main.css --- */

/* --- Medium desktop (1024px - 1279px) --- */
@media (max-width: 1279px) {
    .container { padding: 0 1.25rem; }
    .footer-grid { grid-template-columns: 1.2fr repeat(2, 1fr); gap: 2rem; }
}

/* --- Tablet landscape (768px - 1023px) --- */
@media (max-width: 1023px) {
    .navbar-menu { display: none; }
    .hamburger { display: flex; }

    /* Hide desktop pickers — they live inside the mobile menu instead */
    .navbar-actions .lang-picker,
    .navbar-actions .theme-picker,
    .navbar-actions > a.btn,
    .admin-logout-form { display: none; }   /* admin logout — lives in hamburger menu on mobile */

    /* Admin navbar: hide username text on mobile */
    .admin-navbar-user { display: none; }

    /* Admin sidebar: hidden off-canvas on mobile, toggled by hamburger */
    .admin-sidebar { display: none; }
    .admin-sidebar.open { display: flex; flex-direction: column; }

    /* Mobile menu */
    .mobile-nav {
        display: none;
        position: fixed;
        top: 68px; left: 0; right: 0; bottom: 0;
        background: var(--bg-primary);
        z-index: 999;
        overflow-y: auto;
        padding: 1rem 1.25rem 2rem;
        flex-direction: column;
        gap: 0.25rem;
        border-top: 1px solid var(--border);
    }
    .mobile-nav.open { display: flex; }
    .mobile-nav a {
        display: flex;
        align-items: center;
        padding: 0.85rem 1rem;
        border-radius: var(--radius-md);
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-secondary);
        border-bottom: 1px solid var(--border);
        gap: 0.5rem;
    }
    .mobile-nav a:hover, .mobile-nav a.active {
        color: var(--accent);
        background: var(--accent-glow);
    }
    .mobile-nav-section {
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        color: var(--text-muted);
        padding: 0.5rem 1rem 0.25rem;
        font-weight: 700;
    }
    .mobile-nav > .mobile-nav-section:first-child {
        padding-top: 0;
    }

    /* Language grid inside mobile menu */
    .mobile-lang-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.4rem;
        padding: 0.25rem 0 0.5rem;
    }
    .mobile-lang-item {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        gap: 0.2rem;
        padding: 0.5rem 0.25rem !important;
        border-radius: var(--radius-md);
        border-bottom: none !important;
        background: var(--bg-secondary);
        font-size: 0.75rem !important;
        font-weight: 500 !important;
        color: var(--text-muted) !important;
        text-align: center;
        transition: background 0.15s, color 0.15s;
    }
    .mobile-lang-item.active,
    .mobile-lang-item:hover {
        background: var(--accent-glow) !important;
        color: var(--accent) !important;
    }
    .mobile-lang-flag { font-size: 1.3rem; line-height: 1; }
    .mobile-lang-label { font-size: 0.68rem; }

    /* Theme row — single row, swatch + one letter */
    .mobile-theme-row {
        display: flex;
        gap: 0.4rem;
        padding: 0.25rem 0 0.5rem;
    }
    .mobile-theme-item {
        display: flex !important;
        flex: 1;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        padding: 0.45rem 0.2rem;
        border-radius: var(--radius-md);
        background: var(--bg-secondary);
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-secondary);
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
        border: 1px solid transparent;
        white-space: nowrap;
    }
    .mobile-theme-item.active,
    .mobile-theme-item:hover {
        background: var(--accent-glow);
        color: var(--accent);
        border-color: var(--accent);
    }

    /* Extra — collapsible toggle button */
    .mobile-extra-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: none;
        border: none;
        border-bottom: 1px solid var(--border);
        border-radius: var(--radius-md);
        cursor: pointer;
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-secondary);
        padding: 0.85rem 1rem;
        font-family: inherit;
        letter-spacing: normal;
    }
    .mobile-extra-toggle:hover { color: var(--accent); background: var(--accent-glow); }
    .mobile-extra-chevron {
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }
    .mobile-extra-toggle[aria-expanded="true"] .mobile-extra-chevron {
        transform: rotate(180deg);
    }
    .mobile-extra-links { display: flex; flex-direction: column; gap: 0.25rem; }
    .mobile-extra-links[hidden] { display: none; }

    /* Account — pinned to bottom */
    .mobile-nav-bottom {
        margin-top: auto;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Grid adjustments */
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .hosting-plans-grid { grid-template-columns: repeat(2, 1fr); }

    /* Hero */
    .hero { min-height: 80vh; padding: 4rem 0; }
    .hero-title { font-size: clamp(2rem, 5vw, 3.5rem); }

    /* Admin */
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
}

/* --- Mobile hero text alignment --- */
@media (max-width: 1023px) {
    .hero-content .hero-badge   { display: inline-flex; }
    .hero-content               { text-align: center; }
    .hero-content .hero-badge,
    .hero-content .hero-actions { justify-content: center; }
    .hero-content .hero-subtitle { text-align: center; }
}

/* --- Tablet portrait (640px - 767px) --- */
@media (max-width: 767px) {
    .section { padding: 3.5rem 0; }
    .section-lg { padding: 5rem 0; }

    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
    .footer-brand { grid-column: 1 / -1; }

    .hero { min-height: unset; padding: 3rem 0; }
    .hero-badge { font-size: 0.75rem; }
    .hero-actions { flex-direction: column; align-items: center; }
    .hero-actions .btn { width: auto; min-width: 200px; }

    .plan-card { padding: 1.5rem; }
    .hosting-plans-grid { grid-template-columns: 1fr; }
    .theme-grid { grid-template-columns: repeat(2, 1fr); }

    .auth-card { padding: 2rem 1.5rem; }
    .maintenance-content { padding: 0 0.5rem; }

    /* Admin */
    .admin-main { padding: 0.6rem; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .admin-header { flex-direction: column; align-items: flex-start; gap: 0.6rem; }

    /* Tables — let the wrapping card scroll horizontally so wide tables
       (visitors, benchmark results, etc.) stay usable. Keeping the
       <table> as display:table preserves proper column sizing — the
       previous display:block hack broke layout on the visitors page
       and left columns clipped off-screen. */
    .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { width: 100%; min-width: max-content; }
}

/* --- Mobile (< 640px) --- */
@media (max-width: 639px) {
    html { font-size: 15px; }
    .container { padding: 0 1rem; }

    .navbar-logo-text { font-size: 1.05rem; }
    .navbar-actions .lang-picker-btn span:not(.flag) { display: none; }

    .grid-4 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
    .footer-bottom { flex-direction: column; text-align: center; }

    .hero-title { font-size: clamp(1.8rem, 8vw, 2.5rem); }

    .section-header { margin-bottom: 2rem; }

    .countdown { gap: 1rem; }
    .countdown-val { font-size: clamp(1.8rem, 8vw, 2.5rem); }

    .stat-cards { grid-template-columns: 1fr; }
    .theme-grid { grid-template-columns: repeat(2, 1fr); }

    .btn-lg { padding: 0.85rem 1.75rem; font-size: 0.95rem; }

    /* Fix contact form */
    .contact-grid { grid-template-columns: 1fr; }
}

/* --- Very small screens (< 375px) --- */
@media (max-width: 374px) {
    .countdown { gap: 0.5rem; }
    .countdown-sep { display: none; }
    .auth-card { padding: 1.5rem 1rem; }
}

/* --- Print --- */
@media print {
    .navbar, .footer, .hamburger, .theme-picker-btn, .lang-picker, .hero-bg, .hero-grid-overlay { display: none !important; }
    body { background: white; color: black; }
    main { padding-top: 0; }
    a { color: black; text-decoration: underline; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    [data-reveal] { opacity: 1; transform: none; }

    /* Keep the maintenance dots animated — they're functional, not decorative */
    .maintenance-dots span {
        animation-duration: 1.4s !important;
        animation-iteration-count: infinite !important;
    }
}

/* --- High contrast --- */
@media (forced-colors: active) {
    .btn-primary { forced-color-adjust: none; }
    .card, .plan-card { border: 2px solid ButtonText; }
}

/* --- Landscape mobile fix --- */
@media (max-width: 767px) and (orientation: landscape) {
    .hero { min-height: unset; }
    .maintenance-wrap { padding: 1rem; }
    .auth-wrap { align-items: flex-start; padding-top: 1rem; }
}
