/* ═══════════════════════════════════════════════════════════════
   InsuranceGrokBot Training — Mobile-First Responsive Styles
   App-like experience for phones and tablets
   ═══════════════════════════════════════════════════════════════ */

/* ── Mobile Bottom Navigation ───────────────────────────────── */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 0.4rem 0;
    padding-bottom: env(safe-area-inset-bottom, 0.4rem);
}

.mobile-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-width: 56px;
}

.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.mobile-nav-item.active {
    color: var(--accent-blue);
}

.mobile-nav-item:active {
    color: var(--accent-blue);
    transform: scale(0.95);
}

/* ── Mobile Hamburger / More Menu ────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.mobile-header .mobile-logo {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.mobile-header .mobile-logo .logo-accent {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* ── Slide-out Menu (More) ────────────────────────────────────── */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-drawer-overlay.open {
    display: block;
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 301;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-drawer.open {
    right: 0;
}

.mobile-drawer-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-drawer-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.mobile-drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    cursor: pointer;
}

.mobile-drawer-links {
    padding: 0.75rem;
    flex: 1;
}

.mobile-drawer-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    text-decoration: none;
}

.mobile-drawer-links a:hover,
.mobile-drawer-links a.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-blue);
}

.mobile-drawer-links a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mobile-drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ═══════════════════════════════════════════════════════════════
   TABLET BREAKPOINT (max-width: 1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }

    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 1.5rem; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BREAKPOINT (max-width: 768px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Layout shifts ───────────────────────────────────────── */
    .sidebar { display: none !important; }

    .mobile-nav { display: block; }
    .mobile-header { display: flex; }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
        padding-top: calc(56px + 1rem);      /* below mobile header */
        padding-bottom: calc(70px + 1rem);    /* above bottom nav */
        min-height: 100vh;
    }

    /* ── Typography ──────────────────────────────────────────── */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.05rem !important; }

    /* ── Grid ────────────────────────────────────────────────── */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* ── Cards ───────────────────────────────────────────────── */
    .card { padding: 1rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.4rem; }

    /* ── Buttons (touch-friendly 44px minimum) ────────────────── */
    .btn {
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px;
    }
    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        width: 100%;
    }
    .btn-sm {
        padding: 0.6rem 1rem;
        min-height: 40px;
    }

    /* ── Forms ───────────────────────────────────────────────── */
    .form-input {
        padding: 0.85rem 1rem;
        font-size: 16px; /* prevents iOS zoom on focus */
        min-height: 44px;
    }

    /* ── Tables (horizontal scroll) ──────────────────────────── */
    .table-container {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* ── Toast ───────────────────────────────────────────────── */
    .toast-container {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: calc(70px + 0.5rem);
    }
    .toast { max-width: 100%; }

    /* ── Navbar (hide desktop navbar on mobile) ────────────────── */
    .navbar { display: none !important; }

    /* ── Dashboard-specific ───────────────────────────────────── */
    .dashboard-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }
    .time-balance {
        width: 100%;
        justify-content: space-between !important;
    }
    .balance-item { text-align: left !important; }

    .quick-actions {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    .action-card {
        padding: 1rem !important;
    }
    .action-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
    }

    /* ── Session rows ────────────────────────────────────────── */
    .session-row {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .session-score { font-size: 1.2rem; margin-right: 0.5rem; }
    .session-info h4 { font-size: 0.85rem; }
    .session-info p { font-size: 0.75rem; }
    .session-meta { font-size: 0.7rem; }

    /* ── Training page ───────────────────────────────────────── */
    .training-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* ── Auth pages (login/register) ─────────────────────────── */
    .auth-card {
        margin: 1rem !important;
        padding: 1.5rem !important;
        max-width: 100% !important;
    }

    /* ── Report page ─────────────────────────────────────────── */
    .grade-circle {
        width: 100px !important;
        height: 100px !important;
        font-size: 2.5rem !important;
    }
    .report-header {
        flex-direction: column !important;
        text-align: center;
    }

    /* ── Scripts page ────────────────────────────────────────── */
    .script-card {
        padding: 1rem !important;
    }
    .script-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .script-actions .btn { width: 100%; }

    /* Modal (full-screen on mobile) */
    .modal {
        width: calc(100% - 2rem) !important;
        max-width: 100% !important;
        max-height: calc(100vh - 8rem) !important;
        margin: 1rem !important;
    }

    /* ── Analytics page ──────────────────────────────────────── */
    .period-tabs {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .period-tab {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    /* ── Homework page ───────────────────────────────────────── */
    .assignment-card {
        padding: 1rem !important;
    }

    /* ── Settings page ───────────────────────────────────────── */
    .settings-section {
        padding: 1rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SMALL PHONE BREAKPOINT (max-width: 380px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    h1 { font-size: 1.25rem !important; }
    .stat-value { font-size: 1.2rem; }
    .mobile-nav-item { font-size: 0.6rem; min-width: 48px; }
    .mobile-nav-item svg { width: 20px; height: 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   TRAINING SESSION — Mobile Full-Screen Voice UI
   When actively in a voice session on mobile, go full-screen
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .voice-session-active .mobile-nav { display: none; }
    .voice-session-active .mobile-header { display: none; }
    .voice-session-active .main-content {
        padding: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .voice-ui {
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport for mobile browsers */
        display: flex;
        flex-direction: column;
    }

    .voice-ui-header {
        padding: 1rem;
        padding-top: env(safe-area-inset-top, 1rem);
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
    }

    .voice-ui-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem 1rem;
    }

    .voice-ui-footer {
        padding: 1.5rem 1rem;
        padding-bottom: calc(env(safe-area-inset-bottom, 1rem) + 0.5rem);
        display: flex;
        justify-content: center;
        gap: 1.5rem;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
    }

    /* Pulse animation for recording state */
    .voice-pulse {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        background: var(--gradient-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }
    .voice-pulse.recording::before {
        content: '';
        position: absolute;
        inset: -10px;
        border-radius: 50%;
        border: 2px solid var(--accent-blue);
        animation: voicePulse 1.5s ease-out infinite;
    }
    .voice-pulse.recording::after {
        content: '';
        position: absolute;
        inset: -20px;
        border-radius: 50%;
        border: 2px solid var(--accent-blue);
        animation: voicePulse 1.5s ease-out infinite 0.3s;
    }

    @keyframes voicePulse {
        0% { opacity: 0.6; transform: scale(1); }
        100% { opacity: 0; transform: scale(1.3); }
    }

    /* Round control buttons in voice footer */
    .voice-control-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .voice-control-btn.end-call {
        background: var(--accent-red);
        color: white;
        width: 64px;
        height: 64px;
    }
    .voice-control-btn.mute {
        background: var(--bg-card);
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
    }
}

/* ═══════════════════════════════════════════════════════════════
   LANDING PAGE — Mobile Responsive
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem !important;
        text-align: center;
    }
    .hero-title { font-size: 2rem !important; }
    .hero-subtitle { font-size: 1rem !important; }
    .hero-stats {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

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

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .pricing-card {
        margin: 0 1rem !important;
        padding: 1.5rem !important;
    }

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

/* ═══════════════════════════════════════════════════════════════
   PWA / App-like Enhancements
   ═══════════════════════════════════════════════════════════════ */

/* Prevent pull-to-refresh in standalone mode */
@media (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* iOS safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent text selection on navigation elements */
.mobile-nav, .mobile-header, .mobile-drawer {
    -webkit-user-select: none;
    user-select: none;
}

/* Smooth scrolling for the main content area */
.main-content {
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════
   LANDSCAPE PHONE (short height, wide width)
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-nav-item svg { width: 18px; height: 18px; }
    .mobile-nav-item { font-size: 0.55rem; gap: 0; }
    .mobile-nav { padding: 0.2rem 0; }

    .voice-pulse { width: 80px; height: 80px; }
    .voice-ui-body { padding: 0.5rem; }
}
