/*
 * Responsive Design Optimization
 * Mobile-first approach for Preta AI website
 * Breakpoints: 320px (mobile) | 768px (tablet) | 1024px (desktop) | 1440px+ (large screens)
 */

/* ================================================================
   GLOBAL RESPONSIVE UTILITIES
   ================================================================ */

/* Prevent horizontal scroll */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Responsive images and media */
img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ================================================================
   MOBILE FIRST (320px - 767px)
   ================================================================ */

/* Typography */
@media (max-width: 767px) {
    h1, .hero-section h1 {
        font-size: 2rem !important;
        line-height: 1.3 !important;
        margin-bottom: 15px !important;
    }

    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }

    h3 {
        font-size: 1.5rem !important;
        line-height: 1.4 !important;
    }

    p, .hero-description {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }

    /* Header - Mobile optimized */
    #header {
        padding: 10px 0 !important;
    }

    #logo img {
        max-height: 40px !important;
    }

    /* Hide desktop navigation on mobile */
    header nav {
        display: none !important;
    }

    /* Mobile menu button (if exists) */
    .mobile-menu-toggle {
        display: block !important;
    }

    /* Hero sections */
    .hero-section {
        padding: 60px 15px 40px 15px !important;
        text-align: center !important;
    }

    /* CTA Buttons */
    .cta-button, .button {
        font-size: 1rem !important;
        padding: 15px 25px !important;
        display: block !important;
        width: 100% !important;
        max-width: 300px !important;
        margin: 10px auto !important;
        text-align: center !important;
    }

    /* Sections */
    .section {
        padding: 40px 15px !important;
    }

    /* Containers */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
    }

    /* Grid layouts - Stack on mobile */
    .stats-grid,
    .features-grid,
    .services-grid,
    .agents-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Cards */
    .agent-card,
    .service-card,
    .benefit-card,
    .stat-card,
    .pricing-card {
        padding: 20px !important;
        margin-bottom: 20px !important;
    }

    /* Hide decorative elements on mobile */
    .desktop-only,
    .decorative-element {
        display: none !important;
    }

    /* Pricing tables */
    .pricing-tables {
        display: block !important;
    }

    .pricing-card {
        width: 100% !important;
        margin-bottom: 30px !important;
    }

    /* Forms */
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }

    /* Case studies and testimonials */
    .case-study {
        padding: 25px 15px !important;
    }

    /* Footer */
    #footer .container {
        padding: 30px 15px !important;
    }

    #footer .footer-column {
        margin-bottom: 30px !important;
    }

    /* Reduce spacing on mobile */
    .margin-top-60,
    .margin-top-80 {
        margin-top: 30px !important;
    }

    .margin-bottom-60,
    .margin-bottom-80 {
        margin-bottom: 30px !important;
    }

    /* Icons sizing */
    .icon-large {
        font-size: 2.5rem !important;
    }

    /* Video embeds */
    .video-container {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 ratio */
        height: 0;
        overflow: hidden;
    }

    .video-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* ================================================================
   TABLET (768px - 1023px)
   ================================================================ */

@media (min-width: 768px) and (max-width: 1023px) {
    /* Typography adjustments */
    h1, .hero-section h1 {
        font-size: 2.5rem !important;
        line-height: 1.2 !important;
    }

    h2 {
        font-size: 2rem !important;
    }

    /* Header */
    #logo img {
        max-height: 45px !important;
    }

    /* Navigation - Show simplified nav */
    header nav {
        gap: 15px !important;
    }

    header nav a {
        font-size: 0.9rem !important;
        padding: 8px 12px !important;
    }

    /* Hero sections */
    .hero-section {
        padding: 80px 30px 50px 30px !important;
    }

    /* Grid layouts - 2 columns on tablet */
    .stats-grid,
    .features-grid,
    .services-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px !important;
    }

    .agents-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }

    /* Sections */
    .section {
        padding: 60px 30px !important;
    }

    /* Pricing - 2 columns */
    .pricing-tables {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }

    /* CTA Buttons */
    .cta-button, .button {
        font-size: 1.1rem !important;
        padding: 16px 30px !important;
        display: inline-block !important;
        width: auto !important;
    }

    /* Container */
    .container {
        padding-left: 30px !important;
        padding-right: 30px !important;
    }

    /* Cards */
    .case-study {
        padding: 35px 25px !important;
    }
}

/* ================================================================
   DESKTOP (1024px - 1439px)
   ================================================================ */

@media (min-width: 1024px) and (max-width: 1439px) {
    /* Standard desktop layout */
    .container {
        max-width: 1140px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Grid layouts - 3 columns */
    .stats-grid,
    .features-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 30px !important;
    }

    .agents-grid,
    .services-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 35px !important;
    }

    /* Pricing - 3 columns */
    .pricing-tables {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 30px !important;
    }

    /* Hero sections */
    .hero-section {
        padding: 100px 0 70px 0 !important;
    }

    h1, .hero-section h1 {
        font-size: 3rem !important;
    }
}

/* ================================================================
   LARGE DESKTOP (1440px+)
   ================================================================ */

@media (min-width: 1440px) {
    /* Max width container for large screens */
    .container {
        max-width: 1320px !important;
    }

    /* Larger typography for big screens */
    h1, .hero-section h1 {
        font-size: 3.5rem !important;
    }

    h2 {
        font-size: 2.5rem !important;
    }

    /* Grid layouts - 4 columns for large screens */
    .stats-grid,
    .features-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 35px !important;
    }

    .agents-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 40px !important;
    }

    /* Pricing - keep 3 columns but wider */
    .pricing-tables {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 40px !important;
        max-width: 1200px !important;
        margin: 0 auto !important;
    }
}

/* ================================================================
   SPECIFIC COMPONENT FIXES
   ================================================================ */

/* Mobile: Stack header elements */
@media (max-width: 767px) {
    #header > div > div {
        flex-direction: column !important;
        gap: 15px !important;
        align-items: center !important;
    }

    #header .button {
        width: 100% !important;
        max-width: 250px !important;
    }
}

/* Tablet: Horizontal header with smaller elements */
@media (min-width: 768px) and (max-width: 1023px) {
    #header > div > div {
        flex-wrap: wrap !important;
        justify-content: space-between !important;
    }
}

/* FAQ Accordion - Mobile friendly */
@media (max-width: 767px) {
    .faq-item {
        padding: 15px !important;
    }

    .faq-question {
        font-size: 1rem !important;
    }
}

/* Chatbot - Mobile positioning */
@media (max-width: 767px) {
    #chatbot-container {
        width: 100% !important;
        height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
    }

    #chatbot-toggle {
        bottom: 15px !important;
        right: 15px !important;
        width: 55px !important;
        height: 55px !important;
    }
}

/* Modal - Full screen on mobile */
@media (max-width: 767px) {
    .modal-content {
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        max-height: none !important;
    }

    .modal {
        padding: 0 !important;
    }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */

@media print {
    /* Hide unnecessary elements when printing */
    header,
    #header-container,
    .chatbot,
    #chatbot-toggle,
    .cta-button,
    footer {
        display: none !important;
    }

    /* Optimize for print */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .container {
        max-width: none !important;
    }
}

/* ================================================================
   ACCESSIBILITY ENHANCEMENTS
   ================================================================ */

/* Focus states for keyboard navigation */
@media (max-width: 767px) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid #66cc66 !important;
        outline-offset: 2px !important;
    }

    /* Larger touch targets on mobile */
    button,
    .button,
    a.button,
    input[type="submit"] {
        min-height: 48px !important;
        min-width: 48px !important;
    }
}

/* ================================================================
   PERFORMANCE OPTIMIZATIONS
   ================================================================ */

/* Reduce animations on mobile for performance */
@media (max-width: 767px) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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