/* ============================================
   MOBILE OPTIMIZATIONS FOR DAF-DEVS PORTFOLIO
   ============================================ */

/* ===== MOBILE-FIRST IMPROVEMENTS ===== */

/* Better Touch Targets - Minimum 48x48px for comfortable tapping */
@media (max-width: 768px) {
    /* Navigation Links */
    .nav-item a {
        padding: 12px 16px !important;
        min-height: 48px;
        display: flex;
        align-items: center;
        font-size: 16px !important;
    }

    /* All Buttons */
    .btn-primary,
    .btn-outline,
    .btn-secondary,
    button {
        min-height: 48px !important;
        padding: 12px 24px !important;
        font-size: 16px !important;
    }

    /* Mobile Menu Toggle - Larger Touch Area */
    .mobile-menu-toggle {
        padding: 12px !important;
        min-width: 48px;
        min-height: 48px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(0, 230, 118, 0.2);
    }

    /* Form Inputs - Better for Mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        min-height: 48px;
        padding: 12px 16px !important;
        border-radius: 8px;
    }

    textarea {
        min-height: 120px !important;
    }

    /* Service Cards - Better Spacing */
    .service-card {
        padding: 24px !important;
        margin-bottom: 20px;
    }

    /* Portfolio Items */
    .portfolio-item {
        margin-bottom: 24px;
    }

    /* Hero Section - Mobile Optimization */
    .hero-section h1 {
        font-size: 2rem !important;
        line-height: 1.2;
    }

    .hero-section p {
        font-size: 1.1rem !important;
    }

    /* Hero service pills grid - 2 columns on mobile */
    .hero-section .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .hero-service-pill {
        width: 100% !important;
        justify-content: flex-start !important;
        padding: 8px !important;
        font-size: 0.875rem !important;
    }

    .hero-service-pill .w-10 {
        width: 32px !important;
        height: 32px !important;
    }

    /* Section Padding */
    section {
        padding: 60px 20px !important;
    }

    /* Testimonial Cards */
    .testimonial-card {
        padding: 24px !important;
    }

    /* Footer Links */
    .footer a {
        padding: 8px 0;
        display: inline-block;
    }
}

/* ===== MOBILE MENU ENHANCEMENTS ===== */

/* Overlay for Mobile Menu */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Close Button for Mobile Menu */
.mobile-menu-close {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 0;
    -webkit-tap-highlight-color: rgba(0, 230, 118, 0.2);
}

@media (max-width: 992px) {
    .navbar-nav.active ~ .mobile-menu-overlay,
    .navbar-nav.active .mobile-menu-close {
        display: block;
    }
}

/* ===== TOUCH FEEDBACK ===== */

/* Touch Highlight for Better Feedback */
a, button, .clickable {
    -webkit-tap-highlight-color: rgba(0, 230, 118, 0.2);
    -webkit-touch-callout: none;
}

/* Active States for Touch */
@media (hover: none) and (pointer: coarse) {
    .btn-primary:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .service-card:active {
        transform: scale(0.99);
    }

    .portfolio-item:active {
        opacity: 0.95;
    }
}

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

/* Lazy Loading Images */
img[loading="lazy"],
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

img[loading="lazy"].loaded,
img[data-src].loaded {
    opacity: 1;
    background: none;
    animation: none;
}

@keyframes loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Reduce Motion for Performance */
@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;
    }
}

/* Low-end device optimizations */
.low-end-device .glass-bg,
.low-end-device [class*="glass"] {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.low-end-device [data-aos] {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
}

/* Optimize repaints and reflows */
@media (max-width: 768px) {
    * {
        will-change: auto !important;
    }

    /* Only optimize properties that actually animate */
    .btn-primary,
    .btn-outline,
    .service-card,
    .portfolio-item {
        will-change: transform, opacity;
    }

    /* Use transform for animations instead of position */
    .scroll-to-top,
    .admin-login {
        will-change: transform, opacity;
    }

    /* Hardware acceleration for smooth animations */
    .navbar-nav,
    .mobile-menu-overlay,
    .modal-content {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* Optimize fonts loading */
.fonts-loaded body {
    font-family: 'Roboto', sans-serif;
}

.fonts-loaded h1,
.fonts-loaded h2,
.fonts-loaded h3,
.fonts-loaded h4,
.fonts-loaded h5,
.fonts-loaded h6 {
    font-family: 'Montserrat', sans-serif;
}

/* Reduce paint areas on scroll */
@media (max-width: 768px) {
    .navbar {
        contain: layout style;
    }

    .service-card,
    .portfolio-item,
    .testimonial-card {
        contain: layout paint;
    }
}

/* ===== MOBILE TYPOGRAPHY ===== */

@media (max-width: 768px) {
    /* Better Readability on Mobile */
    body {
        font-size: 16px;
        line-height: 1.7;
        letter-spacing: 0.3px;
    }

    h1 {
        font-size: 2rem !important;
        line-height: 1.25;
        margin-bottom: 1.25rem;
        letter-spacing: -0.5px;
    }

    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3;
        margin-bottom: 1.25rem;
        letter-spacing: -0.4px;
    }

    h3 {
        font-size: 1.5rem !important;
        line-height: 1.4;
        margin-bottom: 1rem;
        letter-spacing: -0.3px;
    }

    h4 {
        font-size: 1.25rem !important;
        line-height: 1.4;
        margin-bottom: 0.875rem;
    }

    h5 {
        font-size: 1.125rem !important;
        margin-bottom: 0.75rem;
    }

    h6 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem;
    }

    p {
        font-size: 1rem;
        line-height: 1.7;
        margin-bottom: 1.25rem;
    }

    /* Section Headings */
    .section-title {
        font-size: 1.875rem !important;
        margin-bottom: 1.75rem;
        line-height: 1.3;
    }

    .section-subtitle {
        font-size: 1rem !important;
        line-height: 1.6;
        margin-bottom: 1rem;
    }

    /* List Spacing */
    ul, ol {
        margin-bottom: 1.25rem;
        padding-left: 1.5rem;
    }

    li {
        margin-bottom: 0.75rem;
        line-height: 1.6;
    }

    /* Better vertical rhythm */
    .hero-section {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }

    /* Card Content Spacing */
    .service-card h3,
    .portfolio-item h3,
    .testimonial-card h4 {
        margin-top: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .service-card p,
    .portfolio-item p,
    .testimonial-card p {
        margin-bottom: 1rem;
        line-height: 1.7;
    }

    /* Stats/Counter Spacing */
    .stat-number,
    .counter {
        font-size: 2.25rem !important;
        margin-bottom: 0.5rem;
    }

    .stat-label {
        font-size: 0.9rem;
        line-height: 1.4;
    }
}

/* ===== MOBILE NAVIGATION IMPROVEMENTS ===== */

@media (max-width: 992px) {
    .navbar {
        padding: 12px 16px !important;
        min-height: 60px;
    }

    .navbar-brand img {
        height: 36px !important;
    }

    /* Mobile Menu Improvements */
    .navbar-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: var(--color-primary);
        padding: 80px 20px 20px 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transition: left 0.3s ease;
        z-index: 1001;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.5);
    }

    .navbar-nav.active {
        left: 0;
    }

    .navbar-nav .nav-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
    }

    .navbar-nav .nav-item:last-child {
        border-bottom: none;
    }

    .navbar-nav .nav-item a {
        display: block;
        width: 100%;
        padding: 16px 12px;
    }

    /* Reduce navbar height when scrolled */
    .navbar.scrolled {
        padding: 8px 16px !important;
        min-height: 56px;
    }

    /* Theme toggle in navbar - better positioning */
    .theme-toggle {
        width: 44px !important;
        height: 44px !important;
    }
}

/* ===== SCROLL TO TOP BUTTON - MOBILE ===== */

@media (max-width: 768px) {
    #scrollTopBtn,
    #scrollToTop,
    .scroll-to-top {
        width: 48px !important;
        height: 48px !important;
        bottom: 80px !important;
        right: 20px !important;
        font-size: 20px !important;
    }

    /* Admin Login Button - Larger Touch Target */
    .admin-login {
        width: 56px !important;
        height: 56px !important;
        bottom: 24px !important;
        right: 24px !important;
    }

    /* Portfolio Filter Buttons - Better Touch Targets */
    .portfolio-filters button,
    .filter-btn {
        padding: 12px 20px !important;
        min-height: 48px !important;
        font-size: 15px !important;
        margin: 4px !important;
    }

    /* Admin Tab Buttons */
    .admin-tabs button,
    .admin-tab-btn {
        padding: 14px 24px !important;
        min-height: 48px !important;
        font-size: 16px !important;
    }

    /* Social Media Icons */
    .footer .social-links a,
    .social-icon {
        min-width: 48px !important;
        min-height: 48px !important;
        padding: 12px !important;
    }

    /* Calculator Option Buttons */
    .calc-option,
    .calculator-option {
        padding: 16px !important;
        min-height: 56px !important;
    }

    /* Close Buttons in Modals */
    .close-modal,
    .admin-panel-close,
    .mobile-menu-close {
        min-width: 48px !important;
        min-height: 48px !important;
        padding: 12px !important;
    }
}

/* ===== FORMS - MOBILE OPTIMIZATION ===== */

@media (max-width: 768px) {
    .contact-form {
        padding: 24px 20px !important;
        border-radius: 12px;
    }

    .calculator-container {
        padding: 24px 20px !important;
    }

    .calc-option {
        padding: 16px !important;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .calc-option:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    /* Better Select Dropdowns on Mobile */
    select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300e676' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px !important;
        cursor: pointer;
    }

    /* Native select styling for better mobile experience */
    select:focus {
        outline: 3px solid var(--color-accent);
        outline-offset: 2px;
    }

    /* Form Groups */
    .form-group {
        margin-bottom: 1.25rem;
    }

    /* Labels */
    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
        font-size: 15px;
    }

    /* Input Focus States - Prevent zoom on iOS */
    input:focus,
    textarea:focus,
    select:focus {
        border-color: var(--color-accent);
        box-shadow: 0 0 0 3px var(--color-accent-glow);
    }

    /* Radio and Checkbox - Larger touch targets */
    input[type="radio"],
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
        margin-right: 12px;
        cursor: pointer;
    }

    /* Radio/Checkbox Labels */
    input[type="radio"] + label,
    input[type="checkbox"] + label {
        display: inline-flex;
        align-items: center;
        min-height: 48px;
        padding: 8px 0;
        cursor: pointer;
    }

    /* Submit Buttons in Forms */
    .contact-form button[type="submit"],
    .calculator-container button[type="submit"],
    form button[type="submit"] {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
        font-weight: 600;
        margin-top: 1rem;
    }

    /* Form Validation Messages */
    .error-message,
    .success-message {
        padding: 12px 16px;
        border-radius: 8px;
        margin-bottom: 1rem;
        font-size: 14px;
    }

    /* Admin Panel Forms */
    .admin-form input,
    .admin-form textarea,
    .admin-form select {
        width: 100%;
        margin-bottom: 1rem;
    }
}

/* ===== CARDS & GRID IMPROVEMENTS ===== */

@media (max-width: 768px) {
    /* 2-column grid layout for mobile - FORCE OVERRIDE */
    .grid,
    div.grid,
    section .grid,
    .container .grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Flex containers to wrap with 2 columns */
    .flex-wrap {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 12px !important;
    }

    .flex-wrap > * {
        flex: 0 0 calc(50% - 6px) !important;
        max-width: calc(50% - 6px) !important;
    }

    /* Ensure all cards use proper width for 2-column layout */
    .service-card,
    .portfolio-item,
    .testimonial-card,
    .feature-card,
    .glass-card,
    [class*="card"] {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    /* Card Shadows - Lighter on Mobile */
    .service-card,
    .portfolio-item,
    .testimonial-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    /* Feature Cards - compact padding for 2 columns */
    .feature-card {
        padding: 16px !important;
    }

    .service-card,
    .portfolio-item,
    .testimonial-card {
        padding: 16px !important;
    }

    /* Override Tailwind grid classes for 2 columns */
    .grid-cols-2,
    .grid-cols-3,
    .md\:grid-cols-2,
    .md\:grid-cols-3,
    .lg\:grid-cols-2,
    .lg\:grid-cols-3,
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Container width */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Remove any negative margins */
    .mx-auto,
    .mx-4,
    [class*="mx-"] {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Full width sections */
    section {
        width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Reduce font sizes for better fit in 2 columns */
    .service-card h3,
    .portfolio-item h3,
    .testimonial-card h4 {
        font-size: 1rem !important;
        margin-bottom: 8px !important;
    }

    .service-card p,
    .portfolio-item p,
    .testimonial-card p {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }

    /* Icons in cards - smaller for 2 columns */
    .service-icon,
    .feature-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
    }
}

/* ===== MODAL / POPUP IMPROVEMENTS ===== */

@media (max-width: 768px) {
    .modal,
    .popup {
        padding: 16px;
        align-items: flex-end;
    }

    .modal-content,
    .popup-content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0 !important;
        -webkit-overflow-scrolling: touch;
        animation: slideUpModal 0.3s ease-out;
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Service Modal Improvements */
    .service-modal .modal-content,
    #serviceModal .modal-content {
        padding: 24px 20px !important;
    }

    .service-modal h3,
    #serviceModal h3 {
        font-size: 1.5rem !important;
        margin-bottom: 1rem;
    }

    .service-modal p,
    #serviceModal p {
        font-size: 1rem;
        line-height: 1.7;
        margin-bottom: 1rem;
    }

    /* Calculator Modal */
    .calculator-modal .modal-content {
        max-height: 90vh;
    }

    /* Modal Close Button - Better positioning */
    .modal-content .close-modal,
    .popup-content .close-modal {
        position: sticky;
        top: 16px;
        right: 16px;
        z-index: 10;
        background: var(--color-accent);
        color: var(--color-dark);
    }

    /* Prevent body scroll when modal open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* ===== STICKY ELEMENTS ON MOBILE ===== */

@media (max-width: 768px) {
    .navbar {
        position: sticky !important;
        top: 0;
        z-index: 1000;
    }
}

/* ===== IMAGES - MOBILE OPTIMIZATION ===== */

@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }

    .project-image,
    .portfolio-image {
        object-fit: cover;
        width: 100%;
    }

    /* Hero Images */
    .hero-section img {
        max-height: 300px;
        object-fit: contain;
    }
}

/* ===== PERFORMANCE - REDUCE ANIMATIONS ON MOBILE ===== */

@media (max-width: 768px) {
    /* Simpler animations for better performance */
    [data-aos] {
        animation-duration: 0.6s !important;
    }

    /* Disable complex animations */
    .animate-float,
    .animate-pulse {
        animation: none !important;
    }
}

/* ===== ACCESSIBILITY - MOBILE ===== */

/* Larger Focus Indicators */
@media (max-width: 768px) {
    a:focus,
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 3px solid var(--color-accent);
        outline-offset: 2px;
    }
}

/* ===== ORIENTATION - LANDSCAPE MODE ===== */

@media (max-width: 926px) and (orientation: landscape) {
    section {
        padding: 40px 20px !important;
    }

    .hero-section {
        min-height: auto !important;
        padding: 60px 20px !important;
    }
}

/* ===== SAFE AREA INSETS (iPhone X+) ===== */

@supports (padding: max(0px)) {
    .navbar,
    .footer {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .navbar-nav {
        padding-left: max(20px, env(safe-area-inset-left));
    }

    #scrollTopBtn,
    #scrollToTop,
    .scroll-to-top {
        right: max(20px, env(safe-area-inset-right));
        bottom: max(80px, env(safe-area-inset-bottom));
    }
}

/* ===== TABLET BREAKPOINT (768px - 992px) ===== */

@media (min-width: 768px) and (max-width: 992px) {
    /* Tablet specific styles */
    .container {
        max-width: 720px;
        padding: 0 30px;
    }

    /* 2-column grid for tablets */
    .grid,
    .services-grid,
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px;
    }

    /* Hero Section */
    .hero-section h1 {
        font-size: 2.5rem !important;
    }

    .hero-section p {
        font-size: 1.2rem !important;
    }

    /* Section Padding */
    section {
        padding: 80px 30px !important;
    }

    /* Cards */
    .service-card,
    .portfolio-item,
    .testimonial-card {
        padding: 28px !important;
    }

    /* Buttons remain same size as desktop */
    .btn-primary,
    .btn-outline {
        padding: 12px 28px !important;
    }
}

/* ===== SMALL PHONE BREAKPOINT (375px and below) ===== */

@media (max-width: 375px) {
    /* Extra small phones - iPhone SE, etc. */
    body {
        font-size: 14px;
    }

    /* Smaller typography */
    h1 {
        font-size: 1.75rem !important;
    }

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

    h3 {
        font-size: 1.25rem !important;
    }

    h4 {
        font-size: 1.1rem !important;
    }

    /* Hero Section */
    .hero-section h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }

    .hero-section p {
        font-size: 1rem !important;
    }

    /* Reduce padding to save space */
    section {
        padding: 50px 12px !important;
    }

    .service-card,
    .portfolio-item,
    .testimonial-card {
        padding: 12px !important;
    }

    /* Smaller gaps for 2-column layout on tiny screens */
    .grid {
        gap: 8px !important;
    }

    /* Reduce container padding */
    .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Even smaller fonts for 2-column cards */
    .service-card h3,
    .portfolio-item h3,
    .testimonial-card h4 {
        font-size: 0.9rem !important;
    }

    .service-card p,
    .portfolio-item p,
    .testimonial-card p {
        font-size: 0.8rem !important;
    }

    /* Buttons - slightly smaller but still touch-friendly */
    .btn-primary,
    .btn-outline,
    button {
        padding: 12px 16px !important;
        font-size: 14px !important;
    }

    /* Navigation */
    .navbar {
        padding: 10px 12px !important;
    }

    .navbar-brand img {
        height: 32px !important;
    }

    /* Mobile menu narrower on small screens */
    .navbar-nav {
        width: 85%;
        max-width: 280px;
    }

    /* Form inputs - maintain 16px for iOS zoom prevention */
    input,
    textarea,
    select {
        font-size: 16px !important;
        padding: 10px 12px !important;
    }

    /* Calculator */
    .calculator-container {
        padding: 16px !important;
    }

    .calc-option {
        padding: 12px !important;
        font-size: 14px !important;
    }

    /* Modal adjustments */
    .modal-content,
    .popup-content {
        width: 98% !important;
        margin: 8px !important;
        padding: 16px !important;
    }

    /* Admin button positioning */
    .admin-login {
        width: 48px !important;
        height: 48px !important;
        bottom: 16px !important;
        right: 12px !important;
    }

    /* Scroll to top button */
    #scrollTopBtn,
    #scrollToTop,
    .scroll-to-top {
        width: 44px !important;
        height: 44px !important;
        bottom: 64px !important;
        right: 12px !important;
    }

    /* Hero service pills - smaller icons */
    .hero-service-pill {
        padding: 6px !important;
        font-size: 0.75rem !important;
    }

    .hero-service-pill .w-10 {
        width: 28px !important;
        height: 28px !important;
    }
}

/* ===== MEDIUM PHONE BREAKPOINT (376px - 425px) ===== */

@media (min-width: 376px) and (max-width: 425px) {
    /* Standard phone sizes - iPhone 6/7/8, Galaxy S20/S21, Pixel 5/6, etc. */
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 1.875rem !important;
    }

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

    /* Hero Section */
    .hero-section h1 {
        font-size: 1.875rem !important;
    }

    .hero-section p {
        font-size: 1.05rem !important;
    }

    /* Balanced padding */
    section {
        padding: 55px 18px !important;
    }

    .service-card,
    .portfolio-item,
    .testimonial-card {
        padding: 22px !important;
    }

    /* Mobile menu */
    .navbar-nav {
        width: 82%;
        max-width: 300px;
    }
}

/* ===== ANDROID-SPECIFIC OPTIMIZATIONS ===== */

/* Large Android Phones (426px - 480px) - Galaxy S21+, Pixel 7 Pro, OnePlus, etc. */
@media (min-width: 426px) and (max-width: 480px) {
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 2.125rem !important;
    }

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

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

    section {
        padding: 60px 20px !important;
    }

    .service-card,
    .portfolio-item,
    .testimonial-card {
        padding: 24px !important;
    }

    .navbar-nav {
        width: 80%;
        max-width: 340px;
    }
}

/* Extra Large Android Phones (481px - 600px) - Galaxy S23 Ultra, Fold open, etc. */
@media (min-width: 481px) and (max-width: 600px) {
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 2.25rem !important;
    }

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

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

    section {
        padding: 70px 24px !important;
    }

    /* Can show some 2-column layouts */
    .services-grid,
    .portfolio-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }

    .navbar-nav {
        width: 75%;
        max-width: 360px;
    }
}

/* Android Material Design Optimizations */
@media (max-width: 768px) {
    /* Android ripple effect on touch */
    button,
    .btn-primary,
    .btn-outline,
    .service-card,
    .portfolio-item {
        position: relative;
        overflow: hidden;
    }

    /* Better contrast for Android AMOLED screens */
    [data-theme="dark"] {
        --color-primary: #000000; /* Pure black for AMOLED */
    }

    /* Android system fonts fallback */
    body {
        font-family: 'Roboto', 'Noto Sans', 'Droid Sans', -apple-system, system-ui, sans-serif;
    }
}

/* Samsung devices with curved edges */
@media (max-width: 480px) {
    .navbar,
    .footer {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* Android landscape mode optimizations */
@media (max-width: 926px) and (max-height: 480px) and (orientation: landscape) {
    /* Short landscape screens - many Android devices */
    .hero-section {
        min-height: 100vh !important;
        padding: 40px 20px !important;
    }

    section {
        padding: 40px 20px !important;
    }

    .navbar {
        padding: 8px 16px !important;
    }

    /* Optimize modal for landscape */
    .modal-content,
    .popup-content {
        max-height: 80vh !important;
        margin: 10px !important;
    }
}

/* ===== MATERIAL DESIGN RIPPLE EFFECT (Android) ===== */

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Android device class optimizations */
.android-device {
    /* Better scrolling on Android */
    -webkit-overflow-scrolling: touch;
}

.android-device button,
.android-device .btn-primary,
.android-device .btn-outline {
    /* Better touch response */
    -webkit-tap-highlight-color: transparent;
}

/* Old Android compatibility */
.android-old * {
    /* Disable transforms on Android < 8 for better performance */
    transform: none !important;
}

.android-old [data-aos] {
    /* No animations on old Android */
    animation: none !important;
    opacity: 1 !important;
}

/* Foldable device optimizations */
.foldable-device .container {
    max-width: 100%;
    transition: max-width 0.3s ease;
}

.device-folded .grid,
.device-folded .services-grid,
.device-folded .portfolio-grid {
    grid-template-columns: 1fr !important;
}

.device-folded .navbar-nav {
    width: 90%;
    max-width: 240px;
}

/* ===== ANDROID CHROME SPECIFIC ===== */

/* Remove Chrome Android blue highlight */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Custom highlight color */
    a, button, input, textarea, select {
        -webkit-tap-highlight-color: rgba(0, 230, 118, 0.1);
    }
}

/* Pull-to-refresh area */
@supports (overscroll-behavior: contain) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* Android notification bar color adaptation */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #000000;
    }
}

/* ===== SAMSUNG INTERNET BROWSER OPTIMIZATIONS ===== */

@media (max-width: 768px) {
    /* Samsung Internet specific fixes */
    select::-ms-expand {
        display: none;
    }

    /* Better video controls on Samsung */
    video {
        width: 100%;
        height: auto;
    }

    /* Samsung edge panel compatibility */
    .navbar,
    .footer,
    .scroll-to-top,
    .admin-login {
        margin-right: env(safe-area-inset-right, 0);
        margin-left: env(safe-area-inset-left, 0);
    }
}

/* ===== ADDITIONAL MOBILE LAYOUT FIXES ===== */

@media (max-width: 768px) {
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    /* All direct children of sections should be full width */
    section > div,
    section > .container {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Specific grid overrides for services - 2 columns */
    #services .grid,
    [id*="service"] .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        gap: 12px !important;
    }

    /* Portfolio grid - 2 columns */
    #portfolio .grid,
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        gap: 12px !important;
    }

    /* Team grid - 2 columns */
    #team .grid,
    .team-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        gap: 12px !important;
    }

    /* Testimonials - 2 columns */
    #testimonials .grid,
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        gap: 12px !important;
    }

    /* Stats/Counters - 2 columns */
    .stats .grid,
    .counters .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Flex items should wrap and be full width */
    .flex {
        flex-wrap: wrap !important;
    }

    .flex > * {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    /* Override any min-width constraints */
    * {
        min-width: 0 !important;
    }

    /* Images should not overflow */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Padding consistency */
    .px-4 {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* Gap utilities */
    .gap-12,
    .gap-8,
    .gap-6 {
        gap: 20px !important;
    }

    .gap-4,
    .gap-3 {
        gap: 12px !important;
    }
}
