/**
 * Comprehensive Responsive Styles
 * Mobile-first approach with perfect breakpoints
 */

/* =========================================
   Breakpoints Reference
   ========================================= */
/*
   xs: 0px - 479px (Small phones)
   sm: 480px - 639px (Phones)
   md: 640px - 767px (Large phones)
   lg: 768px - 1023px (Tablets)
   xl: 1024px - 1279px (Small desktops)
   2xl: 1280px+ (Large desktops)
*/

/* =========================================
   Base Mobile Styles (0-479px)
   ========================================= */
@media (max-width: 479px) {
    /* Typography */
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.75rem !important; }
    h3 { font-size: 1.5rem !important; }
    h4 { font-size: 1.25rem !important; }

    .hero-title {
        font-size: 2.5rem !important;
    }

    .section-heading-title {
        font-size: 1.75rem !important;
    }

    /* Spacing */
    .content-section {
        padding: 2.5rem 0 !important;
    }

    .container {
        padding: 0 1rem !important;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
        width: 100%;
        display: block;
        text-align: center;
    }

    .btn-lg {
        padding: 1rem 1.5rem !important;
    }

    .btn-xl {
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
    }

    /* Hero Section */
    .page-hero {
        padding: 5rem 0 3rem !important;
    }

    .hero-section {
        min-height: 80vh !important;
    }

    .hero-content {
        padding: 2rem 1rem 5rem !important;
    }

    /* Grids */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }

    /* Cards */
    .card-animate {
        margin-bottom: 1rem;
    }
}

/* =========================================
   Small Phones (480px - 639px)
   ========================================= */
@media (min-width: 480px) and (max-width: 639px) {
    h1 { font-size: 2.25rem !important; }
    h2 { font-size: 2rem !important; }

    .hero-title {
        font-size: 3rem !important;
    }

    .btn {
        width: auto;
        display: inline-flex;
    }

    .container {
        padding: 0 1.25rem !important;
    }
}

/* =========================================
   Large Phones (640px - 767px)
   ========================================= */
@media (min-width: 640px) and (max-width: 767px) {
    h1 { font-size: 2.5rem !important; }
    h2 { font-size: 2.25rem !important; }

    .hero-title {
        font-size: 3.5rem !important;
    }

    .container {
        padding: 0 1.5rem !important;
    }

    /* Two column grids on larger phones */
    .grid-2-col {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* =========================================
   Tablets Portrait (768px - 1023px)
   ========================================= */
@media (min-width: 768px) and (max-width: 1023px) {
    h1 { font-size: 3rem !important; }
    h2 { font-size: 2.5rem !important; }

    .hero-title {
        font-size: 4rem !important;
    }

    .container {
        padding: 0 2rem !important;
    }

    .content-section {
        padding: 4rem 0 !important;
    }

    /* Show mobile menu */
    .main-navigation {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    /* Two or three column grids */
    .grid-auto {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }

    /* Header adjustments */
    .site-logo-text {
        font-size: 1.35rem;
    }

    .header-cta-btn {
        display: inline-flex !important;
    }
}

/* =========================================
   Small Desktops (1024px - 1279px)
   ========================================= */
@media (min-width: 1024px) and (max-width: 1279px) {
    .container {
        max-width: 960px;
        padding: 0 2rem;
    }

    .main-navigation {
        display: flex;
    }

    .mobile-menu-toggle {
        display: none;
    }

    .main-navigation ul {
        gap: 1.5rem;
    }

    .main-navigation a {
        font-size: 0.875rem;
    }
}

/* =========================================
   Large Desktops (1280px+)
   ========================================= */
@media (min-width: 1280px) {
    .container {
        max-width: 1200px;
        padding: 0 2rem;
    }

    .main-navigation ul {
        gap: 2rem;
    }
}

/* =========================================
   Extra Large Screens (1920px+)
   ========================================= */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }

    h1 { font-size: 4.5rem; }
    .hero-title {
        font-size: 8rem;
    }

    .content-section {
        padding: 7rem 0;
    }
}

/* =========================================
   Landscape Mobile
   ========================================= */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: 100vh;
        padding: 2rem 0;
    }

    .page-hero {
        padding: 4rem 0 2rem !important;
    }

    .site-header {
        padding: 0.5rem 0;
    }
}

/* =========================================
   Touch Device Optimizations
   ========================================= */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    a, button, .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.5rem;
    }

    /* Remove hover effects on touch devices */
    .hover-lift:hover {
        transform: none;
    }

    /* Active states instead */
    .btn:active {
        transform: scale(0.97);
    }

    .card-animate:active {
        transform: scale(0.98);
    }
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    .site-header,
    .site-footer,
    .mobile-menu,
    .btn,
    .scroll-indicator,
    .floating-buttons {
        display: none !important;
    }

    .site-content {
        margin-top: 0 !important;
    }

    * {
        background: white !important;
        color: black !important;
    }

    a {
        text-decoration: underline;
    }
}

/* =========================================
   Specific Component Responsiveness
   ========================================= */

/* Header */
@media (max-width: 1023px) {
    .site-header .container {
        padding: 0 1.5rem;
    }

    .header-inner {
        justify-content: space-between;
    }

    .main-navigation {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: block !important;
    }
}

/* Footer */
@media (max-width: 767px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .footer-bottom-inner {
        flex-direction: column;
        gap: 1.5rem;
    }

    .footer-social {
        justify-content: center;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Hero Buttons */
@media (max-width: 639px) {
    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        padding: 0 1rem;
    }

    .hero-buttons .btn {
        width: 100%;
        padding: 1.125rem 2rem !important;
        font-size: 1rem !important;
    }

    .btn-hero, .btn-hero-outline {
        padding: 1.125rem 2rem !important;
    }
}

/* Forms */
@media (max-width: 767px) {
    .contact-form-grid {
        grid-template-columns: 1fr !important;
    }

    form > div {
        margin-bottom: 1rem;
    }
}

/* Product Cards */
@media (max-width: 639px) {
    [style*="grid-template-columns"]:has(.product-card) {
        grid-template-columns: 1fr !important;
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    [style*="grid-template-columns"]:has(.product-card) {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Team Members / Testimonials */
@media (max-width: 639px) {
    [style*="grid-template-columns"]:has(.team-card),
    [style*="grid-template-columns"]:has(.testimonial-card) {
        grid-template-columns: 1fr !important;
    }
}

/* Stats / Numbers */
@media (max-width: 479px) {
    [style*="display: flex"]:has([style*="font-size: 2rem"]) {
        flex-direction: column !important;
        gap: 1rem !important;
    }
}

/* Images */
@media (max-width: 767px) {
    img {
        width: 100%;
        height: auto;
    }

    .image-zoom-container {
        max-height: 300px;
    }
}

/* Tables */
@media (max-width: 767px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Modal / Dialog */
@media (max-width: 639px) {
    .modal,
    .dialog {
        width: 95% !important;
        max-width: 100% !important;
        margin: 1rem !important;
    }
}

/* Text Alignment on Mobile */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }

    .text-left-mobile {
        text-align: left !important;
    }
}

/* Spacing Utilities */
@media (max-width: 767px) {
    .px-mobile-0 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .py-mobile-2 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .gap-mobile-1 {
        gap: 0.5rem !important;
    }
}

/* Hide on Mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on Mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* =========================================
   Flexible Grids
   ========================================= */
.responsive-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 479px) {
    .responsive-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* =========================================
   Aspect Ratio Containers
   ========================================= */
.aspect-video {
    aspect-ratio: 16/9;
}

.aspect-square {
    aspect-ratio: 1/1;
}

@supports not (aspect-ratio: 1/1) {
    .aspect-video {
        padding-bottom: 56.25%;
    }

    .aspect-square {
        padding-bottom: 100%;
    }
}

/* =========================================
   Scrollbar on Mobile
   ========================================= */
@media (max-width: 767px) {
    ::-webkit-scrollbar {
        width: 4px;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 2px;
    }
}

/* =========================================
   Safe Area (iPhone X+)
   ========================================= */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .site-header,
    .site-footer {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* =========================================
   Accessibility - Focus Visible
   ========================================= */
@media (max-width: 1023px) {
    *:focus-visible {
        outline: 3px solid var(--color-accent);
        outline-offset: 2px;
    }
}
