/* ============================================
   DOKUMENTOR PWA — GLOBAL STYLES
============================================ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Instrument+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #0a1628;
  --ink-2: #0f1f3d;
  --ink-3: #1a2f50;
  --surface: #131f35;
  --surface-2: #1e2d47;
  --accent: #e85d2f;
  --accent-2: #f5a623;
  --cyan: #00c2cb;
  --green: #075E54;
  --green-light: #25D366;
  --paper: #f8f7f4;
  --paper-2: #efecea;
  --white: #ffffff;
  --text-muted: rgba(255,255,255,0.5);
  --text-dim: rgba(255,255,255,0.7);
  --border: rgba(255,255,255,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font-head: 'Cormorant Garamond', serif;
  --font-body: 'Instrument Sans', sans-serif;
  --max-w: 430px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--ink);
  color: var(--white);
  min-height: 100%;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   MOBILE SHELL
============================================ */
.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ============================================
   TYPOGRAPHY
============================================ */
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; }
h1 { font-size: 2.4rem; font-weight: 700; }
h2 { font-size: 1.8rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { line-height: 1.6; color: var(--text-dim); }

/* ============================================
   BUTTONS
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  width: 100%;
  letter-spacing: 0.01em;
}
.btn--primary {
  background: #4285F4;
  color: white;
}
.btn--primary:hover { background: #3574e2; transform: translateY(-1px); }
.btn--accent {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 20px rgba(232,93,47,0.35);
}
.btn--accent:hover { box-shadow: 0 6px 28px rgba(232,93,47,0.5); transform: translateY(-1px); }
.btn--outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--white);
}
.btn--outline:hover { border-color: rgba(255,255,255,0.25); }
.btn--ghost {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  border: 1px solid var(--border);
}
.btn--green {
  background: var(--green);
  color: white;
}
.btn--full { width: 100%; }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ============================================
   CARDS
============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card--elevated {
  background: var(--surface-2);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* ============================================
   INPUTS
============================================ */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

/* ============================================
   NAV BAR (bottom)
============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  background: var(--ink-2);
  border-top: none;
  box-shadow: 0 -1px 12px rgba(0,0,0,0.4);
  display: flex;
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  transition: color 0.2s;
}
.bottom-nav__item.active { color: var(--accent); }
.bottom-nav__item svg { width: 22px; height: 22px; }

/* ============================================
   TAGS / BADGES
============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--accent { background: rgba(232,93,47,0.2); color: var(--accent); }
.badge--green { background: rgba(37,211,102,0.15); color: var(--green-light); }
.badge--cyan { background: rgba(0,194,203,0.15); color: var(--cyan); }
.badge--muted { background: rgba(255,255,255,0.08); color: var(--text-dim); }

/* ============================================
   DIVIDER
============================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 8px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================
   ANIMATIONS
============================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}
.fade-up { animation: fadeUp 0.5s ease forwards; }
.fade-in { animation: fadeIn 0.4s ease forwards; }

/* ============================================
   SCROLLBAR
============================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================
   UTILITY
============================================ */
.text-accent { color: var(--accent); }
.text-cyan { color: var(--cyan); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.px-24 { padding-left: 24px; padding-right: 24px; }
.py-16 { padding-top: 16px; padding-bottom: 16px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

@keyframes skeleton-shine { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── LAYOUTS AVANZADOS: DOCUMENTOS (2 COLS) Y MICROSITIOS (3 COLS) ────────────────── */
body.mode-microsite .app-shell,
body.mode-doc-dashboard .app-shell {
    display: grid;
    max-width: 100vw;
    height: 100vh;
    margin: 0;
    gap: 0;
    background: var(--ink);
}

body.mode-doc-dashboard .app-shell {
    grid-template-columns: 1fr 400px; /* Dashboard a la izquierda, Chat a la derecha */
}

body.mode-microsite .app-shell {
    grid-template-columns: 25% 1fr 25%; /* Captura, Dashboard, Chat */
}

.panel-capture, .panel-dashboard {
    display: none; /* Oculto por defecto en móvil */
    border-right: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
    position: relative;
    z-index: 10;
}

/* Jerarquía Visual de Fondos */
body.mode-microsite .panel-capture, 
body.mode-microsite .panel-mentor,
body.mode-doc-dashboard .panel-mentor {
    background: var(--ink-2);
}
body.mode-microsite .panel-dashboard,
body.mode-doc-dashboard .panel-dashboard {
    background: var(--ink);
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

/* Desktop layout visibility */
@media (min-width: 1025px) {
    body.mode-microsite .app-shell,
    body.mode-doc-dashboard .app-shell {
        max-width: 100vw; /* Asegurar Full-Width en escritorio */
    }

    body.mode-doc-dashboard .panel-dashboard,
    body.mode-microsite .panel-dashboard,
    body.mode-microsite .panel-capture {
        display: flex;
        flex-direction: column;
    }
    body.mode-doc-dashboard .panel-mentor,
    body.mode-microsite .panel-mentor {
        border-left: 1px solid var(--border);
        height: 100vh;
        overflow: hidden;
    }
}

/* Mobile Tabs for Microsite */
@media (max-width: 1024px) {
    body.mode-microsite .app-shell,
    body.mode-doc-dashboard .app-shell {
        display: flex; /* En móvil, volvemos a flex para el tab switching */
        flex-direction: column;
        max-width: var(--max-w);
        margin: 0 auto;
        height: 100dvh;
    }

    /* Control de pestañas en Micrositio móvil */
    body.mode-microsite .panel-capture.active-tab,
    body.mode-microsite .panel-dashboard.active-tab,
    body.mode-microsite .panel-mentor.active-tab {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        height: auto; /* Dejar que el contenedor flex calcule la altura */
    }
    body.mode-microsite .panel-capture:not(.active-tab),
    body.mode-microsite .panel-dashboard:not(.active-tab),
    body.mode-microsite .panel-mentor:not(.active-tab) {
        display: none !important;
    }

    body.mode-doc-dashboard .panel-dashboard {
        display: none !important; /* En doc móvil 100% chat */
    }
}

/* Selector de pestañas móvil */
.mobile-tabs {
    display: none;
    background: var(--ink-2);
    padding: 8px 12px;
    gap: 8px;
    justify-content: space-around;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
body.mode-microsite .mobile-tabs {
    display: flex;
}
@media (min-width: 1025px) {
    .mobile-tabs { display: none !important; }
}
.mobile-tab-btn {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: 8px;
    padding: 8px 0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.mobile-tab-btn.active {
    background: var(--accent-light, rgba(232,93,47,0.08));
    color: var(--accent);
    border-color: var(--accent);
}

/* Ocultar botones FAB antiguos si existían */
.fab-capture { display: none !important; }
.btn-voice {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--accent);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-voice:hover { background: var(--accent); color: white; transform: scale(1.1); }
.btn-voice.recording { background: #ef4444; color: white; animation: pulse 1s infinite; }

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(37, 211, 102, 0.1);
    border: 1px solid rgba(37, 211, 102, 0.3);
    color: #25D366;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
}
.share-btn:hover { background: #25D366; color: white; }
.share-btn svg { width: 12px; height: 12px; fill: currentColor; }

/* ── AGENTIC OS UI ──────────────────────────────── */
.thinking-block {
    background: rgba(66, 133, 244, 0.05);
    border-left: 2px solid #4285F4;
    padding: 10px 15px;
    margin: 10px 0;
    font-size: 0.75rem;
    color: var(--text-dim);
    animation: fadeIn 0.3s ease;
}
.thinking-step { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.thinking-step.active { color: #4285F4; font-weight: 600; }
.thinking-step svg { width: 14px; height: 14px; animation: spin 2s linear infinite; }

.insight-bell {
    position: relative;
    cursor: pointer;
    color: var(--text-muted);
}
.insight-bell.has-new::after {
    content: '';
    position: absolute;
    top: -2px; right: -2px;
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--ink-2);
}

.btn-deep-analysis {
    background: linear-gradient(135deg, var(--ink-3), var(--ink-2));
    border: 1px solid rgba(232, 93, 47, 0.3);
    color: white;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}
.btn-deep-analysis:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(232,93,47,0.2); }

/* Widgets Dashboard */
.microsite-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin: 10px;
}

.microsite-table-container { overflow-x: auto; padding: 10px; }
.microsite-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; color: white; }
.microsite-table th { text-align: left; padding: 10px 8px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-size: 0.7rem; text-transform: uppercase; }
.microsite-table td { padding: 12px 8px; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* Formulario Dinámico */
.dynamic-form { padding: 15px; display: flex; flex-direction: column; gap: 15px; }
.dynamic-form h3 { font-size: 0.9rem; color: white; margin-bottom: 5px; }
.dynamic-form .field { display: flex; flex-direction: column; gap: 6px; }
.dynamic-form .field label { font-size: 0.75rem; color: var(--text-dim); font-weight: 500; }
.dynamic-form .field input, .dynamic-form .field select {
    background: var(--ink); border: 1px solid var(--border); 
    border-radius: 10px; color: white; padding: 12px; font-size: 0.95rem;
}

/* ---- MICROSITE UX UPGRADE ---- */
@media (min-width: 1024px) {
    /* Ocultar elementos sobrantes del layout original en modo micrositio */
    body.mode-microsite .bottom-nav { display: none !important; }
    
    /* Grid de 3 columnas strict */
    body.mode-microsite .app-shell {
        display: grid !important;
        grid-template-columns: 280px minmax(400px, 1fr) 350px !important;
        gap: 0;
        padding: 0;
        height: 100dvh;
        overflow: hidden;
        background: var(--ink) !important;
    }
    
    /* Comportamiento de paneles */
    body.mode-microsite .panel-dashboard,
    body.mode-microsite .panel-capture,
    body.mode-microsite .panel-mentor {
        display: flex !important;
        flex-direction: column;
        height: 100dvh;
        overflow-y: auto;
        position: relative;
        background: var(--ink-2) !important; /* Fondo oscuro consistente */
        border-right: 1px solid var(--border);
        width: auto !important; /* Override inline styles */
    }

    body.mode-microsite .panel-mentor { border-right: none; }
    
    /* El input del chat debe pertenecer a su columna */
    body.mode-microsite .panel-mentor .input-area {
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 10;
        background: white; /* El input sí es blanco por diseño base */
        border-top: 1px solid var(--border);
    }
}

/* Forzar que el Formulario Central sea Oscuro en todo momento */
body.mode-microsite .panel-capture {
    background: var(--ink-2) !important;
    color: white !important;
}

body.mode-microsite .dynamic-form label {
    color: rgba(255, 255, 255, 0.7) !important;
}

body.mode-microsite .dynamic-form input,
body.mode-microsite .dynamic-form select {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

body.mode-microsite .dynamic-form input::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* Smart Tabs Progress Bar */
.ms-progress-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 0 14px;
}
.ms-progress-step {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    transition: background 0.3s;
}
.ms-progress-step.active { background: var(--accent); }
.ms-progress-step.completed { background: #25D366; }

/* Control de Tabs (Ocultar estrictamente lo inactivo) */
.ms-stage-container { display: none !important; }
.ms-stage-container.active { display: block !important; animation: fadeIn 0.3s ease; }

.ms-stage-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
    padding: 0 14px;
    font-family: var(--font-head);
}

.ms-form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    gap: 12px;
    padding: 0 14px 20px;
}

/* ---- MICROSITE MINI-APP COMPONENTS ---- */
.ms-sidebar-nav {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ms-nav-item {
    background: transparent;
    border: none;
    color: var(--text-dim);
    text-align: left;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ms-nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}
.ms-nav-item.active {
    background: rgba(232, 93, 47, 0.1);
    color: var(--accent);
    font-weight: 600;
}
.ms-app-view {
    flex: 1;
    display: none;
    flex-direction: column;
}
.ms-app-view.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

/* ---- MICROSITE BOTTOM SHEET ---- */
.ms-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.ms-sheet-overlay.active {
    display: block;
    opacity: 1;
}

.ms-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--ink-2);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.ms-bottom-sheet.active {
    transform: translateY(0);
}

.ms-sheet-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ms-sheet-title {
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    font-family: var(--font-head);
}
.ms-sheet-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-sheet-content {
    padding: 10px 20px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Adjust for Desktop */
@media (min-width: 992px) {
    .ms-bottom-sheet {
        left: 50%;
        transform: translate(-50%, calc(100% + 24px));
        width: 400px;
        border-radius: 20px;
        bottom: 20px;
    }
    .ms-bottom-sheet.active {
        transform: translate(-50%, 0);
    }
}


/* ---- MATERIAL DESIGN 3 REFRESH ---- */
body.mode-microsite {
    /* M3 Dark Palette Tints */
    --m3-surface: #1A1C1E;
    --m3-surface-variant: #42474E;
    --m3-on-surface: #E2E2E6;
    --m3-primary: var(--accent); /* Keep Dokumentor Orange as Primary */
    --m3-secondary-container: rgba(232, 93, 47, 0.15);
    --m3-on-secondary-container: #FFDBCF;
    --m3-radius-lg: 28px;
    --m3-radius-md: 16px;
    --m3-elevation-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

@media (min-width: 1024px) {
    body.mode-microsite .app-shell {
        background: var(--m3-surface) !important;
    }
    
    body.mode-microsite .panel-dashboard,
    body.mode-microsite .panel-capture,
    body.mode-microsite .panel-mentor {
        background: var(--m3-surface) !important;
        border-right: 1px solid rgba(255,255,255,0.05);
        border-radius: 0; /* Clean grid for desktop */
    }
}

/* M3 Filled Input Style */
body.mode-microsite .dynamic-form .field {
    margin-bottom: 16px;
}

body.mode-microsite .dynamic-form input,
body.mode-microsite .dynamic-form select {
    background: rgba(255, 255, 255, 0.05) !important;
    border: none !important;
    border-bottom: 2px solid var(--text-muted) !important;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    padding: 16px 12px 8px 12px !important;
    color: white !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.mode-microsite .dynamic-form input:focus,
body.mode-microsite .dynamic-form select:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-bottom-color: var(--accent) !important;
    outline: none;
}

/* Floating-like labels */
body.mode-microsite .dynamic-form label {
    font-size: 0.7rem !important;
    color: var(--accent) !important;
    margin-bottom: -10px !important;
    z-index: 1;
    padding-left: 12px;
    position: relative;
}

body.mode-microsite .btn {
    border-radius: 100px !important; /* M3 Pill style */
    padding: 12px 24px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important;
}

body.mode-microsite .btn--accent {
    box-shadow: var(--m3-elevation-1);
}

.ms-bottom-sheet {
    border-top-left-radius: var(--m3-radius-lg) !important;
    border-top-right-radius: var(--m3-radius-lg) !important;
}

.ms-sheet-handle {
    width: 32px;
    height: 4px;
    background: var(--m3-surface-variant);
    border-radius: 2px;
    margin: 12px auto 0;
    opacity: 0.4;
}

.ms-sheet-header {
    border-bottom: none !important;
    padding-top: 8px !important;
}

.ms-nav-item {
    border-radius: var(--m3-radius-md) !important;
    margin: 0 8px;
}
