/* ============================================================================
   VisorReporteIA.Web — Mobile-first styles
   ============================================================================ */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f5f7fa;
    color: #1f2937;
    overscroll-behavior: none;
}

.app-shell {
    height: 100vh;
    height: 100dvh; /* dynamic viewport para evitar saltos por URL bar */
    width: 100vw;
    overflow: hidden;
}

/* ============================================================================
   Landing (Home.razor)
   ============================================================================ */
.landing {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}
.landing-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.landing-icon { font-size: 48px; margin-bottom: 12px; }
.landing-card h1 { font-size: 22px; margin: 8px 0 16px; color: #1e3a8a; }
.landing-card p { font-size: 15px; line-height: 1.5; color: #4b5563; margin: 8px 0; }
.landing-hint { font-size: 13px; color: #9ca3af; margin-top: 16px; }

/* ============================================================================
   Visor (Pages/Visor.razor) — Mobile layout: header + pane + bottom tabs
   ============================================================================ */
.visor-mobile {
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: grid;
    grid-template-rows: 44px 1fr 56px; /* header / pane / bottom tabs */
    overflow: hidden;
}

.visor-header {
    background: #1e3a8a;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.visor-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.visor-emoji { flex: 0 0 auto; }
.visor-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Panes — sólo uno visible a la vez en móvil */
.pane { display: none; height: 100%; width: 100%; overflow: hidden; background: #fff; }
.visor-mobile.tab-pdf  .pane-pdf  { display: block; }
.visor-mobile.tab-chat .pane-chat { display: block; }

.pane-loading, .pane-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
    color: #6b7280;
}
.pane-error p { margin: 4px 0; }
.pane-error .hint { font-size: 13px; color: #9ca3af; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #1e3a8a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bottom tabs */
.bottom-tabs {
    display: flex;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-tabs .tab {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: #6b7280;
    font-size: 12px;
    transition: color 0.15s;
}
.bottom-tabs .tab.active { color: #1e3a8a; font-weight: 600; }
.bottom-tabs .tab:active { background: #f3f4f6; }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { font-size: 11px; }

/* ============================================================================
   Chat (Shared/AssistViewEs.razor)
   ============================================================================ */
.aiassist-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
}
.ai-header-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: #fff;
}
.ai-header-icon svg { display: block; }
.ai-header-title { font-weight: 600; font-size: 15px; }
.ai-header-subtitle { font-size: 12px; opacity: 0.85; }
.ai-footer-disclaimer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px 8px;
    border-top: 1px solid #f3f4f6;
}

/* Chat HTML response styling (mermaid / echarts / tablas) */
.sf-ai-html pre { background: #f7f7f7; padding: 8px; overflow: auto; border-radius: 4px; }
.sf-ai-html .mermaid { margin: 12px 0; min-height: 200px; }
.sf-ai-html .echarts-chart { width: 100%; height: 320px; margin: 12px 0; }
.sf-ai-html .ai-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.sf-ai-html .ai-table th, .sf-ai-html .ai-table td { border: 1px solid #ddd; padding: 6px; text-align: left; }
.sf-ai-html .ai-table th { background: #f5f5f5; font-weight: 600; }

/* Sf AIAssistView: full-height dentro del pane */
::deep .e-aiassistview { height: 100% !important; }

/* ============================================================================
   Desktop overrides (≥ 900px): side-by-side, hide bottom tabs
   ============================================================================ */
@media (min-width: 900px) {
    .visor-mobile {
        grid-template-rows: 44px 1fr;
        grid-template-columns: 1fr 420px;
        grid-template-areas:
            "header header"
            "pdf    chat";
    }
    .visor-header { grid-area: header; }
    .pane-pdf  { grid-area: pdf;  display: block !important; border-right: 1px solid #e5e7eb; }
    .pane-chat { grid-area: chat; display: block !important; }
    .bottom-tabs { display: none; }
}
