/* Mobile Responsive Styles */
html,
body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
    margin: 0;
}

@media (max-width: 768px) {

    /* Mobile Header */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.5rem;
        background-color: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 40;
        width: 100%;
        box-sizing: border-box;
        transition: all 0.3s ease;
    }

    .mobile-header.scrolled {
        padding: 0.4rem 1.5rem;
        background-color: rgba(9, 9, 11, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .mobile-logo {
        font-family: 'Space Grotesk', sans-serif;
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-primary);
        transition: font-size 0.3s ease;
        line-height: 1;
    }

    .mobile-header.scrolled .mobile-logo {
        font-size: 1rem;
    }

    .mobile-logo .dot {
        width: 8px;
        height: 8px;
        border-radius: 999px;
        margin-left: 6px;
        display: inline-block;
        background: #22c55e;
        box-shadow:
            0 0 6px rgba(34, 197, 94, 0.35),
            0 0 18px rgba(34, 197, 94, 0.22);
        animation: runai-led-breathe 5.5s ease-in-out infinite;
        font-size: 0;
        line-height: 0;
        vertical-align: middle;
        position: relative;
        top: -1px;
    }

    @keyframes runai-led-breathe {
        0%,
        100% {
            opacity: 0.35;
            transform: scale(0.92);
            box-shadow:
                0 0 4px rgba(34, 197, 94, 0.25),
                0 0 12px rgba(34, 197, 94, 0.18);
        }
        50% {
            opacity: 1;
            transform: scale(1);
            box-shadow:
                0 0 10px rgba(34, 197, 94, 0.55),
                0 0 28px rgba(34, 197, 94, 0.35);
        }
    }

    /* Sidebar */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100% !important;
        transform: translateX(-100%);
        width: 85%;
        max-width: 300px;
        box-shadow: 20px 0 40px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
        z-index: 1000;
        visibility: hidden;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
    }

    /* Overlay for sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 40;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* SweetAlert2 Mobile Overrides */
    div:where(.swal2-container) div:where(.swal2-popup) {
        padding: 1.25rem 1rem !important;
        width: 92% !important;
        max-width: 92% !important;
        margin: 0 auto !important;
        border-radius: 24px !important;
    }

    div:where(.swal2-container) h2:where(.swal2-title) {
        font-size: 1.3rem !important;
        margin-bottom: 0.5rem !important;
    }

    div:where(.swal2-container) div:where(.swal2-html-container) {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
        margin: 0.5rem 0 1rem !important;
    }

    div:where(.swal2-container) .swal2-actions {
        margin-top: 1rem !important;
        gap: 0.5rem !important;
        width: 100%;
        flex-direction: row;
        /* Keep row but ensure they fit */
        flex-wrap: wrap;
        justify-content: center;
    }

    div:where(.swal2-container) button.swal2-styled {
        font-size: 0.9rem !important;
        padding: 0.6rem 1.2rem !important;
        margin: 0 !important;
        flex: 1;
        /* Distribute space */
        min-width: 100px;
    }

    /* Main Content */
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 1.5rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        /* Use % instead of vw to avoid scrollbar issues */
        overflow-x: hidden !important;
        position: relative !important;
        left: 0 !important;
        box-sizing: border-box !important;
    }

    /* Chat Layout Specifics - Restore full screen */
    .main-content.chat-layout {
        padding: 0 !important;
        overflow: hidden !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        height: 100dvh !important;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-right {
        width: 100%;
    }

    .date-display {
        font-size: 0.875rem;
        color: var(--text-muted);
        background-color: var(--bg-card);
        padding: 0.5rem 1rem;
        border-radius: 6px;
        border: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .content-grid {
        grid-template-columns: 1fr !important;
    }

    .card-body {
        overflow-x: auto;
    }

    /* Disable body flex on mobile to prevent layout issues */
    body.dashboard-page {
        display: block !important;
        overflow-x: hidden !important;
        padding: 70px 0 0 0 !important; /* Top padding for fixed header */
        margin: 0 !important;
        width: 100% !important;
    }

    /* Chat page has no top mobile header */
    body.dashboard-page.chat-mode {
        padding: 0 !important;
    }

    /* Chat Mode Overrides */
    body.chat-mode {
        overflow: hidden !important;
        position: fixed !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        height: 100dvh !important;
        width: 100% !important;
    }

    .main-content.chat-layout {
        background: radial-gradient(circle at 50% 0%, #2a2a35 0%, #09090b 60%);
    }

    /* Chat Header */
    .chat-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        width: auto !important;
        padding: 1rem;
        gap: 0;
        justify-content: space-between;
        align-items: flex-start;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        z-index: 100;
        box-sizing: border-box !important;
    }

    /* Removed .mobile-header-controls styles */

    /* Hamburger Menu */
    .mobile-menu-btn,
    .burger-menu {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: var(--text-primary);
        font-size: 1rem;
        width: 36px;
        height: 36px;
        cursor: pointer;
        margin-right: 0;
        flex-shrink: 0;
    }

    /* Mobile Model Selector */
    .model-selector-container {
        position: static;
        /* Allow expansion */
        display: flex;
        align-items: center;
    }

    .model-toggle-mobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: #ffffff !important;
        font-size: 1rem;
        cursor: pointer;
        z-index: 20;
    }

    .model-toggle-mobile i {
        color: #ffffff !important;
    }

    /* Remove fade mask on mobile */
    body.chat-mode .messages-container {
        mask-image: none !important;
        -webkit-mask-image: none !important;
        mask: none !important;
        padding-bottom: 6rem !important;
        /* Ensure space for footer */
    }

    .model-selector-wrapper {
        display: none !important;
        /* Hidden by default on mobile */
    }

    .model-selector-container.active .model-selector-wrapper {
        display: flex !important;
        position: absolute;
        top: 0;
        left: 0;
        /* Align to left edge */
        width: auto;
        /* Auto width to fit content */
        min-width: 160px;
        max-width: 70vw;
        height: 100%;
        background: var(--bg-card);
        z-index: 2000;
        padding: 0 0.5rem;
        border-radius: 12px;
        justify-content: space-between;
        align-items: center;
        border: 1px solid var(--border-color);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

    .model-selector-container.active .model-selector-wrapper select {
        width: 40vw;
        max-width: 150px;
        font-size: 0.85rem;
        padding: 0.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: transparent;
        color: var(--text-primary);
        border: none;
    }

    .model-close-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 1.2rem;
        cursor: pointer;
        flex-shrink: 0;
    }

    .desktop-only {
        display: none !important;
    }

    /* Remove fade mask on mobile */
    .messages-container {
        mask-image: none !important;
        -webkit-mask-image: none !important;
        padding: 0 0 1rem 0 !important;
        /* Small bottom padding */
    }

    .message {
        gap: 0 !important;
        /* No gap needed without avatar */
        max-width: 100%;
        overflow-x: hidden;
        /* Prevent horizontal overflow */
    }

    .avatar {
        display: none !important;
        /* Hide avatar on mobile */
    }

    .message-content {
        flex: 1;
        min-width: 0;
        width: auto;
        max-width: 100%;
        font-size: 0.95rem;
        padding: 0.75rem 0rem;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .header-actions {
        display: none !important;
    }

    /* Chat Body */
    .chat-body {
        padding: 5rem 0 0;
        /* Increased side padding for safety */
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .main-chat-area {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0 1rem;
        box-sizing: border-box;
    }

    .chat-footer {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0.75rem 0 calc(1.25rem + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

    .input-wrapper {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .message.user .message-content {
        border-radius: 18px 18px 4px 18px;
    }

    /* Fix Welcome Message Contrast */
    .message-content p {
        color: #e5e7eb !important;
        /* Force light color */
    }

    .message-content strong {
        color: #ffffff !important;
    }

    .chat-footer textarea {
        min-height: 40px;
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 8px 12px;
    }

    .input-wrapper {
        max-width: 100%;
    }

    .input-box {
        padding: 0.5rem;
        border-radius: 16px;
    }

    .input-actions {
        padding: 0 0.25rem;
    }

    .send-btn {
        width: 40px;
        height: 40px;
        border-radius: 100px;
    }

    /* Hide tooltips or hover effects on mobile */
    [title]:hover::after {
        display: none;
    }

    /* Search Bar Mobile */
    .search-container.active {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-card);
        z-index: 100;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
    }

    .search-input-wrapper {
        width: 100%;
    }

    /* Voice Overlay Mobile */
    .voice-visualizer-container {
        width: 90%;
        height: 150px;
    }

    /* Hide Voice Button on Mobile */
    #voiceBtn {
        display: none !important;
    }

    /* Message Actions (Copy/Speak) */
    .message-actions {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .chat-body {
        padding: 6rem 2rem 10rem;
    }
}

/* =========================================
   WEBSITE RESPONSIVE STYLES (Landing Page)
   ========================================= */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    padding: 0.5rem;
    position: relative;
    /* Ensure z-index works */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 1200px) {

    /* Header & Navigation */
    header {
        left: 0;
        transform: none;
        width: 100%;
    }

    header.scrolled {
        width: 100%;
        max-width: 100%;
        top: 0;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(5, 5, 5, 0.95);
        /* Ensure background is solid enough */
    }

    .container {
        width: 100%;
        padding: 0 1.25rem;
        /* Reduce container padding to gain width */
    }

    header .container {
        justify-content: space-between;
        padding: 0 1.25rem;
        /* Match general container padding */
        height: 70px;
        width: 100%;
        /* Ensure container takes full width */
    }

    header.scrolled .container {
        height: 60px;
        width: 100%;
    }

    .mobile-menu-toggle {
        display: block;
        order: 3;
        /* Place it on the right */
    }

    /* Hide desktop actions in header, show in mobile menu if needed */
    header .header-actions {
        display: none !important;
    }

    header .header-divider {
        display: none !important;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(5, 5, 5, 0.98);
        /* Increased opacity */
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transform: translateY(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        /* Slightly lower than toggle button */
    }

    .main-nav.active {
        transform: translateY(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0.85rem !important;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center;
    }

    .main-nav li {
        margin: 0 !important;
        padding: 0 !important;
    }

    .mobile-only-nav-item {
        display: block;
        margin-top: 1.15rem;
        padding-top: 1.4rem;
        border-top: 1px solid var(--border);
    }

    .mobile-only-nav-item .mobile-nav-btn {
        margin-top: 1rem;
    }

    .header-divider {
        display: none;
    }

    .mobile-nav-btn {
        width: auto;
        min-width: 200px;
        justify-content: center;
        font-size: 1.1rem;
        padding: 0.8rem 2rem;
    }

    .main-nav a.nav-link {
        font-size: 1.35rem;
        font-weight: 600;
        padding: 0.2rem 0;
    }

    .main-nav a.nav-link.nav-link-cta {
        font-size: 1.1rem;
        padding: 5px 15px;
        min-width: 200px;
    }

    /* Hero Section */
    .hero {
        padding-top: 80px;
        min-height: auto;
        padding-bottom: 2rem;
    }

    /* General Section Spacing */
    section,
    .video-section,
    .privacy-section,
    .features,
    .billing-section,
    .chat-section {
        padding: 40px 0 !important;
    }

    .hero .container {
        flex-direction: column;
        text-align: center;
        align-items: center;
        /* Ensure flex items are centered */
    }

    .hero-content {
        max-width: 100%;
        margin-bottom: 3rem;
        text-align: center;
        /* Explicitly center text */
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Center children like buttons */
    }

    .hero-content h1 {
        font-size: 2.5rem;
        line-height: 1.2;
        text-align: center;
        width: 100%;
        word-wrap: break-word;
        /* Prevent long words from overflowing */
        overflow-wrap: break-word;
    }

    .hero-content .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
        text-align: center;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
        /* Ensure it doesn't overflow */
    }

    .cta-group {
        justify-content: center;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: center;
    }

    .cta-button {
        width: 100%;
        text-align:center;
        font-size: 14px;
        font-weight: 600;
    }

    .hero-visual {
        width: 100%;
        height: 300px;
    }

    /* Features Section */
    .feature-grid {
        grid-template-columns: 1fr;
        /* Stack cards */
        gap: 1rem;
        /* Reduce gap */
    }

    .feature-card {
        padding: 2rem 1.5rem;
        /* Reduce internal padding */
    }

    .section-header h2 {
        font-size: 2rem;
    }

    /* Billing Section */
    .billing-wrapper {
        flex-direction: column;
        gap: 3rem;
    }

    .billing-content,
    .billing-visual {
        width: 100%;
    }

    .billing-visual {
        order: 1;
    }

    /* Footer */
    footer .container {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 1.5rem;
    }

    /* Use Cases Section */
    .use-cases-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .use-case-card {
        padding: 2rem 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .uc-icon {
        margin-bottom: 1.5rem;
    }

    /* Modal Adjustments */
    .auth-modal-overlay {
        padding: 10px;
    }

    .auth-modal-content {
        width: 100%;
        padding: 1.25rem;
    }

    .modal-close {
        top: 10px;
        right: 10px;
        background: rgba(255, 255, 255, 0.05);
        /* Make it slightly visible to ensure contrast */
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
    }

    /* Contact Form */
    .contact-form-container {
        padding: 1.5rem;
    }

    .form-group input,
    .form-group textarea {
        padding: 0.8rem;
    }

    .info-item {
        padding: 1rem;
        gap: 1rem;
    }
}

/* Tablet Adjustments for Website */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-content h1 {
        font-size: 3rem;
    }

    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        width: 95%;
    }
}