/* 📱 MOBILE ENHANCEMENT - Bổ sung tối ưu mobile không làm hỏng desktop */
/* Chỉ cải thiện mobile, giữ nguyên desktop layout */

/* ===== MOBILE NAVIGATION FIXES ===== */
@media (max-width: 767px) {
    /* Fix language switcher position */
    .nav-container {
        position: relative;
        padding: 0 15px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .language-switcher {
        position: absolute;
        right: 55px; /* More space for hamburger */
        top: 50%;
        transform: translateY(-50%);
        gap: 0.1rem;
        z-index: 999; /* Lower than hamburger menu */
        display: flex;
        flex-wrap: nowrap;
        max-width: 75px; /* Smaller to prevent overlap */
    }
    
    .lang-btn {
        padding: 2px 3px;
        font-size: 0.55rem;
        min-width: 22px;
        height: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        border-radius: 3px;
        margin: 0;
        flex-shrink: 0;
        border: 1px solid rgba(37, 99, 235, 0.3);
        background: rgba(37, 99, 235, 0.1);
        color: #2563eb;
        font-weight: 500;
    }
    
    .lang-btn.active {
        background: #2563eb;
        color: white;
        border-color: #2563eb;
    }
    
    /* Hamburger menu positioning */
    .nav-toggle {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1003; /* Higher than language switcher */
        width: 30px;
        height: 30px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        cursor: pointer;
        background: transparent;
        border: none;
        padding: 5px;
    }
    
    .nav-toggle span {
        width: 20px;
        height: 2px;
        background: #2563eb;
        transition: all 0.3s ease;
        border-radius: 1px;
    }
    
    /* Extra small screens - further adjustments */
    @media (max-width: 360px) {
        .language-switcher {
            right: 60px; /* Even more space */
            max-width: 65px;
        }
        
        .lang-btn {
            min-width: 20px;
            height: 20px;
            font-size: 0.5rem;
            padding: 1px 2px;
        }
    }
    
    /* Mobile menu improvements */
    .nav-menu {
        padding-top: 1rem;
    }
    
    .nav-menu li {
        margin: 0.5rem 0;
    }
    
    .nav-menu a {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-radius: 8px;
        margin: 0 1rem;
    }
}

/* ===== IMAGE SIZE FIXES ===== */
@media (max-width: 767px) {
    /* Hero image fix */
    .hero-image img {
        max-width: 100%;
        height: auto;
        max-height: 250px;
        object-fit: cover;
        border-radius: 12px;
    }
    
    /* About image fix */
    .about-image img {
        max-width: 100%;
        height: auto;
        max-height: 200px;
        object-fit: cover;
        border-radius: 8px;
    }
    
    /* Service icons size fix */
    .service-card i {
        font-size: 2.5rem !important;
    }
    
    /* General image constraints */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* ===== TYPOGRAPHY MOBILE FIXES ===== */
@media (max-width: 767px) {
    /* Hero title responsive */
    .hero-title {
        font-size: 1.8rem !important;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    /* Section headers */
    .section-header h2 {
        font-size: 1.6rem !important;
    }
    
    /* Service card titles */
    .service-card h3 {
        font-size: 1.1rem !important;
    }
    
    /* Body text readability */
    .hero-description,
    .service-card p,
    .about-text p {
        font-size: 0.95rem !important;
        line-height: 1.5;
    }
}

/* ===== BUTTON & TOUCH TARGET FIXES ===== */
@media (max-width: 767px) {
    /* Ensure minimum touch target size */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hero buttons stack properly */
    .hero-buttons {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 280px;
    }
    
    /* Social buttons mobile */
    .social-btn {
        min-height: 48px;
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }
}

/* ===== FORM MOBILE IMPROVEMENTS ===== */
@media (max-width: 767px) {
    .contact-form {
        padding: 1.5rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
        border-radius: 6px;
    }
    
    .form-group textarea {
        min-height: 100px;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* ===== SPACING & LAYOUT MOBILE FIXES ===== */
@media (max-width: 767px) {
    /* Section padding adjustments */
    .hero {
        padding: 80px 0 40px;
    }
    
    .services,
    .about,
    .contact {
        padding: 40px 0;
    }
    
    /* Container padding */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Service cards spacing */
    .services-grid {
        gap: 1.25rem;
    }
    
    .service-card {
        padding: 1.5rem;
    }
    
    /* Contact content mobile */
    .contact-content {
        gap: 1.5rem;
    }
    
    .contact-item {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* ===== HEADER MOBILE IMPROVEMENTS ===== */
@media (max-width: 767px) {
    .header {
        height: 60px;
    }
    
    .nav-container {
        height: 60px;
    }
    
    /* Logo adjustments */
    .logo-main {
        font-size: 1.2rem;
    }
    
    .logo-main i {
        font-size: 1.4rem;
        margin-right: 0.5rem;
    }
    
    .logo-slogan {
        font-size: 0.65rem;
    }
}

/* ===== TABLET SPECIFIC FIXES ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet optimizations */
    .hero-title {
        font-size: 2.2rem;
    }
    
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .about-content {
        gap: 2rem;
    }
    
    .contact-content {
        gap: 2rem;
    }
}

/* ===== PERFORMANCE & ANIMATION FIXES ===== */
@media (max-width: 767px) {
    /* Reduce motion for better performance */
    .service-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .service-card:hover {
        transform: translateY(-4px);
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }
    
    /* Touch feedback */
    .btn:active,
    .social-btn:active,
    .nav-menu a:active {
        transform: scale(0.98);
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (max-width: 767px) {
    /* Focus states for mobile */
    .btn:focus,
    .nav-menu a:focus,
    .lang-btn:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
    }
    
    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 6px;
        background: #2563eb;
        color: white;
        padding: 8px;
        text-decoration: none;
        border-radius: 4px;
        z-index: 1000;
    }
    
    .skip-to-content:focus {
        top: 6px;
    }
}

/* ===== PREVENT HORIZONTAL SCROLL ===== */
@media (max-width: 767px) {
    body {
        overflow-x: hidden;
    }
    
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .container,
    .hero-container,
    .services-grid,
    .about-content,
    .contact-content {
        width: 100%;
        max-width: 100%;
    }
}

/* ===== LOADING STATES ===== */
@media (max-width: 767px) {
    /* Image loading placeholder */
    img {
        background: #f3f4f6;
        transition: opacity 0.3s ease;
    }
    
    img:not([src]) {
        opacity: 0.5;
    }
    
    /* Loading animation for slow connections */
    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }
    
    .loading img {
        animation: pulse 1.5s ease-in-out infinite;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .nav-toggle,
    .language-switcher,
    .social-buttons {
        display: none !important;
    }
    
    .hero {
        background: none !important;
        color: black !important;
    }
    
    .service-card,
    .contact-form {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .service-card {
        border: 2px solid #333;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== DOMAIN SWITCHER FIXES ===== */
/* Hide domain switcher from header completely */
.domain-switcher-container {
    display: none !important;
}

/* Footer domain switcher styling */
.domain-switcher-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.domain-switcher-footer .domain-switcher-container {
    display: block !important;
    position: static !important;
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    padding: 0.75rem !important;
    border-radius: 6px !important;
    font-size: 0.8rem !important;
    z-index: auto !important;
    box-shadow: none !important;
    margin: 0 auto !important;
    max-width: 300px !important;
}

.domain-switcher-footer .current-domain {
    font-size: 0.75rem !important;
    opacity: 0.8;
    margin-bottom: 0.5rem !important;
}

.domain-switcher-footer .domain-options button {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    padding: 0.25rem 0.5rem !important;
    margin: 0.125rem !important;
    border-radius: 4px !important;
    font-size: 0.7rem !important;
}

.domain-switcher-footer .domain-options button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3) !important;
}

@media (max-width: 767px) {
    .domain-switcher-footer .domain-switcher-container {
        max-width: 250px !important;
        font-size: 0.75rem !important;
    }
    
    .domain-switcher-footer .current-domain {
        font-size: 0.7rem !important;
    }
    
    .domain-switcher-footer .domain-options button {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    @media (max-width: 767px) {
        .nav-menu {
            background: rgba(30, 30, 30, 0.95);
            color: white;
        }
        
        .nav-menu a {
            color: white;
            background: rgba(255, 255, 255, 0.1);
        }
        
        .nav-menu a:hover {
            background: rgba(255, 255, 255, 0.2);
        }
    }
}