/* Additional Mobile Enhancements and Touch Feedback */

/* ========================================
   TOUCH FEEDBACK & INTERACTION STATES
   ======================================== */

/* Touch active states for better feedback */
.touch-active,
.nav-link:active,
.btn-primary:active,
.btn-secondary:active,
.suggestion-card:active,
.category-link:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Improved focus states for accessibility */
.nav-link:focus,
.btn-primary:focus,
.btn-secondary:focus,
.category-link:focus,
.control-btn:focus,
.lang-btn:focus {
    outline: 2px solid #0084ff;
    outline-offset: 2px;
}

/* ========================================
   SMOOTH SCROLLING & PERFORMANCE
   ======================================== */

/* Smooth momentum scrolling on iOS */
.nav-links,
.chat-messages,
.comparison-table-container,
.process-steps {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent text selection on interactive elements */
.mobile-menu-toggle,
.btn-primary,
.btn-secondary,
.nav-link,
.category-link,
.suggestion-card,
.lang-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   MOBILE-SPECIFIC ANIMATIONS
   ======================================== */

/* Reduced motion for better performance */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimized animations for mobile */
@media (max-width: 768px) {
    /* Disable complex animations on mobile for performance */
    .worker-node {
        animation: none;
    }

    .gradient-text {
        animation: none;
        background-position: 0% 50%;
    }

    /* Simpler hover effects */
    .category-card,
    .benefit-item,
    .process-step {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
}

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

@media (max-width: 768px) {
    /* Better readability on mobile */
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    /* Consistent line heights */
    p, li {
        line-height: 1.6;
    }

    /* Prevent orphans in headings */
    h1, h2, h3 {
        text-wrap: balance;
    }
}

/* ========================================
   MOBILE INPUT IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Larger touch targets for inputs */
    input,
    textarea,
    select,
    button {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Better input styling */
    .chat-textarea {
        font-size: 16px;
        line-height: 1.5;
        padding: 12px;
    }

    /* Improved form spacing */
    form > * + * {
        margin-top: 16px;
    }
}

/* ========================================
   MOBILE LOADING STATES
   ======================================== */

/* Loading spinner for mobile */
.mobile-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 132, 255, 0.2);
    border-top-color: #0084ff;
    border-radius: 50%;
    animation: mobile-spin 0.8s linear infinite;
    z-index: 10000;
}

@keyframes mobile-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========================================
   MOBILE SCROLL INDICATORS
   ======================================== */

/* Horizontal scroll indicators */
.scroll-indicator-left,
.scroll-indicator-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: linear-gradient(90deg, rgba(10, 14, 26, 0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.scroll-indicator-right {
    right: 0;
    background: linear-gradient(-90deg, rgba(10, 14, 26, 0.9), transparent);
}

.scroll-indicator-left {
    left: 0;
}

.has-scroll .scroll-indicator-right,
.has-scroll .scroll-indicator-left {
    opacity: 1;
}

/* ========================================
   MOBILE PULL-TO-REFRESH PREVENTION
   ======================================== */

/* Prevent pull-to-refresh when modal is open */
body.menu-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
    -webkit-overflow-scrolling: auto;
}

/* ========================================
   MOBILE SAFE AREAS (iPhone X+)
   ======================================== */

/* Support for iPhone X and newer */
@supports (padding: max(0px)) {
    .navbar {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .nav-links {
        padding-top: max(80px, calc(80px + env(safe-area-inset-top)));
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }

    .chat-footer {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

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

/* ========================================
   MOBILE DARK MODE ADJUSTMENTS
   ======================================== */

@media (prefers-color-scheme: dark) and (max-width: 768px) {
    /* Adjust colors for better contrast in dark mode */
    .mobile-menu-toggle span {
        background: #f1f5f9;
    }

    .nav-links {
        background: linear-gradient(135deg, #000000 0%, #0a0e1a 100%);
    }

    .suggestion-card {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* ========================================
   MOBILE ORIENTATION CHANGES
   ======================================== */

/* Handle orientation change smoothly */
@media (orientation: portrait) {
    .hero-visual {
        order: 2;
    }

    .hero-text {
        order: 1;
    }
}

@media (orientation: landscape) and (max-width: 812px) {
    .navbar {
        padding: 0.5rem 1rem;
    }

    .logo-image {
        height: 21px;
    }

    .hero {
        min-height: calc(100vh - 60px);
    }
}

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

@media (max-width: 768px) {
    /* Use GPU acceleration for smooth animations */
    .mobile-menu-toggle,
    .nav-links,
    .mobile-nav-overlay {
        will-change: transform, opacity;
    }

    /* Optimize paint operations */
    .category-card,
    .benefit-item,
    .process-step {
        will-change: auto;
        backface-visibility: hidden;
        transform: translateZ(0);
    }

    /* Reduce shadow complexity on mobile */
    .category-card:hover,
    .benefit-item:hover {
        box-shadow: 0 10px 20px rgba(0, 132, 255, 0.15);
    }
}

/* ========================================
   MOBILE ACCESSIBILITY IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Better focus indicators */
    *:focus-visible {
        outline: 3px solid #0084ff;
        outline-offset: 2px;
    }

    /* Skip to main content link */
    .skip-to-main {
        position: absolute;
        top: -40px;
        left: 0;
        background: #0084ff;
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 10001;
    }

    .skip-to-main:focus {
        top: 0;
    }

    /* Larger clickable areas */
    a, button {
        position: relative;
    }

    a::after,
    button::after {
        content: '';
        position: absolute;
        top: -8px;
        right: -8px;
        bottom: -8px;
        left: -8px;
    }
}

/* ========================================
   MOBILE ERROR STATES
   ======================================== */

.mobile-error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px;
    font-size: 14px;
    text-align: center;
}

/* ========================================
   MOBILE TOAST NOTIFICATIONS
   ======================================== */

.mobile-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 14, 26, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10002;
    animation: slide-up 0.3s ease;
    max-width: calc(100% - 40px);
}

@keyframes slide-up {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ========================================
   MOBILE BOTTOM NAVIGATION (Optional)
   ======================================== */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 14, 26, 0.98);
    border-top: 1px solid rgba(0, 132, 255, 0.2);
    padding: 8px 0;
    z-index: 998;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px;
        color: #a0a9b8;
        text-decoration: none;
        font-size: 11px;
        transition: color 0.2s ease;
    }

    .mobile-bottom-nav-item.active,
    .mobile-bottom-nav-item:active {
        color: #0084ff;
    }

    .mobile-bottom-nav-icon {
        width: 24px;
        height: 24px;
    }

    /* Adjust content for bottom nav */
    body.has-bottom-nav {
        padding-bottom: 60px;
    }
}