/* 
 * Kanti Pro Solutions - Mobile-First Responsive Design
 * Optimized for all screen sizes: Mobile → Tablet → Desktop
 */

/* ===== MOBILE-FIRST BREAKPOINTS ===== */
:root {
    --mobile-xs: 320px;   /* Small phones */
    --mobile-sm: 375px;   /* iPhone SE, small Android */
    --mobile-md: 414px;   /* iPhone XR/11, most phones */
    --mobile-lg: 480px;   /* Large phones */
    --tablet-sm: 600px;   /* Small tablets */
    --tablet-md: 768px;   /* iPad portrait */
    --tablet-lg: 900px;   /* iPad landscape */
    --desktop-sm: 1024px; /* Small laptops */
    --desktop-md: 1200px; /* Standard laptops */
    --desktop-lg: 1440px; /* Large monitors */
    --desktop-xl: 1920px; /* 4K monitors */
}

/* ===== RESPONSIVE UTILITIES ===== */
/* Hide/Show based on screen size */
.mobile-only { display: none !important; }
.desktop-only { display: block !important; }

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .touch-device {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 12px 16px !important;
    }
    
    button, 
    a.btn, 
    input[type="submit"],
    .clickable {
        min-height: 44px !important;
        min-width: 44px !important;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .safe-area-padding {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ===== MOBILE OPTIMIZATIONS (0px - 767px) ===== */
@media (max-width: 767px) {
    /* Global Mobile Reset */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-font-smoothing: antialiased;
    }
    
    html {
        font-size: 14px;
    }
    
    body {
        overflow-x: hidden;
        position: relative;
        width: 100%;
    }
    
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .mobile-only { display: block !important; }
    .desktop-only { display: none !important; }
    
    /* Typography for Mobile */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: 1rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    p, li, a {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }
    
    /* Header - Mobile Navigation */
    header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 12px 0 !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .header-container {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 12px !important;
    }
    
    .logo {
        flex: 1;
        min-width: 0;
    }
    
    .logo-text {
        font-size: 1.1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
    }
    
    .hamburger {
        width: 24px;
        height: 2px;
        background: currentColor;
        position: relative;
        transition: all 0.3s ease;
    }
    
    .hamburger::before,
    .hamburger::after {
        content: '';
        position: absolute;
        width: 24px;
        height: 2px;
        background: currentColor;
        left: 0;
        transition: all 0.3s ease;
    }
    
    .hamburger::before {
        top: -8px;
    }
    
    .hamburger::after {
        bottom: -8px;
    }
    
    .mobile-menu-toggle.active .hamburger {
        background: transparent;
    }
    
    .mobile-menu-toggle.active .hamburger::before {
        transform: rotate(45deg);
        top: 0;
    }
    
    .mobile-menu-toggle.active .hamburger::after {
        transform: rotate(-45deg);
        bottom: 0;
    }
    
    /* Mobile Navigation Menu */
    .mobile-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
        z-index: 999;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 80px 24px 24px;
        overflow-y: auto;
    }
    
    .mobile-nav.active {
        right: 0;
    }
    
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-nav li {
        margin-bottom: 8px;
    }
    
    .mobile-nav a {
        display: block;
        padding: 16px;
        text-decoration: none;
        color: #333;
        font-weight: 500;
        border-radius: 8px;
        transition: background 0.2s ease;
    }
    
    .mobile-nav a:hover,
    .mobile-nav a.active {
        background: #f0f9ff;
        color: #1a56db;
    }
    
    /* Main content adjustments for fixed header */
    main {
        padding-top: 70px !important;
    }
    
    /* Hero Section - Mobile */
    .hero, .region-hero {
        padding: 2rem 0 !important;
        text-align: center !important;
        min-height: auto !important;
    }
    
    .hero .container,
    .region-hero .container {
        flex-direction: column !important;
        gap: 2rem !important;
    }
    
    .hero-content,
    .region-hero .hero-content {
        order: 1;
        width: 100% !important;
        text-align: center !important;
    }
    
    .hero-image,
    .region-hero .hero-image {
        order: 2;
        width: 100% !important;
        margin-top: 1rem !important;
    }
    
    .hero-image img,
    .region-hero .hero-image img {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 12px !important;
    }
    
    .hero-actions,
    .region-hero .hero-actions {
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }
    
    .hero-actions .btn,
    .region-hero .hero-actions .btn {
        width: 100% !important;
        margin: 4px 0 !important;
    }
    
    /* Cards & Grids - Stack on Mobile */
    .grid-2,
    .grid-3,
    .grid-4,
    .services-grid,
    .features-grid,
    .apps-grid,
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .card,
    .service-card,
    .feature-card,
    .app-card {
        width: 100% !important;
        margin-bottom: 1rem !important;
        padding: 1.5rem !important;
    }
    
    /* Forms - Mobile Optimized */
    form {
        width: 100% !important;
    }
    
    input, 
    textarea, 
    select {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 14px 16px !important;
        width: 100% !important;
        margin-bottom: 12px !important;
    }
    
    /* Buttons - Mobile Friendly */
    .btn {
        display: block !important;
        width: 100% !important;
        padding: 16px !important;
        margin: 8px 0 !important;
        font-size: 1rem !important;
        min-height: 50px !important;
    }
    
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .btn-group .btn {
        margin: 4px 0 !important;
        width: 100% !important;
    }
    
    /* Tables - Scrollable on Mobile */
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
    
    /* Modals - Full Screen on Mobile */
    .modal-content {
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    
    /* Footer - Stacked on Mobile */
    footer {
        padding: 2rem 0 1rem !important;
    }
    
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center !important;
    }
    
    .footer-col {
        margin-bottom: 2rem !important;
    }
    
    /* Region Switcher - Mobile */
    .region-switcher {
        width: 100% !important;
        margin: 1rem 0 !important;
    }
    
    .region-switcher-btn {
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    .region-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90% !important;
        max-width: 400px !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
    
    /* Hide unnecessary elements on mobile */
    .desktop-nav,
    .carousel-controls,
    .sidebar {
        display: none !important;
    }
}

/* ===== TABLET OPTIMIZATIONS (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding-left: 24px !important;
        padding-right: 24px !important;
        max-width: 100% !important;
    }
    
    /* Typography for Tablet */
    h1 {
        font-size: 2.25rem !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
    }
    
    /* Grids - 2 columns on tablet */
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .services-grid,
    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    /* Hero Layout */
    .hero .container,
    .region-hero .container {
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .hero-content,
    .region-hero .hero-content {
        flex: 1 !important;
    }
    
    .hero-image,
    .region-hero .hero-image {
        flex: 1 !important;
    }
    
    /* Navigation - Tablet */
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .desktop-nav {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 1rem !important;
    }
    
    /* Forms - Tablet */
    .form-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Buttons - Tablet */
    .btn-group {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }
    
    .btn-group .btn {
        flex: 1 !important;
        min-width: 150px !important;
    }
}

/* ===== DESKOPT SMALL (1024px - 1199px) ===== */
@media (min-width: 1024px) and (max-width: 1199px) {
    .container {
        max-width: 980px !important;
    }
    
    /* 3 columns for medium screens */
    .grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===== DESKTOP LARGE (1200px+) ===== */
@media (min-width: 1200px) {
    .container {
        max-width: 1200px !important;
    }
    
    /* Full grid on large screens */
    .grid-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ===== ORIENTATION SPECIFIC STYLES ===== */
@media (orientation: portrait) {
    .hero-image img {
        max-height: 50vh !important;
        object-fit: cover !important;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    /* Optimize for landscape mobile */
    header {
        padding: 8px 0 !important;
    }
    
    .hero, .region-hero {
        padding: 1rem 0 !important;
        min-height: auto !important;
    }
    
    main {
        padding-top: 60px !important;
    }
}

/* ===== HIGH-DPI (RETINA) DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Use higher resolution images */
    .hero-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===== 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;
    }
}

/* ===== DARK MODE MOBILE OPTIMIZATIONS ===== */
@media (prefers-color-scheme: dark) {
    .mobile-nav {
        background: #1f2937 !important;
        color: #f9fafb !important;
    }
    
    .mobile-nav a {
        color: #e5e7eb !important;
    }
    
    .mobile-nav a:hover {
        background: #374151 !important;
    }
    
    .hamburger {
        background: #f9fafb !important;
    }
}

/* ===== IOS SPECIFIC FIXES ===== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .ios-input-fix {
        font-size: 16px !important; /* Prevent zoom on focus */
    }
    
    /* Fix for 100vh issue on iOS */
    .full-height-ios {
        height: -webkit-fill-available !important;
    }
}

/* ===== ANDROID SPECIFIC FIXES ===== */
@supports not (-webkit-touch-callout: none) {
    /* Android specific styles */
    .android-fix {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}