/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* Copyright (C) 2025 Michal Marvan */

/* === Mobile + tablet responsive foundation === */
/* Visible < 1024px; hidden ≥ 1024px (desktop keeps existing nav) */

.bim-mobile-topbar,
.bim-mobile-tabs {
    display: none;
}

@media (max-width: 1023px) {
    /* Hide existing desktop navbar */
    .navbar { display: none !important; }

    /* Top bar */
    .bim-mobile-topbar {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 8500;
        height: calc(48px + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        align-items: center;
        justify-content: space-between;
        padding-left: 16px;
        padding-right: 16px;
        background: var(--primary-gradient, linear-gradient(135deg, #667eea 0%, #5568d3 100%));
        color: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    }
    .bim-mobile-topbar__brand {
        display: flex;
        align-items: center;
        gap: 10px;
        text-decoration: none;
        color: white;
    }
    .bim-mobile-topbar__icon {
        width: 28px;
        height: 28px;
        border-radius: 6px;
        background: rgba(255,255,255,0.18);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
    }
    .bim-mobile-topbar__name {
        font-weight: 700;
        font-size: 16px;
        letter-spacing: -0.3px;
    }
    .bim-mobile-topbar__settings {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255,255,255,0.18);
        border: none;
        color: white;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .bim-mobile-topbar__settings:hover { background: rgba(255,255,255,0.28); }

    /* Bottom tabs */
    .bim-mobile-tabs {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 8500;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        align-items: stretch;
        background: var(--bg-primary, #fff);
        border-top: 1px solid var(--border-primary, #e5e7eb);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
    }
    .bim-mobile-tabs__tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        text-decoration: none;
        color: var(--text-tertiary, #6b7280);
        font-size: 11px;
        font-weight: 500;
        transition: color 0.15s;
        min-height: 44px;
    }
    .bim-mobile-tabs__tab.is-active {
        color: var(--primary-color, #667eea);
    }
    .bim-mobile-tabs__icon {
        font-size: 22px;
        line-height: 1;
    }
    .bim-mobile-tabs__label { line-height: 1; }

    /* Reserve space at bottom of body so content not overlapped by fixed tabs */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* On tablet (768-1023): slightly larger touch targets */
    @media (min-width: 768px) {
        .bim-mobile-topbar { padding-left: 24px; padding-right: 24px; }
        .bim-mobile-tabs__tab { font-size: 12px; }
        .bim-mobile-tabs__icon { font-size: 24px; }
    }

    /* Compact footer < 1024px */
    .footer-modern .footer-tech { display: none; }
    .footer-modern .footer-content {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .footer-modern .footer-meta {
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    /* === Mobile modals (fullscreen < 1024px) === */
    /* Overrides common.css/ai-chat.css/ids-*.css .modal-container defaults via higher specificity. */
    /* Works for both .show (legacy) and .active (AI Settings, Phase 7+) open states. */
    .modal-overlay {
        padding: 0;
    }
    .modal-overlay.show,
    .modal-overlay.active {
        display: flex;
        align-items: stretch;
    }
    .modal-overlay.show .modal-container,
    .modal-overlay.active .modal-container {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .modal-overlay.show .modal-header,
    .modal-overlay.active .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        border-radius: 0;
        padding: 16px 20px;
        flex-shrink: 0;
    }
    .modal-overlay.show .modal-header h2,
    .modal-overlay.active .modal-header h2 {
        font-size: 1.2em;
    }
    .modal-overlay.show .modal-close,
    .modal-overlay.active .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.3em;
    }
    .modal-overlay.show .modal-body,
    .modal-overlay.active .modal-body {
        padding: 16px 20px;
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-overlay.show .modal-footer,
    .modal-overlay.active .modal-footer {
        padding: 12px 20px;
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
        flex-shrink: 0;
    }
}
