/* Mobile-First Enhanced Styles */

/* Global Reset for Mobile */
* {
    box-sizing: border-box;
}

/* Ensure no horizontal scroll */
html {
    overflow-x: hidden;
    width: 100%;
    height: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Mobile Header Styles */
.mobile-header {
    display: none;
}

/* Mobile viewport optimization */
@media screen and (max-width: 768px) {
    /* Hide desktop header on mobile */
    .header {
        display: none;
    }

    /* Show mobile header */
    .mobile-header {
        display: block;
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(15, 15, 15, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-color);
        padding: 8px 12px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    .mobile-header-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .mobile-logo {
        text-decoration: none;
        flex: 1;
    }

    .mobile-logo h1 {
        color: var(--primary-color);
        font-size: 18px;
        margin: 0;
        line-height: 1.2;
    }

    .mobile-logo .tagline {
        color: var(--text-light);
        font-size: 11px;
        margin: 0;
        opacity: 0.8;
    }

    .mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-language-selector {
        padding: 6px 8px;
        font-size: 12px;
        background: var(--card-background);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        color: var(--text-color);
        min-height: 36px;
    }

    .mobile-menu-toggle {
        background: transparent;
        border: 1px solid var(--primary-color);
        color: var(--primary-color);
        padding: 6px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 20px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    .hamburger-icon {
        font-size: 18px;
        line-height: 1;
    }

    /* Mobile Navigation Overlay */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 998;
    }

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

    .mobile-nav {
        position: fixed;
        top: 52px;
        right: 0;
        width: 280px;
        height: calc(100vh - 52px);
        background: var(--card-background);
        border-left: 1px solid var(--border-color);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 999;
        overflow-y: auto;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    }

    .mobile-nav.open {
        transform: translateX(0);
    }

    .mobile-nav a {
        display: block;
        padding: 16px 20px;
        color: var(--text-color);
        text-decoration: none;
        border-bottom: 1px solid var(--border-color);
        font-size: 15px;
        transition: background 0.2s ease;
    }

    .mobile-nav a:active {
        background: rgba(139, 92, 246, 0.1);
    }

    .mobile-login-btn {
        background: var(--primary-color);
        color: white !important;
        text-align: center;
        font-weight: 600;
        margin: 16px;
        padding: 12px 20px !important;
        border-radius: 8px;
        border: none !important;
    }

    .mobile-user-info {
        padding: 16px 20px;
        border-top: 1px solid var(--border-color);
        margin-top: auto;
    }

    .mobile-user-name {
        display: block;
        color: var(--text-light);
        font-size: 14px;
        margin-bottom: 12px;
    }

    .mobile-logout-btn {
        background: var(--error-color);
        color: white;
        border: none;
        padding: 10px 16px;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        width: 100%;
    }

    /* Add padding to body to account for fixed header */
    .app {
        padding-top: 52px;
        width: 100%;
        min-height: 100vh;
        position: relative;
    }

    .main-content {
        width: 100%;
        padding: 0;
        overflow-x: hidden;
    }

    /* Mobile-optimized Landing Page */
    .landing-page {
        width: 100%;
        padding: 0;
        overflow-x: hidden;
    }

    .hero {
        width: 100%;
        min-height: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 24px 20px 20px;
        box-sizing: border-box;
    }

    .hero-content {
        text-align: center;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-title {
        font-size: clamp(2.6rem, 9vw, 3.2rem);
        line-height: 1.15;
        margin-bottom: 8px;
        padding: 0 10px;
        word-wrap: break-word;
        width: 100%;
    }

    .hero-subtitle {
        font-size: clamp(18px, 5.5vw, 22px);
        margin-bottom: 16px;
        padding: 0 10px;
        opacity: 0.85;
        line-height: 1.4;
        width: 100%;
    }

    /* Mobile CTA Button */
    .btn-large {
        width: calc(100% - 40px);
        max-width: 340px;
        padding: 16px 32px;
        font-size: 18px;
        font-weight: 600;
        border-radius: 12px;
        min-height: 54px;
        margin: 0 auto 24px auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Feature Cards Mobile */
    .features {
        width: 100%;
        padding: 20px 16px 24px;
        gap: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-sizing: border-box;
        margin: 0 auto;
    }

    .feature {
        width: 100%;
        max-width: 100%;
        padding: 24px 20px;
        text-align: center;
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        box-sizing: border-box;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .feature h3 {
        font-size: 26px;
        margin-bottom: 8px;
        font-weight: 700;
        width: 100%;
        text-align: center;
    }

    .feature p {
        font-size: 19px;
        line-height: 1.5;
        width: 100%;
        margin: 0;
        text-align: center;
    }

    /* Auth Pages Mobile */
    .auth-page {
        width: 100%;
        min-height: calc(100vh - 52px);
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .auth-container {
        width: 100%;
        max-width: 380px;
        padding: 30px 25px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        border-radius: 16px;
        box-sizing: border-box;
    }

    .auth-container h2 {
        font-size: 30px;
        margin-bottom: 20px;
    }

    /* Form Inputs Mobile */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 12px;
        margin-bottom: 6px;
        color: var(--text-light);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
        border: 2px solid var(--border-color);
        background: var(--background-light);
        color: var(--text-color);
        min-height: 48px;
    }

    .form-group input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    }

    /* Error/Success Messages Mobile */
    .error-message,
    .success-message {
        padding: 12px 16px;
        margin-bottom: 16px;
        border-radius: 8px;
        font-size: 17px;
        font-weight: 500;
    }

    /* Dashboard Mobile */
    .dashboard {
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }

    .dashboard-header {
        width: 100%;
        margin-bottom: 24px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .dashboard-header h2 {
        font-size: 30px;
        margin: 0 0 12px 0;
    }

    .dashboard-header .btn {
        width: 100%;
    }

    .history-grid {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .history-card {
        width: 100%;
        padding: 20px;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        transition: transform 0.2s ease;
        box-sizing: border-box;
    }

    .history-card:active {
        transform: scale(0.98);
    }

    /* Photo Capture Mobile */
    .photo-capture {
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }

    .upload-area {
        width: 100%;
        padding: 40px 20px;
        border-radius: 12px;
        margin: 20px 0;
        box-sizing: border-box;
    }

    .photo-preview {
        width: 100%;
        max-width: 100%;
        height: auto;
        border-radius: 8px;
        object-fit: contain;
    }

    .preview-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .preview-actions .btn {
        width: 100%;
    }

    /* Footer Mobile */
    .footer {
        width: 100%;
        padding: 30px 20px;
        background: var(--background-dark);
        box-sizing: border-box;
    }

    .footer-container {
        width: 100%;
        text-align: center;
    }

    .footer-container > p {
        font-size: 16px;
        margin-bottom: 15px;
        color: var(--text-light);
    }

    .footer-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 15px;
    }

    .footer-links a,
    .footer-links .link-button {
        font-size: 16px;
        color: var(--text-light);
        padding: 5px;
        white-space: nowrap;
    }

    /* Cookie Consent Mobile */
    .cookie-consent-banner {
        position: fixed;
        bottom: 0;
        max-height: 80vh;
        overflow-y: auto;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }

    .cookie-consent-content {
        padding: 20px 15px;
    }

    .cookie-icon {
        font-size: 32px;
        margin-bottom: 10px;
    }

    .cookie-consent-content h3 {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .cookie-consent-content > p {
        font-size: 15px;
        margin-bottom: 15px;
    }

    .cookie-details {
        max-height: 200px;
        overflow-y: auto;
        padding: 15px;
        margin: 15px 0;
        border-radius: 8px;
    }

    .cookie-actions {
        position: sticky;
        bottom: 0;
        background: var(--card-background);
        padding: 15px 0 5px;
        margin-top: 15px;
    }

    .cookie-actions .btn,
    .cookie-actions .btn-outline {
        width: 100%;
        margin-bottom: 8px;
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* Legal Pages Mobile */
    .legal-page {
        padding: 20px 10px;
    }

    .legal-container {
        padding: 20px 15px;
        border-radius: 12px;
    }

    .legal-container h1 {
        font-size: 28px;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }

    .legal-container h2 {
        font-size: 22px;
        margin-top: 20px;
        margin-bottom: 10px;
    }

    .legal-container p,
    .legal-container li {
        font-size: 17px;
        line-height: 1.7;
    }

    /* Pricing Section Mobile */
    .pricing-section {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    .pricing-title {
        font-size: clamp(1.8rem, 7vw, 2.2rem);
        margin-bottom: var(--spacing-md);
    }

    .pricing-subtitle {
        font-size: 18px;
        margin-bottom: var(--spacing-xl);
        padding: 0 10px;
    }

    .pricing-cards {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-xl);
        margin-bottom: var(--spacing-lg);
    }

    .pricing-card {
        width: 100%;
        padding: var(--spacing-lg);
    }

    .pricing-card-featured {
        transform: scale(1);
        order: -1;
    }

    .pricing-card-featured:hover {
        transform: translateY(-4px);
    }

    .pricing-plan-name {
        font-size: 26px;
    }

    .price-amount {
        font-size: 2.5rem;
    }

    .pricing-features li {
        font-size: 17px;
        padding: 10px 0;
    }

    .pricing-btn {
        font-size: 18px;
        padding: 14px;
        min-height: 54px;
    }

    .pricing-note {
        padding: var(--spacing-md);
        margin: 0 10px;
    }

    .pricing-note p {
        font-size: 16px;
    }

    /* Quick Analysis Section Mobile */
    .quick-analysis-section {
        padding: var(--spacing-lg) var(--spacing-md);
        min-height: calc(100vh - 100px);
    }

    /* Touch-friendly spacing */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
        min-width: 44px;
    }

    /* Ensure buttons are easily tappable */
    .btn {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 16px;
        font-weight: 600;
    }

    .btn:active {
        transform: scale(0.98);
    }

    /* Language Selector Mobile */
    .language-selector {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 14px;
        background: var(--card-background);
        border: 2px solid var(--border-color);
        color: var(--text-color);
    }

    /* Loading Spinner Mobile */
    .loading-spinner {
        padding: 40px 20px;
    }

    .spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
}

/* Small Mobile Devices */
@media screen and (max-width: 480px) {
    .mobile-header {
        padding: 6px 10px;
    }

    .app {
        padding-top: 48px;
    }

    .main-content {
        padding: 0;
    }

    .mobile-logo h1 {
        font-size: 16px;
    }

    .mobile-logo .tagline {
        font-size: 10px;
    }

    .mobile-language-selector {
        font-size: 11px;
        padding: 5px 6px;
        min-height: 32px;
    }

    .mobile-menu-toggle {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

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

    .hero-title {
        font-size: 1.85rem;
        margin-bottom: 8px;
    }

    .hero-subtitle {
        font-size: 16px;
        margin-bottom: 14px;
    }

    .btn-large {
        width: calc(100% - 30px);
        padding: 14px 20px;
        font-size: 15px;
        min-height: 48px;
    }

    .features {
        padding: 18px 15px 20px;
    }

    .feature {
        padding: 18px 15px;
        margin-bottom: 0;
    }

    .feature h3 {
        font-size: 19px;
        margin-bottom: 8px;
    }

    .feature p {
        font-size: 15px;
    }

    .auth-page {
        padding: 15px;
    }

    .auth-container {
        padding: 25px 20px;
        max-width: 100%;
    }

    .auth-container h2 {
        font-size: 23px;
        margin-bottom: 16px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group input {
        padding: 10px 12px;
        font-size: 16px;
        min-height: 44px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .dashboard {
        padding: 15px;
    }

    .dashboard-header h2 {
        font-size: 23px;
    }

    .history-card {
        padding: 15px;
    }

    .photo-capture {
        padding: 15px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .footer {
        padding: 25px 15px;
    }

    .footer-links a,
    .footer-links .link-button {
        font-size: 13px;
    }

    .cookie-consent-content {
        padding: 15px;
    }

    .cookie-consent-content h3 {
        font-size: 18px;
    }

    .cookie-actions .btn,
    .cookie-actions .btn-outline {
        padding: 10px 16px;
        font-size: 14px;
    }

    .legal-container {
        padding: 20px 15px;
    }
}

/* Landscape Orientation */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 20px;
    }

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

    .hero-subtitle {
        font-size: 14px;
        margin-bottom: 15px;
    }

    .features {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .header {
        -webkit-backdrop-filter: blur(10px);
    }

    input, textarea, select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

    /* Prevent double-tap zoom */
    button, a {
        touch-action: manipulation;
    }
}

/* Android-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Android browser specific styles */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-height: 48px;
    }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #0F0F0F;
        --card-background: #1F1F1F;
    }
}