/* ==================================================
   ENHANCED RESPONSIVE DESIGN
   ================================================== */

/* ===== Large Desktop (1400px+) ===== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ===== Desktop (1200px - 1399px) ===== */
@media (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
}

/* ===== Large Tablet / Small Desktop (992px - 1199px) ===== */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    /* Adjust grid layouts */
    .plans-grid,
    .register-plan-grid,
    .about-panels,
    .features-grid,
    .testimonials-grid,
    .benefits-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .benefits-card--wide {
        grid-column: span 2;
    }
    
    /* Navigation adjustments */
    .nav-container {
        width: calc(100% - 32px);
        padding: var(--space-4) var(--space-6);
    }
    
    .nav-links {
        gap: var(--space-4);
    }
    
    /* Form layout */
    .register-form-shell {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .register-insights {
        order: -1;
    }
}

/* ===== Tablet (768px - 991px) ===== */
@media (max-width: 991px) {
    :root {
        --text-hero: 3.5rem;
        --text-h1: 2.2rem;
        --text-h2: 1.6rem;
        --text-large: 1.1rem;
        --space-6: 28px;
        --space-7: 40px;
        --space-8: 56px;
        --space-9: 72px;
    }
    
    .container {
        max-width: 720px;
        padding: 0 var(--space-5);
    }
    
    main {
        padding-top: 140px;
    }
    
    /* Header / Navigation */
    .primary-header {
        padding-top: var(--space-5);
    }
    
    .nav-container {
        gap: var(--space-4);
        padding: var(--space-4) var(--space-5);
    }
    
    .nav {
        gap: var(--space-3);
    }
    
    .nav-logo {
        font-size: var(--text-body);
    }
    
    .search-box {
        width: 240px;
    }
    
    .search-box:focus {
        width: 280px;
    }
    
    /* Mobile navigation toggle */
    .nav-toggle {
        display: flex;
    }
    
    .main-nav {
        position: absolute;
        top: calc(100% + var(--space-3));
        left: 0;
        right: 0;
        background: linear-gradient(145deg, rgba(9, 14, 34, 0.98), rgba(13, 18, 46, 0.95));
        border-radius: var(--radius-4);
        border: 1px solid rgba(255, 255, 255, 0.08);
        padding: var(--space-5);
        display: grid;
        gap: var(--space-3);
        opacity: 0;
        pointer-events: none;
        transform: translateY(-10px);
        transition: opacity var(--duration-normal) var(--ease-smooth), 
                    transform var(--duration-normal) var(--ease-smooth);
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
    }
    
    .nav-links {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
        width: 100%;
    }
    
    .nav-link {
        width: 100%;
        padding: var(--space-3);
        display: block;
    }
    
    .header-cta {
        flex-direction: column;
        width: 100%;
        gap: var(--space-3);
    }
    
    .nav-cta {
        width: 100%;
        justify-content: center;
    }
    
    .search-container {
        width: 100%;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box:focus {
        width: 100%;
    }
    
    /* Hero section */
    .hero {
        min-height: 70vh;
        padding: var(--space-7) var(--space-4);
    }
    
    .hero-logo {
        width: clamp(100px, 12vw, 150px);
    }
    
    /* Grid layouts */
    .about-panels,
    .features-grid,
    .testimonials-grid,
    .stats-grid,
    .benefits-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-4);
    }
    
    .plans-grid,
    .register-plan-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-4);
    }
    
    /* Cards */
    .about-card,
    .feature-card,
    .testimonial-card,
    .stat-card {
        padding: var(--space-5);
    }
    
    .plan-card {
        padding: var(--space-5);
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-4);
    }
}

/* ===== Mobile Large (576px - 767px) ===== */
@media (max-width: 767px) {
    :root {
        --text-hero: 2.8rem;
        --text-h1: 1.9rem;
        --text-h2: 1.5rem;
        --text-large: 1.05rem;
        --space-5: 20px;
        --space-6: 24px;
        --space-7: 36px;
        --space-8: 48px;
        --space-9: 64px;
    }
    
    .container {
        padding: 0 var(--space-4);
    }
    
    main {
        padding-top: 120px;
    }
    
    /* Header */
    .primary-header {
        padding-top: var(--space-4);
    }
    
    .nav-container {
        width: calc(100% - 24px);
        padding: var(--space-3) var(--space-4);
        gap: var(--space-3);
    }
    
    /* Hero section */
    .hero {
        height: auto;
        min-height: 70vh;
        padding: var(--space-6) var(--space-4);
        justify-content: center;
        padding-top: var(--space-8);
        text-align: center;
    }
    
    .hero-inner {
        align-items: center;
        text-align: center;
    }
    
    .hero-logo {
        width: clamp(90px, 20vw, 130px);
        margin-bottom: var(--space-4);
    }
    
    .hero-title {
        font-size: clamp(2rem, 8vw, 2.8rem);
        text-align: center;
    }
    
    .hero-subtitle {
        text-align: center;
        font-size: var(--text-body);
    }
    
    .hero-search__form {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    
    .hero-search .search-box,
    .hero-search__submit {
        width: 100%;
    }
    
    /* Section headers */
    .about-headline,
    .benefits-header,
    .user-section__header {
        text-align: center;
        margin-bottom: var(--space-5);
    }
    
    .about-title,
    .about-summary,
    .section-title,
    .section-subtitle {
        text-align: center;
    }
    
    /* All grid layouts go single column */
    .plans-grid,
    .register-plan-grid,
    .about-panels,
    .features-grid,
    .testimonials-grid,
    .stats-grid,
    .benefits-grid,
    .user-panels {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .benefits-card--wide {
        grid-column: span 1;
        text-align: center;
    }
    
    /* Cards */
    .about-card,
    .feature-card,
    .stat-card,
    .testimonial-card,
    .plan-card,
    .benefits-card,
    .user-card {
        padding: var(--space-4);
        text-align: center;
    }
    
    .about-card ul,
    .about-card ol,
    .plan-card ul,
    .plan-card ol,
    .benefits-card ul,
    .benefits-card ol,
    .user-card ul,
    .user-card ol {
        text-align: left;
    }
    
    .plan-badge {
        top: -12px;
        right: var(--space-3);
        padding: var(--space-1) var(--space-3);
        font-size: 0.75rem;
    }
    
    /* Forms */
    .register-form {
        padding: var(--space-5) var(--space-4);
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .form-field {
        margin-bottom: var(--space-3);
    }
    
    /* Buttons */
    .app-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .app-button,
    .cta-button,
    .plan-button,
    .register-submit {
        width: 100%;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .footer-brand {
        text-align: center;
    }
    
    .footer-links {
        text-align: center;
    }
    
    /* AI Assistant */
    .ai-assistant {
        width: 56px;
        height: 56px;
        bottom: var(--space-4);
        right: var(--space-4);
        font-size: 1.3rem;
    }
    
    /* Disable complex hover effects on mobile */
    .about-card:hover,
    .feature-card:hover,
    .plan-card:hover,
    .testimonial-card:hover,
    .stat-card:hover,
    .benefits-card:hover,
    .user-card:hover {
        transform: none;
    }
}

/* ===== Mobile Small (320px - 575px) ===== */
@media (max-width: 575px) {
    :root {
        --text-hero: 2.2rem;
        --text-h1: 1.6rem;
        --text-h2: 1.3rem;
        --text-large: 1rem;
        --text-body: 0.95rem;
        --space-4: 14px;
        --space-5: 18px;
        --space-6: 22px;
        --space-7: 32px;
        --space-8: 42px;
        --space-9: 56px;
    }
    
    .container {
        padding: 0 var(--space-3);
    }
    
    /* Header */
    .nav-container {
        width: calc(100% - 16px);
        padding: var(--space-3);
    }
    
    .nav-logo {
        font-size: 0.85rem;
        letter-spacing: 0.2em;
    }
    
    .nav-toggle {
        width: 40px;
        height: 40px;
        align-items: center;
        padding: 0;
    }
    
    .nav-toggle-bar {
        margin: 0 auto;
    }
    
    /* Hero */
    .hero {
        min-height: 70vh;
        padding: var(--space-5) var(--space-3);
        padding-top: var(--space-7);
    }
    
    .hero-logo {
        width: clamp(80px, 22vw, 110px);
    }
    
    .hero-title {
        font-size: clamp(1.8rem, 7vw, 2.2rem);
        margin-bottom: var(--space-3);
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
    
    /* Cards and sections */
    .about-card,
    .feature-card,
    .stat-card,
    .testimonial-card,
    .plan-card,
    .benefits-card,
    .user-card {
        padding: var(--space-4) var(--space-3);
    }
    
    /* Stats */
    .stat-number {
        font-size: 2rem;
    }
    
    /* Plans */
    .plan-name {
        font-size: 1.5rem;
    }
    
    .plan-price {
        font-size: 1.8rem;
    }
    
    /* Forms */
    .register-form {
        padding: var(--space-4) var(--space-3);
    }
    
    .form-field input,
    .form-field select,
    .form-field textarea {
        padding: var(--space-3);
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn,
    .nav-cta,
    .cta-button,
    .plan-button {
        padding: var(--space-3) var(--space-4);
        font-size: 0.9rem;
    }
    
    /* AI Assistant */
    .ai-assistant {
        width: 52px;
        height: 52px;
        bottom: var(--space-3);
        right: var(--space-3);
        font-size: 1.2rem;
    }
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn,
    .nav-link,
    .nav-cta,
    .plan-button,
    .app-button {
        min-height: 44px;
        padding: var(--space-3) var(--space-5);
    }
    
    .nav-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Disable hover effects on touch devices */
    .about-card:hover::before,
    .user-card:hover::before,
    .card:hover::before {
        transform: none;
    }
    
    .plan-card:hover {
        animation: none;
    }
    
    /* Simplify interactions */
    .nav-link::after {
        display: none;
    }
}

/* ===== Landscape Mobile (max-height: 600px) ===== */
@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        min-height: 70vh;
        padding: var(--space-5) var(--space-4);
    }
    
    .hero-logo {
        width: clamp(60px, 10vh, 100px);
        margin-bottom: var(--space-3);
    }
    
    .hero-title {
        font-size: clamp(1.8rem, 6vh, 2.5rem);
    }
    
    main {
        padding-top: 100px;
    }
}

/* ===== Print Styles ===== */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    .primary-header,
    .nav-toggle,
    .ai-assistant,
    .particles,
    .cosmic-bg {
        display: none !important;
    }
    
    main {
        padding-top: 0 !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
}

/* ===== Safe Area Insets for Notched Devices ===== */
@supports (padding: max(0px)) {
    .primary-header,
    .container,
    .hero,
    .site-footer {
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
    }
    
    .ai-assistant {
        bottom: max(var(--space-6), env(safe-area-inset-bottom));
        right: max(var(--space-6), env(safe-area-inset-right));
    }
}
