/* LightLink AI - Responsive Styles */

/* Tablet Styles */
@media (max-width: 1024px) {
    :root {
        --section-padding: 80px 0;
    }

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

    .hero-visual {
        width: 300px;
        height: 300px;
        right: -30px;
    }

    .logo-mark-large {
        width: 250px;
        height: 250px;
    }

    .logo-symbol-large {
        font-size: 3rem;
    }

    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--spacing-xl);
    }

    .integrations-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--spacing-lg);
    }

    .about-illustration {
        width: 250px;
        height: 250px;
    }
    
    .pricing-grid,
    .pricing-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet/Small Desktop - Demo Modal adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .demo-modal-content {
        width: 90%;
        height: 85vh;
        max-height: 85vh;
    }

    .business-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    /* Prevent any accidental horizontal overflow on mobile */
    html, body { overflow-x: hidden; }
    img, svg { max-width: 100%; height: auto; }

    /* Prevent scrolling when modal is open */
    body:has(.demo-modal.active) {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    :root {
        --section-padding: 64px 0;
        --spacing-3xl: 2rem;
        --spacing-2xl: 1.5rem;
    }

    .hero {
        min-height: auto;
        padding-top: var(--spacing-3xl);
        text-align: center;
    }

    .hero-title {
        font-size: 2.25rem;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1.125rem;
    }

    .hero-visual {
        position: relative;
        width: 100%;
        height: 200px;
        margin-top: var(--spacing-xl);
        right: 0;
        opacity: 1 !important; /* Ensure visibility on mobile */
    }

    /* Keep background glow inside viewport on small screens */
    .hero-bg-glow {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 100vw;
        height: 100vw;
        max-width: 100vw;
        max-height: 100vw;
    }

    .logo-mark-large {
        width: 180px;
        height: 180px;
    }

    .logo-symbol-large {
        font-size: 2.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }

    .feature-card {
        padding: var(--spacing-xl);
    }

    .integrations-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }

    .integration-item {
        padding: var(--spacing-md);
    }

    .demo-content {
        gap: var(--spacing-2xl);
    }

    
    /* Hide old demo section on mobile - users will use demo-chat page or widget */
    .demo {
        display: none;
    }

    .pricing-grid,
    .pricing-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .pricing-card {
        padding: var(--spacing-lg);
    }

    .about-content {
        gap: var(--spacing-2xl);
    }

    .about-stats {
        gap: var(--spacing-md);
    }

    .contact-content {
        gap: var(--spacing-2xl);
    }

    .contact-form {
        padding: var(--spacing-xl);
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }

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

    .hero-subtitle {
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .section-subtitle {
        font-size: 1rem;
    }

    .page-hero {
        padding: var(--spacing-2xl) 0 var(--spacing-xl) 0;
    }

    .page-title {
        font-size: 2rem;
    }

    .page-subtitle {
        font-size: 1rem;
    }

    .cta-title {
        font-size: 1.75rem;
    }
    
    .pricing-grid,
    .pricing-grid-4 {
        grid-template-columns: 1fr;
    }

    /* Также для планшетов */
    .pricing-grid {
        grid-template-columns: 1fr;
    }

    .cta-subtitle {
        font-size: 1rem;
    }

    .cta-title {
        font-size: 2rem;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .cta-buttons .btn-large {
        width: 100%;
    }

    /* Demo Modal - Full Screen on Mobile */
    .demo-modal-content {
        width: 100%;
        height: 100vh; /* Fallback for older browsers */
        height: 100dvh; /* Dynamic viewport height - adjusts with keyboard */
        max-height: 100vh; /* Fallback */
        max-height: 100dvh;
        padding: 0;
        border-radius: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    /* Support for older iOS versions */
    @supports (-webkit-touch-callout: none) {
        .demo-modal-content {
            height: -webkit-fill-available;
        }
    }

    .demo-modal-close {
        position: fixed;
        top: var(--spacing-md);
        right: var(--spacing-md);
        z-index: 10001;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    .demo-modal-close svg {
        width: 28px;
        height: 28px;
    }

    .demo-modal-close:hover {
        background: rgba(0, 0, 0, 0.7);
        transform: none; /* Remove rotation on mobile for better UX */
    }

    .demo-modal-close:active {
        background: rgba(0, 0, 0, 0.8);
        transform: scale(0.9);
    }

    /* Business Selector - Mobile adjustments */
    .business-selector {
        padding: var(--spacing-2xl) var(--spacing-md);
        padding-right: calc(var(--spacing-md) + 17px);
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        scrollbar-gutter: stable;
    }

    .business-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .business-card {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .business-icon {
        font-size: 2rem;
    }

    .business-name {
        font-size: 0.875rem;
    }

    .business-selector-title {
        font-size: 1.25rem;
        padding-top: var(--spacing-lg);
    }

    .business-selector-subtitle {
        font-size: 0.875rem;
    }

    /* Chat Interface - Full Screen with Keyboard Support */
    .chat-interface {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .chat-interface {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        max-height: none;
    }

    /* Chat Header */
    .chat-interface .chat-header {
        flex-shrink: 0;
        border-radius: 0;
        padding: var(--spacing-md);
        padding-left: 60px !important;
        background: var(--gradient-primary);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Chat Messages - Flexible scrolling area */
    .chat-interface .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: var(--spacing-md);
        min-height: 0; /* Important for flex scrolling */
        max-height: none;
    }

    /* Chat Input - Fixed at bottom */
    .chat-interface .chat-input {
        flex-shrink: 0;
        border-radius: 0;
        padding: var(--spacing-md);
        background: var(--color-surface-gray);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        position: sticky;
        bottom: 0;
        z-index: 10;
    }

    .chat-interface .chat-input input {
        font-size: 16px; /* Prevent zoom on iOS */
        -webkit-appearance: none;
    }

    /* Improve touch scrolling */
    .chat-messages {
        scroll-behavior: smooth;
    }

    /* Safe area for notched devices */
    @supports (padding: env(safe-area-inset-bottom)) {
        .chat-interface .chat-input {
            padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
        }
        
        .demo-modal-close {
            top: calc(var(--spacing-md) + env(safe-area-inset-top));
        }
    }
    
    /* Prevent bounce scroll on iOS */
    .chat-interface .chat-messages {
        overscroll-behavior: contain;
    }
    
    /* Prevent pull-to-refresh on modal */
    .demo-modal.active {
        overscroll-behavior-y: contain;
    }
    
    /* Better touch feedback */
    .chat-interface .send-btn,
    .chat-interface .chat-input input {
        touch-action: manipulation;
    }

    /* Chat Widget Mobile */
    .chat-widget-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
        position: fixed;
        z-index: 9998;
    }

    .chat-widget-button svg {
        width: 24px;
        height: 24px;
    }

    .chat-widget {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        height: 80vh;
        max-height: 80vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .chat-widget.minimized {
        height: auto;
        left: auto;
        right: 16px;
        width: 300px;
        bottom: 80px;
    }

    .chat-widget-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .chat-widget-header .chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .chat-widget-header .chat-info h4 {
        font-size: 0.875rem;
    }

    .chat-widget-body {
        padding: var(--spacing-md);
    }

    .chat-widget-minimize,
    .chat-widget-close {
        width: 28px;
        height: 28px;
    }

    .chat-widget-minimize svg,
    .chat-widget-close svg {
        width: 16px;
        height: 16px;
    }

    .integrations-grid {
        grid-template-columns: 1fr;
    }

    .footer-links {
        text-align: center;
    }

    .footer-section {
        margin-bottom: var(--spacing-xl);
    }

    .btn {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 0.875rem;
    }

    .btn-large {
        padding: var(--spacing-lg) var(--spacing-xl);
        font-size: 1rem;
    }
}

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}

/* Navigation Mobile Menu */
@media (max-width: 768px) {
    .navbar {
        padding: var(--spacing-sm) 0;
        position: fixed;
        width: 100%;
    }

    .navbar-container {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
        position: relative;
    }

    .navbar-brand {
        font-size: 1rem;
        flex: 0 1 auto;
    }

    .navbar-brand .logo-img {
        width: 28px;
        height: 28px;
    }

    .language-toggle {
        order: 2;
        margin-left: auto;
        padding: 1px;
    }

    .lang-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .navbar-toggle {
        display: flex;
        order: 3;
        margin-left: var(--spacing-sm);
    }

    .navbar-cta {
        order: 4;
        margin-left: var(--spacing-sm);
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-height: auto;
    }

    .navbar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        width: 100%;
        background: rgba(10, 14, 23, 0.98);
        backdrop-filter: blur(10px);
        display: flex;
        flex-direction: column;
        padding: 0 var(--spacing-lg);
        gap: var(--spacing-lg);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
        z-index: 999;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }

    .navbar-menu.active {
        max-height: calc(100vh - 60px);
        padding: var(--spacing-xl) var(--spacing-lg);
        overflow-y: auto;
    }

    .navbar-menu .nav-link {
        font-size: 1.125rem;
        padding: var(--spacing-sm) 0;
        width: 100%;
    }

    /* Mobile dropdown styles */
    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: var(--spacing-sm) 0;
    }

    .nav-dropdown-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        background: rgba(255, 255, 255, 0.03);
        border: none;
        border-radius: var(--radius-sm);
        margin-top: var(--spacing-sm);
        margin-left: var(--spacing-md);
        padding: var(--spacing-sm) 0;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
    }

    .nav-dropdown.active .nav-dropdown-menu {
        max-height: 500px;
        padding: var(--spacing-sm) 0;
    }

    .nav-dropdown-item {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 1rem;
    }

    .navbar-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .navbar-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .navbar-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }

    .feature-card:hover,
    .integration-item:hover,
    .pricing-card:hover {
        transform: none;
    }

    .nav-link:hover::after {
        width: 0;
    }

    .nav-link.active::after {
        width: 100%;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-surface-gray: #2a2e37;
        --color-text-muted: #ffffff;
    }

    .feature-card,
    .integration-item,
    .pricing-card,
    .contact-form {
        border: 2px solid rgba(255, 255, 255, 0.2);
    }
}

/* Reduced motion support */
@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;
    }
}

/* Print styles */
@media print {
    .navbar,
    .hero-ctas,
    .demo-actions,
    .footer-social {
        display: none !important;
    }

    .hero {
        min-height: auto;
        background: white !important;
        color: black !important;
    }

    .hero-title {
        color: black !important;
        -webkit-text-fill-color: black !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .section {
        page-break-inside: avoid;
    }
}

/* Dark mode support (for future expansion) */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark mode */
}

/* Landscape mobile optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 80vh;
        padding-top: 100px;
    }

    .section {
        padding: var(--spacing-xl) 0;
    }
}
