/**
 * GAT Insulation - Professional Responsive Styles
 * Mobile-first approach with smooth transitions
 * Breakpoints:
 * - Desktop: > 1024px
 * - Tablet: 768px - 1024px
 * - Mobile: < 768px
 * - Small Mobile: < 480px
 */

/* ============================================
   TABLET STYLES (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }

    .container {
        padding: 0 30px;
    }

    .hero h1 {
        font-size: 2.75rem;
    }

    .branches-grid,
    .services-grid,
    .services-grid-images,
    .brochures-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .service-card-img {
        height: 180px;
    }

    .clients-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .suppliers-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .about-grid,
    .service-detail-grid,
    .contact-grid {
        gap: 40px;
    }

    /* Stats grid - 2x2 on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }
}

/* ============================================
   MOBILE STYLES (< 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Base typography */
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    body {
        font-size: 15px;
    }

    .section {
        padding: 50px 0;
    }

    .container {
        padding: 0 20px;
    }

    /* ========== HEADER & NAVIGATION ========== */
    .header {
        padding: 12px 0;
    }

    .header .container {
        position: relative;
    }

    .logo-text {
        font-size: 1.6rem;
    }

    .logo-subtitle {
        font-size: 0.55rem;
        letter-spacing: 4px;
    }

    .logo-image {
        max-height: 40px;
    }

    /* Mobile Menu Button */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        position: relative;
    }

    .mobile-menu-btn span {
        display: block;
        width: 24px;
        height: 2px;
        background: #333;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: center;
    }

    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Mobile Navigation Slide-out - Light Theme */
    .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        background: #ffffff;
        padding: 80px 25px 30px;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        box-shadow: -5px 0 30px rgba(0,0,0,0.15);
    }

    .nav.active {
        right: 0;
    }

    .nav-list {
        flex-direction: column;
        gap: 0;
    }

    .nav-list li {
        border-bottom: 1px solid rgba(0,0,0,0.08);
    }

    .nav-list a {
        display: block;
        padding: 16px 0;
        font-size: 1rem;
        font-weight: 500;
        color: #333;
    }

    .nav-list a::after {
        display: none;
    }

    .nav-list a.active {
        color: var(--accent-gold);
    }

    /* Language Switcher Mobile */
    .lang-switcher {
        position: absolute;
        right: 60px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        background: rgba(0,0,0,0.05);
        padding: 4px 8px;
        border-radius: 20px;
    }

    .lang-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .lang-divider {
        margin: 0 2px;
    }

    /* Dropdown in Mobile */
    .dropdown {
        position: static;
        transform: none;
        box-shadow: none;
        background: rgba(0,0,0,0.03);
        margin: 0;
        padding: 0;
        border-radius: 8px;
        opacity: 1;
        visibility: visible;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .dropdown::before {
        display: none;
    }

    .has-dropdown.open .dropdown {
        max-height: 500px;
    }

    .dropdown a {
        padding: 12px 20px;
        color: #666;
        font-size: 0.9rem;
    }

    .dropdown a:hover {
        background: rgba(0,0,0,0.05);
        color: var(--accent-gold);
    }

    /* Mobile Overlay */
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* ========== HERO SECTION ========== */
    .hero {
        min-height: 100svh; /* Small viewport height - accounts for browser chrome */
        min-height: 100vh;
        padding: 60px 0 70px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-sizing: border-box;
    }

    .hero > .container {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .hero-content {
        text-align: center;
        max-width: 100%;
    }

    .hero h1 {
        font-size: 1.65rem;
        line-height: 1.2;
        margin-bottom: 0.6rem;
    }

    .hero p {
        font-size: 0.85rem;
        line-height: 1.5;
        margin-bottom: 1rem;
        opacity: 0.9;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
        padding: 11px 18px;
        font-size: 0.85rem;
    }

    .scroll-indicator {
        position: fixed;
        bottom: 20px;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        display: flex;
        justify-content: center;
        z-index: 50;
        transition: opacity 0.3s ease;
    }

    .scroll-indicator span {
        font-size: 0.6rem;
    }

    .scroll-indicator .mouse {
        width: 20px;
        height: 30px;
    }

    /* ========== CONTACT BAR ========== */
    .contact-bar {
        padding: 20px 0;
    }

    .contact-bar .container {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .contact-bar-item {
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }

    .contact-bar-item svg {
        width: 18px;
        height: 18px;
    }

    /* ========== SECTION HEADERS ========== */
    .section-header {
        margin-bottom: 35px;
    }

    .section-header h2 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }

    .section-header p {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .section-header .accent-line {
        width: 50px;
        margin-top: 15px;
    }

    /* ========== SERVICE CARDS ========== */
    .branches-grid,
    .services-grid,
    .services-grid-images,
    .brochures-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .service-card {
        border-radius: 16px;
    }

    .service-card-img {
        height: 200px;
    }

    .service-card-content {
        padding: 20px;
    }

    .service-card-content h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .service-card-content p {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 12px;
    }

    .learn-more {
        font-size: 0.9rem;
    }

    /* ========== BRANCH CARDS ========== */
    .branch-card {
        border-radius: 16px;
    }

    .branch-card-image {
        height: 180px;
    }

    .branch-card-content {
        padding: 20px;
    }

    .branch-card-content h3 {
        font-size: 1.2rem;
    }

    .branch-card-content p {
        font-size: 0.9rem;
    }

    .branch-card .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    /* ========== ABOUT SECTION ========== */
    .about-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .about-content {
        text-align: center;
    }

    .about-content h2 {
        font-size: 1.75rem;
    }

    .about-content p {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    .about-image {
        border-radius: 16px;
        max-height: 300px;
    }

    /* ========== STATS SECTION ========== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px !important;
        padding: 0 10px;
    }

    .stat-item h2,
    .stat-item .counter {
        font-size: 2.5rem !important;
        margin-bottom: 5px !important;
    }

    .stat-item p {
        font-size: 0.7rem !important;
        letter-spacing: 1px !important;
    }

    /* ========== SERVICE DETAIL ========== */
    .service-detail {
        padding: 50px 0;
    }

    .service-detail-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .back-link {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .service-detail-content h1 {
        font-size: 1.75rem;
    }

    .service-detail-content p {
        font-size: 0.95rem;
    }

    .service-detail-image {
        position: static;
        border-radius: 16px;
        max-height: 300px;
        overflow: hidden;
    }

    .service-detail-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* ========== CLIENTS GRID ========== */
    .clients-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .client-card {
        padding: 20px;
        min-height: 100px;
        border-radius: 12px;
    }

    /* ========== SUPPLIERS GRID ========== */
    .suppliers-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .supplier-card {
        padding: 20px;
    }

    .supplier-logo {
        min-height: 80px;
    }

    .client-card img {
        max-height: 50px;
    }

    /* ========== GALLERY ========== */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .gallery-item {
        border-radius: 10px;
    }

    /* ========== BROCHURES ========== */
    .brochure-card {
        border-radius: 16px;
    }

    .brochure-cover {
        height: 220px;
    }

    .brochure-content {
        padding: 20px;
    }

    .brochure-content h3 {
        font-size: 1.1rem;
    }

    /* ========== CONTACT PAGE ========== */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .contact-form {
        padding: 25px;
        border-radius: 16px;
    }

    .form-group input,
    .form-group textarea {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 10px;
    }

    .form-group select {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 10px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-color: #fff;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 16px center;
        padding-right: 40px;
        color: #333;
    }

    .form-group select option {
        background-color: #fff;
        color: #333;
    }

    .contact-info-card {
        padding: 25px;
        border-radius: 16px;
    }

    .contact-info-item {
        margin-bottom: 20px;
    }

    /* ========== PAGE HEADER ========== */
    .page-header {
        padding: 50px 0 40px;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .page-header p {
        font-size: 0.9rem;
    }

    /* ========== CTA SECTIONS ========== */
    .cta-section {
        padding: 60px 0 !important;
    }

    .cta-section h2 {
        font-size: 1.75rem !important;
    }

    .cta-section p {
        font-size: 0.95rem !important;
        padding: 0 10px;
    }

    /* ========== FOOTER ========== */
    .footer-skyline {
        height: 60px;
    }

    .footer-content {
        padding: 40px 0 25px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }

    .footer-logo {
        margin-bottom: 15px;
    }

    .footer-logo .logo-text {
        font-size: 1.5rem;
    }

    .footer-desc {
        font-size: 0.9rem;
        max-width: 280px;
        margin: 0 auto;
    }

    .footer-col h4 {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .footer-col ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 20px;
    }

    .footer-col ul li {
        margin-bottom: 0;
    }

    .footer-col ul a {
        font-size: 0.9rem;
    }

    .contact-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .contact-info li {
        justify-content: center;
    }

    .social-links {
        justify-content: center;
        gap: 12px;
        margin-top: 15px;
    }

    .social-links a {
        width: 44px;
        height: 44px;
    }

    .footer-bottom {
        margin-top: 30px;
        padding-top: 20px;
    }

    .footer-bottom p {
        font-size: 0.85rem;
    }

    /* ========== BUTTONS ========== */
    .btn {
        padding: 12px 24px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .btn-primary,
    .btn-outline {
        min-height: 48px; /* Touch-friendly */
    }

    /* ========== WHATSAPP BUTTON ========== */
    .whatsapp-float {
        bottom: 20px;
        right: 20px;
        padding: 0;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        justify-content: center;
    }

    .whatsapp-float-text {
        display: none;
    }

    .whatsapp-float-icon {
        width: 56px;
        height: 56px;
    }

    .whatsapp-float-icon svg {
        width: 28px;
        height: 28px;
    }

    /* ========== ALERTS ========== */
    .alert {
        padding: 12px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
}

/* ============================================
   SMALL MOBILE STYLES (< 480px)
   ============================================ */
@media (max-width: 480px) {
    h1 { font-size: 1.625rem; }
    h2 { font-size: 1.375rem; }

    .container {
        padding: 0 16px;
    }

    .section {
        padding: 40px 0;
    }

    /* Header */
    .logo-text {
        font-size: 1.4rem;
    }

    .lang-switcher {
        right: 55px;
    }

    /* Hero */
    .hero h1 {
        font-size: 1.625rem;
    }

    .hero p {
        font-size: 0.9rem;
    }

    /* Stats */
    .stats-grid {
        gap: 20px !important;
    }

    .stat-item h2,
    .stat-item .counter {
        font-size: 2rem !important;
    }

    .stat-item p {
        font-size: 0.65rem !important;
    }

    /* Service cards */
    .service-card-img {
        height: 180px;
    }

    /* Gallery */
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Brochures */
    .brochure-cover {
        height: 200px;
    }

    /* Footer */
    .footer-col ul {
        gap: 8px 15px;
    }
}

/* ============================================
   RTL MOBILE ADJUSTMENTS
   Note: Main RTL mobile nav styles are in rtl.css
   ============================================ */
@media (max-width: 768px) {
    html[dir="rtl"] .hero-content {
        text-align: center;
    }

    html[dir="rtl"] .contact-bar-item {
        flex-direction: row-reverse;
        justify-content: center;
    }

    html[dir="rtl"] .about-content {
        text-align: center;
    }

    html[dir="rtl"] .footer-grid {
        text-align: center;
    }

    html[dir="rtl"] .footer-col ul {
        justify-content: center;
    }

    html[dir="rtl"] .contact-info li {
        justify-content: center;
    }
}

/* ============================================
   TOUCH & INTERACTION OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly targets */
    .btn,
    .nav-list a,
    .dropdown a,
    .gallery-item,
    .client-card,
    .learn-more {
        min-height: 44px;
    }

    /* Disable hover effects on touch */
    .has-dropdown:hover .dropdown {
        opacity: 0;
        visibility: hidden;
        max-height: 0;
    }

    .has-dropdown.open .dropdown {
        opacity: 1;
        visibility: visible;
        max-height: 500px;
    }

    /* Remove hover transforms on touch devices */
    .service-card:hover,
    .branch-card:hover,
    .client-card:hover {
        transform: none;
    }

    .service-card:active,
    .branch-card:active {
        transform: scale(0.98);
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 40px 0;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero-buttons {
        flex-direction: row;
        gap: 10px;
    }

    .hero-buttons .btn {
        width: auto;
        padding: 10px 20px;
    }

    .scroll-indicator {
        display: none;
    }

    .nav {
        padding-top: 60px;
    }
}

/* ============================================
   HIGH DPI / RETINA DISPLAYS
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-text {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        -webkit-font-smoothing: antialiased;
    }
}

/* ============================================
   REDUCED MOTION PREFERENCE
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-video-bg {
        display: none;
    }

    .nav {
        transition: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .footer,
    .mobile-menu-btn,
    .whatsapp-float,
    .btn,
    .scroll-indicator {
        display: none !important;
    }

    body {
        background: white;
        color: black;
        font-size: 12pt;
    }

    .section {
        padding: 20px 0;
        page-break-inside: avoid;
    }

    .hero {
        min-height: auto;
        padding: 20px;
    }

    a {
        text-decoration: underline;
    }
}

/* ============================================
   SAFE AREA INSETS (Notched devices)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .footer-bottom {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .whatsapp-float {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }

    html[dir="rtl"] .whatsapp-float {
        left: max(20px, env(safe-area-inset-left));
        right: auto;
    }

    .nav {
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }
}