/* ── Reset & root ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta AIVA Wealth (medida sobre el mockup de marca) */
  --blue-900: #1D2E48;
  --blue-800: #24406B;
  --blue-700: #2E5286;
  --blue-600: #3A64A0;
  --blue-100: #E4ECFA;
  --blue-50:  #F0F5FC;
  --tri-light: #D1DFEA;
  --gold:     #5C7B8B;   /* acento secundario (antes dorado, ahora slate) */
  --gold-lt:  #8FA6B3;
  --text:     #1A1A2E;
  --text-2:   #4A5568;
  --text-3:   #8896AB;
  --border:   #E2DACB;
  --surface:  #F6F1EE;   /* fondo crema de marca */
  --tri-stroke: #6D7E76;
  --white:    #FFFFFF;
  --green:    #1C8A4C;
  --red:      #C23B3B;
  --sh-sm:    0 1px 4px rgba(29,46,72,.08);
  --sh-md:    0 4px 20px rgba(29,46,72,.12);
  --sh-lg:    0 8px 40px rgba(29,46,72,.18);
  --r:        10px;
  --r-sm:     6px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }
a { color: inherit; text-decoration: none; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

.page-wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }
.grid {
  display: grid; grid-template-columns: 1fr 260px; gap: 40px;
  padding: 40px 0 64px;
}

/* ── Header (banner) ───────────────────────────────────────────────────────
   Imagen estática de marca (recortada del archivo de diseño provisto) para
   que el logo y las líneas decorativas queden exactos, sin redibujarlas. */
.header {
  background: var(--blue-900);
  overflow: hidden;
  line-height: 0;
  position: relative;
}
.header img { display: block; width: 100%; height: auto; }
.header-right {
  position: absolute; top: 18px; right: 28px;
  display: flex; align-items: center; gap: 10px; z-index: 2;
}
.user-email { font-size: 12px; color: rgba(255,255,255,.6); }

/* ── Selector de idioma (banderas ES/PT) ──────────────────────────────────── */
.lang-switch {
  position: absolute; bottom: 14px; right: 24px; z-index: 2;
  display: flex; gap: 6px;
  background: rgba(0,0,0,.18);
  border-radius: 20px; padding: 5px;
}
.lang-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 22px; padding: 0;
  border: none; border-radius: 4px; cursor: pointer;
  background: transparent; opacity: .5;
  transition: opacity .15s, box-shadow .15s;
}
.lang-btn svg { width: 100%; height: 100%; border-radius: 3px; display: block; }
.lang-btn:hover { opacity: .8; }
.lang-btn.active { opacity: 1; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }

@media (max-width: 600px) {
  .lang-switch { bottom: 8px; right: 16px; padding: 4px; gap: 5px; }
  .lang-btn { width: 26px; height: 19px; }
}

/* ── Post date separators ───────────────────────────────────────────────────── */
.date-sep {
  display: flex; align-items: center; gap: 16px;
  font-weight: 700; color: var(--blue-900); font-size: 14px;
  letter-spacing: .5px; margin: 0 0 14px;
}
.date-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.date-sep:not(:first-child) { margin-top: 36px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: 14px; overflow: hidden;
  box-shadow: var(--sh-md); border: 1px solid var(--border);
}
/* Separación entre cards consecutivas sin un date-sep en el medio (vista de un
   día puntual: inicio o Archivo, donde varias cards del mismo día se listan
   una tras otra sin repetir la fecha). Sin esto quedan pegadas entre sí. */
.card + .card { margin-top: 20px; }
.card-head {
  background: var(--blue-900); padding: 18px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.card-title { font-size: 17px; font-weight: 500; color: #fff; }
.card-date { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .5px; white-space: nowrap; }
.card-body { padding: 26px; }

/* ── Audio player ──────────────────────────────────────────────────────────── */
.player-row { display: flex; align-items: center; gap: 18px; }
.play-btn {
  width: 56px; height: 56px; border-radius: 50%; background: var(--blue-900);
  border: none; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.play-btn:hover { background: var(--blue-700); transform: scale(1.03); }
.play-btn svg { color: #fff; margin-left: 2px; }
.play-btn.playing svg { margin-left: 0; }
.player-main { flex: 1; min-width: 0; }
.progress-row { display: flex; align-items: center; gap: 12px; }
input[type="range"].bar {
  flex: 1; -webkit-appearance: none; height: 3px; background: var(--border);
  border-radius: 2px; outline: none; cursor: pointer;
}
input[type="range"].bar::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue-900); cursor: pointer;
}
input[type="range"].bar::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; border: none;
  background: var(--blue-900); cursor: pointer;
}
.time { font-size: 13px; color: var(--text-2); font-weight: 500; min-width: 40px; text-align: right; }
.player-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  margin-top: 16px;
}
.speed-label { font-size: 12px; color: var(--text-3); }
.speed-opt {
  font-size: 12px; color: var(--text-3); cursor: pointer; font-weight: 500;
  background: none; border: none; font-family: inherit; padding: 0;
}
.speed-opt.active { color: var(--blue-900); font-weight: 700; }
.transcript-divider { border: none; border-top: 1px solid var(--tri-light); margin: 14px 0 0; }
.transcript-toggle {
  display: block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--blue-700);
  background: none; border: none; cursor: pointer; font-family: inherit; padding: 0;
}
.transcript-text {
  display: none; margin-top: 14px; font-size: 14px; color: var(--text-2);
  line-height: 1.8; white-space: pre-wrap; padding-top: 14px; border-top: 1px solid var(--border);
}
.transcript-text.open { display: block; }
.transcript-text.transcript-unavailable { color: var(--text-3); font-style: italic; }

/* ── Indices table ─────────────────────────────────────────────────────────── */
.indices-intro { font-size: 14.5px; color: var(--text-2); margin-bottom: 18px; }
table.indices { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.indices th {
  text-align: left; padding: 9px 12px; font-size: 12px; letter-spacing: .5px;
  color: var(--text-2); font-weight: 700; border-bottom: 1px solid var(--border);
}
table.indices td { padding: 8px 12px; }
table.indices tr.section td {
  background: #3A4048; color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: .5px;
}
table.indices tr.row:nth-child(even) { background: #F4F5F7; }
table.indices td.name { font-weight: 600; }
table.indices td.num { text-align: right; font-weight: 600; }
.pct-pos { color: var(--green); }
.pct-neg { color: var(--red); }
.indices-foot { font-size: 11.5px; color: var(--text-3); margin-top: 10px; }

/* ── Índices: variante imagen (captura) ───────────────────────────────────── */
.indices-image {
  display: block; width: 100%; height: auto;
  border-radius: var(--r-sm); border: 1px solid var(--border);
}

/* ── Calendario Semanal (reportes): imagen a tarjeta completa, sin barra ─── */
.card-reportes .card-body { padding: 0; }
.card-reportes .indices-intro { padding: 20px 26px 0; margin-bottom: 16px; }
.reportes-image { display: block; width: 100%; height: auto; }

/* ── Alternativas de inversión ─────────────────────────────────────────────── */
.alt-text { font-size: 14.5px; color: var(--text-2); margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.download-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gold); color: #fff; border: none;
  padding: 11px 26px; border-radius: 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.download-btn:hover { background: #4E6A79; }

/* ── Empty / error states ──────────────────────────────────────────────────── */
.empty-state, .error-state { padding: 64px 36px; text-align: center; color: var(--text-3); }
.empty-state svg, .error-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state h3, .error-state h3 { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state p, .error-state p { font-size: 14px; }

/* Skeleton */
.skeleton-state { padding: 36px; }
.sk { background: linear-gradient(90deg, #ece6de 25%, #ddd5c8 50%, #ece6de 75%); background-size: 200% 100%; border-radius: 6px; margin-bottom: 14px; animation: shimmer 1.4s infinite; }
.sk-label { height: 12px; width: 120px; }
.sk-title { height: 28px; width: 75%; }
.sk-player { height: 100px; border-radius: 10px; margin: 20px 0; }
.sk-line { height: 14px; }
.sk-line.short { width: 55%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Sidebar / archive ─────────────────────────────────────────────────────── */

/* Caja "TOP RECOMMENDATION LIST": informe mensual destacado, arriba de
   "Listados Actualizados". Azul oscuro de marca para distinguirla de la caja
   celeste de Listados. Si no hay informe cargado queda oculta (display:none
   puesto desde app.js), sin dejar un hueco vacío en la sidebar. */
.trl-box {
  background: var(--blue-900); border-radius: 18px;
  padding: 22px 22px 20px; margin-bottom: 20px; color: #fff;
}
.trl-title { font-size: 14px; font-weight: 700; letter-spacing: .5px; margin-bottom: 4px; }
.trl-sub { font-size: 13px; color: rgba(255,255,255,.65); margin-bottom: 16px; min-height: 16px; }
.trl-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; background: var(--gold); color: #fff; border: none;
  padding: 11px 18px; border-radius: 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.trl-btn:hover { background: #4E6A79; }

/* Caja "Listados Actualizados": siempre muestra el último archivo cargado
   por categoría (sin historial), color de fondo medido del mockup de marca. */
.resources-box {
  background: var(--tri-light); border-radius: 18px;
  padding: 22px 22px 8px; margin-bottom: 28px;
}
.resources-title { font-size: 15px; font-weight: 700; color: var(--blue-900); margin-bottom: 10px; }
.resource-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; font-size: 14.5px; color: var(--blue-900);
  border-bottom: 1px solid rgba(29,46,72,.14);
}
.resource-link:last-child { border-bottom: none; }
.resource-dl-icon {
  width: 30px; height: 30px; border-radius: 50%; background: var(--blue-900);
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}

.sidebar-title { font-size: 15px; font-weight: 700; color: var(--blue-900); margin-bottom: 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; margin-bottom: 22px;
}
.search-box input {
  border: none; outline: none; font-size: 13px; flex: 1; background: none; color: var(--text);
  font-family: inherit;
}
.search-box svg { color: var(--text-3); flex-shrink: 0; }
.search-clear { background: none; border: none; cursor: pointer; color: var(--text-3); display: none; }
.search-clear.show { display: flex; }

.search-active-banner {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--blue-100); border: 1px solid var(--blue-100); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 24px; font-size: 13px; color: var(--blue-800);
}
.search-active-banner.show { display: flex; }
.search-active-banner button {
  background: none; border: none; color: var(--blue-700); font-weight: 600; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}

.archive-year { margin-bottom: 4px; }
.archive-year-label {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  font-size: 14px; font-weight: 600; color: var(--blue-800); cursor: pointer;
  user-select: none;
}
.archive-year-label .chev, .archive-month-label .chev { font-size: 11px; color: var(--text-3); transition: transform .15s; display: inline-block; }
.archive-year.open > .archive-year-label .chev,
.archive-month.open > .archive-month-label .chev { transform: rotate(90deg); }
.archive-months { display: none; flex-direction: column; padding-left: 18px; gap: 2px; padding-bottom: 6px; }
.archive-year.open .archive-months { display: flex; }

.archive-month { margin-bottom: 2px; }
.archive-month-label {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
  user-select: none;
}
.archive-month-label .count { color: var(--text-3); font-weight: 500; margin-left: auto; }
.archive-days { display: none; flex-direction: column; padding-left: 18px; gap: 6px; padding-bottom: 6px; }
.archive-month.open .archive-days { display: flex; }
.archive-days a { font-size: 12.5px; color: var(--text-2); padding: 2px 0; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
.archive-days a:hover { color: var(--blue-700); text-decoration: underline; }
.archive-days a .count { color: var(--text-3); font-weight: 500; }
.archive-empty { font-size: 13px; color: var(--text-3); }

/* ── Background triangle band ─────────────────────────────────────────────────
   Fondo liso (--surface) con una franja decorativa de triángulos solo al pie
   del contenido (medidas y color de trazo tomados del archivo de marca). */
.tri-band {
  height: 260px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='175'><g fill='none' stroke='%236D7E76' stroke-width='1.2' stroke-opacity='0.55'><polygon points='35,0 0,60 70,60'/><polygon points='70,0 140,0 105,60'/><polygon points='0,87.5 70,87.5 35,147.5'/><polygon points='105,87.5 70,147.5 140,147.5'/></g></svg>");
  background-repeat: repeat;
  background-size: 140px 175px;
  background-position: top center;
  pointer-events: none;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer { background: var(--blue-900); padding: 34px 0; }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; text-align: center; }
.footer-disclaimer { font-size: 11.5px; color: rgba(255,255,255,.4); max-width: 520px; margin: 0 auto 8px; line-height: 1.6; }
.footer-copy { font-size: 11.5px; color: rgba(255,255,255,.28); }
.footer-ai-note { font-size: 10.5px; color: rgba(255,255,255,.22); margin-top: 6px; font-style: italic; }

/* ── Modal (detalle desde búsqueda / archivo, si hiciera falta) ──────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(29,46,72,.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--sh-lg);
  transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close {
  background: rgba(255,255,255,.1); border: none; border-radius: 6px;
  width: 32px; height: 32px; cursor: pointer; color: white;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s;
}
.modal-close:hover { background: rgba(255,255,255,.2); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; gap: 28px; }
  .card-body { padding: 20px; }
  .tri-band { height: 160px; }
  .header-right { position: static; justify-content: flex-end; padding: 10px 20px; background: var(--blue-900); }
}
@media (max-width: 600px) {
  .card-head { padding: 16px 20px; }
  .card-body { padding: 18px; }
  /* La imagen del header escala con el ancho; por debajo de 600px eso deja el
     logo y el texto ilegibles. Se fija un alto mínimo y se recorta con
     object-fit, priorizando el logo (izquierda) sobre el motivo decorativo. */
  .header { height: 92px; }
  .header img { width: 100%; height: 100%; object-fit: cover; object-position: left center; }
}
