/* ═══════════════════════════════════════════════════════════════════════════
   mobile.css — LoboForge Studio
   Load LAST in App.razor after all other stylesheets.
   Single file covers all pages via @media (max-width: 768px).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── PWA / iOS safe areas ─────────────────────────────────────────────────── */
:root {
    --safe-top:    env(safe-area-inset-top,    0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left,   0px);
    --safe-right:  env(safe-area-inset-right,  0px);
    --mob-nav-h:   56px;
    --mob-tab-h:   58px;
}

/* ── Touch target minimum (applies always, not just mobile) ───────────────── */
button, a, [role="button"], select, input[type="checkbox"], input[type="radio"] {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {

/* ════════════════════════════════════════════════════════════════════════════
   GLOBAL
   ════════════════════════════════════════════════════════════════════════════ */

    /* Prevent horizontal scroll */
    html, body { overflow-x: hidden; }

    /* Minimum touch target size */
    button, a.il-link, a.il-dropdown-item, .il-action-btn,
    .pc-react, .adm-btn, .db-filter, .gal-filter {
        min-height: 44px;
        min-width: 44px;
    }

    /* Slightly larger base font */
    body { font-size: 15px; }

/* ════════════════════════════════════════════════════════════════════════════
   TOP NAV  (inside-layout.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .il-nav {
        height: var(--mob-nav-h);
        padding: 0 16px;
        padding-top: var(--safe-top);
    }

    /* Hide primary nav links — replaced by bottom tab bar */
    .il-links { display: none; }

    /* Hide username label — keep avatar only */
    .il-username { display: none; }

    /* Collapse token badge — icon only */
    .il-token-badge { padding: 5px 8px; font-size: 0.78rem; }

    /* Hide less-critical action buttons */
    .il-nsfw-btn { display: none; }

    /* Tighten right actions */
    .il-actions { gap: 4px; }

    /* Brand — smaller */
    .il-brand { margin-right: 0; }
    .il-brand-name { font-size: 0.95rem; }
    .il-brand-sub  { display: none; }

    /* Dropdown menus — full width on mobile */
    .il-dropdown-menu {
        position: fixed;
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: calc(var(--mob-tab-h) + var(--safe-bottom) + 8px);
        min-width: unset;
        width: auto;
        border-radius: 16px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .il-dropdown-right {
        left: 8px !important;
        right: 8px !important;
    }

    /* Avatar button — smaller */
    .il-avatar-btn { padding: 4px 6px; }

    /* Toast stack — full width, bottom safe area */
    .il-toast-stack {
        left: 8px;
        right: 8px;
        bottom: calc(var(--mob-tab-h) + var(--safe-bottom) + 8px);
        max-width: 100%;
    }

    .il-toast { padding: 10px 12px; gap: 10px; }

    /* Main content — account for bottom tab bar */
    .il-content {
        padding-bottom: calc(var(--mob-tab-h) + var(--safe-bottom));
    }

/* ════════════════════════════════════════════════════════════════════════════
   BOTTOM TAB BAR  (mobile nav replacement)
   ════════════════════════════════════════════════════════════════════════════ */

    .mob-tabbar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--mob-tab-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: #0f0f1a;
        border-top: 1px solid #1a1a2e;
        z-index: 300;
        align-items: stretch;
    }

    .mob-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        color: #666688;
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        transition: color 0.15s;
        padding: 0;
        position: relative;
    }

    .mob-tab.active { color: #ff9800; }
    .mob-tab:hover  { color: #aaaacc; }

    .mob-tab-icon {
        font-size: 1.3rem;
        line-height: 1;
    }

    .mob-tab-badge {
        position: absolute;
        top: 6px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        padding: 0 3px;
        border-radius: 999px;
        background: #ef4444;
        color: #fff;
        font-size: 0.58rem;
        font-weight: 800;
        line-height: 16px;
        text-align: center;
    }

/* ════════════════════════════════════════════════════════════════════════════
   DASHBOARD  (dashboard.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .db-wrap { padding: 0 12px 24px; }

    .db-filterbar {
        top: var(--mob-nav-h);
        padding: 12px 0 10px;
        gap: 8px;
    }

    .db-search-wrap { max-width: 100%; min-width: unset; }

    .db-filters { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
    .db-filter  { flex-shrink: 0; padding: 5px 12px; font-size: 0.78rem; }

    .db-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

    .db-section { margin-top: 20px; }
    .db-section-title { font-size: 0.9rem; }

/* ════════════════════════════════════════════════════════════════════════════
   GALLERY  (gallery.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .gal-page { padding: 12px; }

    .gal-header { margin-bottom: 14px; gap: 10px; }
    .gal-title  { font-size: 1.3rem; }

    .gal-filters { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
    .gal-filter  { flex-shrink: 0; padding: 5px 12px; font-size: 0.78rem; }

    .gal-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

/* ════════════════════════════════════════════════════════════════════════════
   POST CARD  (postcard.css)
   ════════════════════════════════════════════════════════════════════════════ */

    /* Always show bottom info bar on mobile (no hover) */
    .pc-bottom {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        padding-top: 20px;
    }

    /* Always show admin controls */
    .pc:hover .pc-admin,
    .pc .pc-admin { opacity: 1; }

    .pc-react { padding: 4px 8px; font-size: 0.75rem; }

/* ════════════════════════════════════════════════════════════════════════════
   POST DETAIL  (postdetail.css)
   ════════════════════════════════════════════════════════════════════════════ */

    /* Already has 860px breakpoint — just tighten it */
    .pd-wrap { padding: 12px !important; gap: 16px; }

    .pd-title { font-size: 1.2rem; }

    /* Download buttons — full width */
    .pd-download-btn { width: 100%; justify-content: center; }

/* ════════════════════════════════════════════════════════════════════════════
   GENERATE  (generate.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .gen-page { padding: 12px !important; }

    /* Model tiles — scrollable row */
    .model-tiles {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 4px;
        gap: 8px;
    }
    .model-tile { flex-shrink: 0; }

    /* Prompt area full width */
    .prompt-row  { grid-template-columns: 1fr !important; }
    .config-row  { grid-template-columns: 1fr !important; }

    /* Submit button — full width */
    .gen-submit { width: 100%; }

/* ════════════════════════════════════════════════════════════════════════════
   CHAT  (chat.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .chat-layout {
        height: calc(100vh - var(--mob-nav-h) - var(--mob-tab-h) - var(--safe-bottom));
        position: relative;
    }

    /* Sidebar hidden by default, slides in when .mob-chat-open added to layout */
    .chat-sidebar {
        position: fixed;
        top: var(--mob-nav-h);
        left: 0;
        bottom: calc(var(--mob-tab-h) + var(--safe-bottom));
        width: 85vw;
        max-width: 320px;
        min-width: auto !important;
        z-index: 250;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .chat-layout.mob-chat-open .chat-sidebar { transform: translateX(0); }

    /* Main chat takes full width */
    .chat-main { width: 100% !important; }

    /* Message bubbles — wider on mobile */
    .message-row { max-width: 90% !important; }
    .bubble-wrap { max-width: 100% !important; }

    /* Message input area — add bottom safe area */
    .message-input-area {
        padding-bottom: calc(8px + var(--safe-bottom));
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Hide files panel on mobile (already done in chat.css, reinforce) */
    .chat-files-panel { display: none !important; }

    /* Sidebar toggle button — show on mobile */
    .chat-mob-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 8px;
        color: #aaaacc;
        font-size: 1.1rem;
        cursor: pointer;
        flex-shrink: 0;
    }

    /* Backdrop when sidebar is open */
    .chat-mob-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 249;
        backdrop-filter: blur(2px);
    }

/* ════════════════════════════════════════════════════════════════════════════
   AI ASSISTANT  (ai-assistant.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .ai-page {
        height: calc(100vh - var(--mob-nav-h) - var(--mob-tab-h) - var(--safe-bottom));
        flex-direction: column;
    }

    /* Sidebar hidden by default, slide in */
    .ai-sidebar {
        position: fixed;
        top: var(--mob-nav-h);
        left: 0;
        bottom: calc(var(--mob-tab-h) + var(--safe-bottom));
        width: 85vw;
        max-width: 300px;
        z-index: 250;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        border-right: none;
    }

    .ai-sidebar.open { transform: translateX(0); }

    /* Main takes full width */
    .ai-main { width: 100%; }

    /* Messages */
    .ai-messages { padding: 12px; gap: 12px; }
    .ai-msg      { max-width: 92%; }

    /* Input area */
    .ai-input-area { padding: 10px 12px; }
    .ai-input      { font-size: 1rem; }  /* prevent iOS zoom on focus */

    /* Preset modal */
    .ai-modal { padding: 20px 16px; border-radius: 20px 20px 0 0; }
    .ai-modal-backdrop { align-items: flex-end; }
    .ai-preset-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .ai-preset-card { padding: 14px 12px; }
    .ai-preset-icon { font-size: 1.5rem; }
    .ai-preset-name { font-size: 0.85rem; }
    .ai-preset-desc { font-size: 0.72rem; }

/* ════════════════════════════════════════════════════════════════════════════
   CREATE POST  (createpost.css) — already has 800px rule, supplement it
   ════════════════════════════════════════════════════════════════════════════ */

    .cp-page  { padding: 12px; }
    .cp-title { font-size: 1.2rem; }

    .cp-type-tabs { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
    .cp-tab       { flex-shrink: 0; padding: 7px 14px; }

    .cp-actions { flex-direction: column; }
    .cp-btn-submit { width: 100%; }

/* ════════════════════════════════════════════════════════════════════════════
   ADMIN  (admin.css) — already has 768px rule, supplement it
   ════════════════════════════════════════════════════════════════════════════ */

    .adm-page    { padding: 0 12px 24px; }
    .adm-tabs    { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .adm-tab     { flex-shrink: 0; padding: 8px 12px; font-size: 0.8rem; }

    /* Tables — hide less-critical columns */
    .adm-table th:nth-child(4),
    .adm-table td:nth-child(4),
    .adm-table th:nth-child(5),
    .adm-table td:nth-child(5) { display: none; }

/* ════════════════════════════════════════════════════════════════════════════
   PROFILE  (profile.css) — already has 640px rule, supplement it
   ════════════════════════════════════════════════════════════════════════════ */

    .pf-root  { padding: 0 0 60px; }
    .pf-panel { padding: 20px 16px; }
    .pf-tabs  { padding: 0 16px; overflow-x: auto; flex-wrap: nowrap; }
    .pf-tab   { flex-shrink: 0; padding: 12px 14px; }

/* ════════════════════════════════════════════════════════════════════════════
   CREATOR PROFILE  (creatorprofile.css) — already has 700px rule
   ════════════════════════════════════════════════════════════════════════════ */

    /* Tabs row scrollable */
    .cp-tabs-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
    .cp-tab-btn  { flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════════════════
   MUSIC  (music.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .mg-page  { padding: 16px; }
    .mg-title { font-size: 1.5rem; }

    .mg-mode-row { gap: 6px; }
    .mg-mode-btn { padding: 8px; font-size: 0.85rem; }

    .mg-result-card { padding: 1.5rem 1rem; }

/* ════════════════════════════════════════════════════════════════════════════
   REPORT  (report.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .rpt-page { padding: 24px 12px; }
    .rpt-card { padding: 24px 16px; border-radius: 12px; }
    .rpt-actions { flex-direction: column-reverse; }
    .rpt-btn-submit, .rpt-btn-cancel { width: 100%; text-align: center; }

/* ════════════════════════════════════════════════════════════════════════════
   SUBSCRIBE  (subscribe.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .sub-page { padding: 24px 16px 60px; }
    .sub-hero { flex-direction: column; gap: 16px; padding: 24px 0 20px; }
    .sub-hero-text { width: 100%; }

/* ════════════════════════════════════════════════════════════════════════════
   MANAGE TIERS  (manage-tiers.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .mt-page   { padding: 20px 16px 60px; }
    .mt-header { flex-direction: column; gap: 16px; }
    .mt-header-stats { flex-direction: row; gap: 16px; }
    .mt-tier   { flex-direction: column; gap: 12px; }
    .mt-tier-actions { flex-direction: row; }

    /* Earnings table — simplify */
    .mt-earnings-head,
    .mt-earnings-row { grid-template-columns: 60px 1fr 80px 70px !important; }
    .mt-earnings-head > *:nth-child(3),
    .mt-earnings-row  > *:nth-child(3),
    .mt-earnings-head > *:nth-child(5),
    .mt-earnings-row  > *:nth-child(5),
    .mt-earnings-head > *:nth-child(7),
    .mt-earnings-row  > *:nth-child(7) { display: none; }

/* ════════════════════════════════════════════════════════════════════════════
   PAYMENTS  (payments.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .payments-page { padding: 20px 12px 60px; }
    .payments-header h1 { font-size: 1.5rem; }
    .payments-sub { font-size: 0.9rem; }
    .package-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .package-card { padding: 16px 12px; }
    .package-price { font-size: 1.5rem; }
    .widget-modal { width: calc(100vw - 24px); }
    .invoice-table { font-size: 0.75rem; }
    .invoice-table th,
    .invoice-table td { padding: 5px 6px; }

/* ════════════════════════════════════════════════════════════════════════════
   PUBLIC  (public.css)  — landing/login pages
   ════════════════════════════════════════════════════════════════════════════ */

    /* Public pages don't have the bottom nav bar — reset */
    .pub-page .il-content { padding-bottom: 0; }

/* ════════════════════════════════════════════════════════════════════════════
   ANNOUNCEMENTS  (announcements.css)
   ════════════════════════════════════════════════════════════════════════════ */

    .ann-banner { flex-wrap: wrap; }
    .ann-inner  { width: 100%; }

/* ════════════════════════════════════════════════════════════════════════════
   TOOLS  (tools.css) — already has 660px/640px rules, supplement it
   ════════════════════════════════════════════════════════════════════════════ */

    .tr-page   { padding: 16px 12px 60px; }
    .tr-header { gap: 10px; }
    .tr-title  { font-size: 1.3rem; }

    /* Resolution tiles — scrollable row instead of wrap */
    .tr-res-tiles { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .tr-res-tile  { flex-shrink: 0; }

    /* Run button already full width — just ensure touch target */
    .tr-run-btn { min-height: 48px; }

    /* Result actions — stack */
    .tr-result-actions { flex-direction: column; }
    .tr-result-actions .tr-run-btn { min-width: unset; }

/* ════════════════════════════════════════════════════════════════════════════
   VIDEO  (video.css) — already has 700px/600px rules, supplement it
   ════════════════════════════════════════════════════════════════════════════ */

    .vg-page  { padding: 16px 12px 60px; }
    .vg-title { font-size: 1.5rem; }

    /* Duration tiles — scrollable */
    .vg-duration-tiles { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .vg-duration-tile  { flex-shrink: 0; }

    /* Run button touch target */
    .vg-run-btn { min-height: 48px; }

    /* Result actions — stack */
    .vg-result-actions { flex-direction: column; }
    .vg-result-actions .vg-run-btn { min-width: unset; }

/* ════════════════════════════════════════════════════════════════════════════
   FORMS — prevent iOS zoom on input focus (font-size must be >= 16px)
   ════════════════════════════════════════════════════════════════════════════ */

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }

/* ════════════════════════════════════════════════════════════════════════════
   SCROLLBARS — hide on mobile (touch scrolling handles it)
   ════════════════════════════════════════════════════════════════════════════ */

    ::-webkit-scrollbar { width: 0; height: 0; }

} /* end @media (max-width: 768px) */


/* ════════════════════════════════════════════════════════════════════════════
   BOTTOM TAB BAR — hidden on desktop, shown on mobile via the rule above
   Define the hide rule outside the media query so desktop never shows it
   ════════════════════════════════════════════════════════════════════════════ */
.mob-tabbar       { display: none; }
.chat-mob-toggle  { display: none; }
.chat-mob-backdrop { display: none; }
