/* Mobile Optimizations for IUPI EXPRESS */
/* Mobile First Approach */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Reset and Base */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    body {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        font-size: 16px;
    }
    
    /* Container Adjustments */
    .container {
        padding: 0 16px;
        max-width: 100%;
    }
    
    /* Header Mobile Optimized */
    .header {
        position: fixed;
        width: 100%;
        top: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        padding: 12px 0;
    }
    
    .nav {
        padding: 0;
    }
    
    .nav-logo svg {
        width: 120px;
        height: 36px;
    }
    
    /* Mobile Menu */
    .nav-menu {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #ffffff;
        flex-direction: column;
        padding: 24px 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        margin: 0;
        padding: 16px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a {
        display: block;
        font-size: 18px;
        font-weight: 500;
        color: #1a1a1a;
        padding: 8px 0;
    }
    
    .nav-actions {
        display: none;
    }
    
    .nav-menu.active ~ .nav-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 24px 16px 0;
        border-top: 2px solid #f0f0f0;
    }
    
    .nav-toggle {
        display: flex;
        width: 32px;
        height: 32px;
        padding: 0;
        background: none;
        border: none;
        cursor: pointer;
    }
    
    /* Hero Mobile */
    .hero {
        margin-top: 60px;
        padding: 40px 0 60px;
        min-height: auto;
    }
    
    .hero-background {
        display: none;
    }
    
    .hero-title {
        font-size: 32px;
        line-height: 1.2;
        margin-bottom: 16px;
        text-align: center;
    }
    
    .hero-title .gradient-text {
        display: block;
        margin-top: 8px;
    }
    
    .hero-subtitle {
        font-size: 16px;
        line-height: 1.6;
        text-align: center;
        padding: 0 16px;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-top: 32px;
    }
    
    .btn-large {
        width: 100%;
        padding: 16px 24px;
        font-size: 16px;
        font-weight: 600;
    }
    
    .hero-link {
        text-align: center;
        font-size: 16px;
        padding: 12px;
    }
    
    /* Social Proof Mobile */
    .social-proof {
        padding: 40px 0;
        overflow: hidden;
    }
    
    .section-title-small {
        font-size: 16px;
        line-height: 1.4;
        text-align: center;
        padding: 0 16px;
        margin-bottom: 24px;
    }
    
    .logos-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 0 16px;
        max-width: 100%;
    }
    
    .logo-item {
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
    }
    
    .logo-item svg {
        max-width: 80%;
        height: auto;
    }
    
    /* Features Mobile */
    .features {
        padding: 60px 0;
        overflow: hidden;
    }
    
    .section-title {
        font-size: 28px;
        line-height: 1.3;
        text-align: center;
        padding: 0 24px;
        margin-bottom: 32px;
    }
    
    .features-grid,
    .features-grid.three-columns {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 0 16px;
        max-width: 100%;
    }
    
    .feature-card {
        padding: 32px 24px;
        text-align: center;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .feature-icon {
        margin: 0 auto 24px;
        width: 60px;
        height: 60px;
    }
    
    .feature-icon svg {
        width: 100%;
        height: 100%;
        max-width: 48px;
        max-height: 48px;
    }
    
    .feature-card h3 {
        font-size: 22px;
        margin-bottom: 16px;
    }
    
    .feature-card p {
        font-size: 15px;
        line-height: 1.6;
    }
    
    /* Pricing Mobile */
    .pricing {
        padding: 60px 0;
    }
    
    .pricing-card {
        margin: 0 16px;
        border-radius: 16px;
    }
    
    .pricing-header {
        padding: 32px 24px;
    }
    
    .pricing-header h3 {
        font-size: 24px;
    }
    
    .price {
        margin-top: 16px;
    }
    
    .price .currency {
        font-size: 20px;
    }
    
    .price .amount {
        font-size: 42px;
    }
    
    .price .period {
        font-size: 16px;
    }
    
    .pricing-features {
        padding: 32px 24px;
    }
    
    .pricing-features h4 {
        font-size: 18px;
        margin-bottom: 20px;
    }
    
    .pricing-features li {
        font-size: 15px;
        padding: 8px 0;
    }
    
    .pricing-cta {
        padding: 0 24px 32px;
    }
    
    /* Steps Mobile */
    .how-it-works {
        padding: 60px 0;
    }
    
    .steps-container {
        flex-direction: column;
        gap: 32px;
        padding: 0 16px;
    }
    
    .step {
        width: 100%;
        text-align: center;
        padding: 24px;
    }
    
    .step-number {
        margin: 0 auto 16px;
    }
    
    .step h3 {
        font-size: 20px;
    }
    
    .step-arrow {
        transform: rotate(90deg);
        font-size: 24px;
        color: #0066FF;
    }
    
    /* API Documentation Mobile */
    .api-preview {
        padding: 60px 0;
    }
    
    .api-container {
        flex-direction: column;
        margin: 0 16px;
    }
    
    .api-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #f0f0f0;
        padding: 0 0 16px;
        margin-bottom: 24px;
    }
    
    .api-sidebar h4 {
        display: none;
    }
    
    .api-menu {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding: 0 0 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .api-menu::-webkit-scrollbar {
        display: none;
    }
    
    .api-menu li {
        white-space: nowrap;
        padding: 8px 16px;
        background: #f5f5f5;
        border-radius: 20px;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s;
        flex-shrink: 0;
    }
    
    .api-menu li.active {
        background: #0066FF;
        color: white;
    }
    
    .api-content {
        width: 100%;
        padding: 0;
    }
    
    .api-section h3 {
        font-size: 22px;
        margin-bottom: 16px;
    }
    
    .code-block {
        margin: 16px 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .code-header {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .code-header button {
        font-size: 12px;
        padding: 4px 12px;
    }
    
    .code-block pre {
        padding: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 13px;
    }
    
    .code-block code {
        font-size: 13px;
        line-height: 1.5;
    }
    
    /* About Mobile */
    .about {
        padding: 60px 0;
        overflow: hidden;
    }
    
    .about-content {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 0 16px;
        max-width: 100%;
    }
    
    .about-text {
        max-width: 100%;
    }
    
    .about-text h3 {
        font-size: 24px;
        margin-bottom: 16px;
    }
    
    .about-text p {
        font-size: 15px;
        line-height: 1.6;
        word-wrap: break-word;
    }
    
    .about-stats {
        display: flex;
        flex-direction: column;
        gap: 16px;
        margin-top: 32px;
    }
    
    .stat {
        background: #f8f9fa;
        padding: 20px;
        border-radius: 12px;
        text-align: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .stat h4 {
        font-size: 32px;
        margin-bottom: 8px;
        color: #0066FF;
    }
    
    .stat p {
        font-size: 14px;
        color: #666;
        margin: 0;
    }
    
    .about-info {
        padding: 24px 20px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .about-info h4 {
        font-size: 18px;
        margin-bottom: 16px;
    }
    
    .company-info {
        padding: 0;
        margin: 0;
    }
    
    .company-info li {
        font-size: 14px;
        padding: 10px 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Contact Mobile */
    .contact {
        padding: 60px 0;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 0 16px;
    }
    
    .contact-info h3 {
        font-size: 24px;
    }
    
    .contact-info p {
        font-size: 15px;
    }
    
    .contact-items {
        gap: 20px;
    }
    
    .contact-item {
        padding: 16px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    /* CTA Final Mobile */
    .cta-final {
        padding: 60px 0;
        text-align: center;
    }
    
    .section-subtitle {
        font-size: 16px;
        padding: 0 24px;
    }
    
    /* Footer Mobile */
    .footer {
        padding: 48px 0 24px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 40px;
        padding: 0 16px;
    }
    
    .footer-brand {
        text-align: center;
    }
    
    .footer-brand svg {
        margin-bottom: 16px;
    }
    
    .footer-desc {
        font-size: 14px;
    }
    
    .footer-links {
        grid-template-columns: 1fr;
        gap: 32px;
        text-align: left;
    }
    
    .footer-links h5 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    .footer-links ul {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .footer-links a {
        font-size: 14px;
        padding: 4px 0;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 24px 16px 0;
        font-size: 12px;
    }
    
    /* Modal Mobile */
    .modal {
        padding: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 16px auto;
        padding: 32px 24px;
        border-radius: 16px;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }
    
    .modal-large {
        width: 100%;
        max-width: none;
    }
    
    .modal-content h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    .close {
        font-size: 32px;
        width: 32px;
        height: 32px;
        top: 16px;
        right: 16px;
    }
    
    /* Form Mobile */
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form input,
    .form select,
    .form textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
        border-radius: 8px;
    }
    
    .form select {
        background-size: 16px;
        padding-right: 40px;
    }
    
    .checkbox {
        align-items: flex-start;
        gap: 12px;
    }
    
    .checkbox input[type="checkbox"] {
        margin-top: 2px;
        width: 20px;
        height: 20px;
    }
    
    .checkbox span {
        font-size: 14px;
        line-height: 1.4;
    }
    
    .btn-full {
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
    }
    
    .form-footer {
        font-size: 14px;
        margin-top: 24px;
    }
    
    /* Tables Mobile */
    table {
        font-size: 14px;
    }
    
    .cookie-table,
    .risk-table,
    .sector-risk-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    /* SDK Grid Mobile */
    .sdk-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .sdk-item {
        padding: 16px;
    }
    
    /* API Footer Mobile */
    .api-footer {
        flex-direction: column;
        gap: 12px;
        margin-top: 32px;
    }
    
    .api-footer .btn-secondary,
    .api-footer .btn-primary {
        width: 100%;
    }
}

/* Small Mobile Devices */
@media (max-width: 360px) {
    .hero-title {
        font-size: 28px;
    }
    
    .section-title {
        font-size: 24px;
    }
    
    .price .amount {
        font-size: 36px;
    }
    
    .logos-grid {
        grid-template-columns: 1fr;
    }
    
    .about-stats {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .stat {
        padding: 16px;
        background: #f8f9fa;
        border-radius: 8px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        padding: 32px 0;
    }
    
    .hero-title {
        font-size: 28px;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .about-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .logos-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch Device Specific */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    a,
    button,
    input,
    select,
    textarea,
    .nav-menu li,
    .api-menu li {
        min-height: 44px;
    }
    
    /* Remove hover effects */
    .feature-card:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    }
    
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }
    
    /* Add active states */
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
    }
    
    /* Improve scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix iOS form zoom */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Fix iOS momentum scrolling */
    .nav-menu,
    .modal,
    .modal-content,
    .api-menu,
    .code-block pre {
        -webkit-overflow-scrolling: touch;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid #0066FF;
    }
    
    .btn-secondary {
        border: 2px solid #333;
    }
    
    .feature-card,
    .pricing-card {
        border: 2px solid #333;
    }
}

/* 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 Support */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed in future */
}

/* Critical Mobile Fixes */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    main,
    section,
    .container,
    .hero-content,
    .features-grid,
    .about-content,
    .contact-grid,
    .footer-content {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Fix feature cards breaking layout */
    .features .container {
        width: 100%;
        max-width: 100%;
        padding: 0 16px;
    }
    
    .features-grid {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .feature-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    
    /* Fix SVG icons size */
    .feature-icon svg,
    .logo-item svg {
        width: 100%;
        height: 100%;
        max-width: 100%;
    }
    
    /* Ensure all text wraps properly */
    p, h1, h2, h3, h4, h5, h6, li, td, th {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Fix about section layout */
    .about-content {
        width: 100%;
        max-width: 100%;
    }
    
    .about-info {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    .company-info li {
        white-space: normal;
        word-break: break-word;
    }
    
    /* Ensure modals don't break */
    .modal-content {
        max-width: calc(100vw - 32px);
    }
    
    /* Fix any absolute positioned elements */
    [style*="position: absolute"] {
        max-width: 100vw !important;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .container {
        padding: 0 12px;
    }
    
    .feature-card {
        padding: 24px 16px;
    }
    
    .pricing-card {
        margin: 0 12px;
    }
    
    .about-stats .stat {
        padding: 16px 12px;
    }
}