/* CompanionAI - Mobile-first responsive overrides */
/* Include after page styles so these take effect on small screens */

/* Safe area for notched devices (iPhone X+) */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .chat-page .input-area {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}
@supports (padding: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}

/* Hide scrollbars globally but keep scroll functionality */
html, body {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}
/* Firefox: hide scrollbars on common scrollable containers */
.hero-companion-strip,
.hero-companion-list,
.header-nav,
#headerNav,
.header-mobile-drawer,
.search-suggestions,
.notify-panel,
.quick-actions,
.mobile-tool-panel,
.main-content,
.companions-main-wrap,
.advanced-grid,
#chat-messages,
.chat-menu-tabs,
.emoji-picker-grid,
.feature-sheet,
.stories-sheet-inner {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Prevent horizontal overflow on all pages */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Minimum touch target size (44px) for interactive elements */
@media (max-width: 768px) {
    .lang-toggle,
    .user-avatar,
    .back-btn,
    .header-actions button,
    .nav-item {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .nav-item {
        padding: 8px 4px;
    }
    .filter-tab {
        padding: 12px 18px;
    }
    .send-btn {
        min-height: 44px;
    }

    .header-top-nav {
        display: none;
    }

    .companions-header-bottom {
        gap: 8px;
    }

    .companions-header-bottom span {
        font-size: 0.68rem;
    }

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

/* Container padding on small screens */
@media (max-width: 480px) {
    .container,
    .main-content,
    .profile-content,
    .payment-page {
        padding-left: 16px;
        padding-right: 16px;
    }
    .header {
        padding-left: 12px;
        padding-right: 12px;
    }
    .bottom-nav {
        padding-left: 8px;
        padding-right: 8px;
    }

    .companions-main-wrap {
        padding: 138px 12px 12px;
    }

    .companions-hero {
        border-radius: 14px;
        padding: 20px 12px;
    }

    .companions-hero h1 {
        font-size: 1.45rem;
    }

    .advanced-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .companion-actions {
        grid-template-columns: 1fr;
    }

    .threejs-quote-modal {
        width: min(96vw, 680px);
        margin-top: 8vh;
    }

    .threejs-canvas-host {
        height: 270px;
    }

    .threejs-quote-text {
        font-size: 0.86rem;
    }

    .companions-footer {
        padding: 20px 12px 100px;
    }
}

/* Typography scaling on very small screens */
@media (max-width: 360px) {
    html {
        font-size: 14px;
    }
    .hero h1,
    .page-header h1 {
        font-size: 1.5rem !important;
    }
    .logo span,
    .header-logo {
        font-size: 1.1rem !important;
    }

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

    .threejs-canvas-host {
        height: 220px;
    }
}

/* Full-screen modals on mobile */
@media (max-width: 480px) {
    [id$="-modal"] {
        align-items: flex-start !important;
        padding: 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    [id$="-modal"] > div {
        max-width: 100% !important;
        max-height: none !important;
        margin: auto 0 !important;
    }
    .home-companion-grid {
        max-height: 50vh !important;
        overflow-y: auto !important;
    }
}

/* Shared mobile hardening for all templates */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .header-nav,
    #headerNav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        white-space: nowrap;
    }
    .header-nav::-webkit-scrollbar,
    #headerNav::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 680px) {
    .search-wrap,
    #searchWrap,
    .notify-wrap,
    .avatar-wrap {
        width: 100% !important;
        max-width: 100% !important;
    }
    .quick-actions,
    .notify-panel,
    .search-suggestions {
        right: 0 !important;
        left: auto !important;
        width: min(92vw, 360px) !important;
        max-width: calc(100vw - 16px) !important;
    }
}
