/* ============================================================
   Dataproa Markets — styles.css
   Marca Dataproa por tokens (--brand*). Tema oscuro (default) y
   claro ([data-theme="light"]). Espejo del enfoque del PMO.
   ============================================================ */

:root {
  /* --- Marca Dataproa (editar aqui para re-marcar) --- */
  --brand:       #0e7c66;   /* verde-teal mercados */
  --brand-dark:  #0a5c4b;
  --brand-light: #16a085;
  --accent:      #C9A84C;   /* dorado */
  --up:          #16c784;   /* velas alcistas */
  --down:        #ea3943;   /* velas bajistas */
  --up-soft:     rgba(22, 199, 132, 0.15);
  --down-soft:   rgba(234, 57, 67, 0.15);

  /* --- Tema OSCURO (default) --- */
  --bg-primary:    #071410;
  --bg-secondary:  #0a1c17;
  --bg-card:       #0f2620;
  --bg-card-hover: #143029;
  --bg-input:      #0f2620;
  --border-color:  #1c3a30;
  --border-light:  #2a5245;

  --text-primary:   #eafff6;
  --text-secondary: #9fc4b6;
  --text-muted:     #6d8b80;

  --neutral:        #8a9aa0;

  --shadow-sm: 0 1px 3px rgba(0,10,6,0.45);
  --shadow-md: 0 4px 12px rgba(0,10,6,0.55);
  --shadow-lg: 0 8px 24px rgba(0,10,6,0.65);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --transition: all 0.18s ease;
  --sidebar-width: 250px;
  --font: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* --- Tema CLARO --- */
[data-theme="light"] {
  --bg-primary:    #f4f7f6;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f0f5f3;
  --bg-input:      #f4f7f6;
  --border-color:  #dde7e3;
  --border-light:  #cbdad4;
  --text-primary:   #0d201a;
  --text-secondary: #4a655c;
  --text-muted:     #7d938b;
  --shadow-sm: 0 1px 3px rgba(14,124,102,0.10);
  --shadow-md: 0 4px 12px rgba(14,124,102,0.12);
  --shadow-lg: 0 8px 24px rgba(14,124,102,0.15);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
h1,h2,h3,h4,h5,h6 { font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--brand-light); text-decoration: none; }
a:hover { color: var(--brand); }
.mono { font-family: var(--mono); }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-muted); }

/* --- Layout --- */
.app-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--brand-dark) 0%, var(--bg-secondary) 100%);
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px; background: var(--brand); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 18px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(14,124,102,0.4);
}
.logo-text h1 { font-size: 15px; color: #fff; line-height: 1.1; }
[data-theme="light"] .logo-text h1 { color: #fff; }
.logo-text h1 .brand-accent { color: var(--accent); }
.logo-text span { font-size: 9.5px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.2px; display: block; margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section { margin-bottom: 14px; }
.nav-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: 6px 12px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary);
  font-size: 13.5px; transition: var(--transition); user-select: none;
}
.nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--brand-light); color: #fff;
  font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 700;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border-color); }
.disclaimer-mini { font-size: 10px; color: var(--text-muted); line-height: 1.35; }

/* --- Main --- */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-width: 0; display: flex; flex-direction: column; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 22px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 50;
}
.top-bar-left { display: flex; align-items: center; gap: 14px; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 20px; cursor: pointer; }
.breadcrumb { font-size: 13px; color: var(--text-muted); }
.breadcrumb .separator { margin: 0 6px; }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }
.top-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.top-select {
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 12.5px; font-family: var(--font); cursor: pointer;
}
.top-select:focus { outline: none; border-color: var(--brand); }

.lang-switch, .theme-switch { display: inline-flex; border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
.lang-btn, .icon-btn {
  background: var(--bg-input); color: var(--text-secondary); border: none;
  padding: 6px 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.lang-btn.active { background: var(--brand); color: #fff; }
.icon-btn { border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* --- Views --- */
.view-container { display: none; }
.view-container.active { display: block; }
.page-content { padding: 22px; max-width: 1400px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h2 { font-size: 22px; margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--text-muted); max-width: 720px; }
.header-actions { display: flex; gap: 8px; }

/* --- Cards / grid --- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.stat-change { font-size: 12px; font-weight: 600; }

/* --- Badges de lectura / rating --- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-bullish { background: var(--up-soft); color: var(--up); }
.badge-bearish { background: var(--down-soft); color: var(--down); }
.badge-neutral { background: rgba(138,154,160,0.15); color: var(--neutral); }
.badge-demo { background: rgba(201,168,76,0.18); color: var(--accent); letter-spacing: 1px; font-size: 10px; }

.rating-pill { display: inline-block; padding: 6px 16px; border-radius: 24px; font-weight: 800; font-size: 15px; }
.rating-strongBuy { background: var(--up); color: #04140d; }
.rating-buy { background: var(--up-soft); color: var(--up); }
.rating-neutral { background: rgba(138,154,160,0.18); color: var(--neutral); }
.rating-sell { background: var(--down-soft); color: var(--down); }
.rating-strongSell { background: var(--down); color: #1a0405; }

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-color); }
.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 700; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table td.num { font-family: var(--mono); text-align: right; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; font-family: var(--font); transition: var(--transition);
}
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.tf-btn { padding: 5px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; }
.tf-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- Chart --- */
.chart-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-toolbar .group { display: flex; gap: 4px; align-items: center; }
.chart-wrap { position: relative; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
#chart-canvas, #osc-canvas { display: block; width: 100%; cursor: crosshair; }
.chart-legend { position: absolute; top: 8px; left: 12px; font-size: 12px; font-family: var(--mono); background: rgba(0,0,0,0.35); padding: 4px 10px; border-radius: 6px; pointer-events: none; }
[data-theme="light"] .chart-legend { background: rgba(255,255,255,0.7); color: var(--text-primary); }
.toggle-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 14px; border: 1px solid var(--border-color); background: var(--bg-input); font-size: 11.5px; cursor: pointer; color: var(--text-secondary); }
.toggle-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- Disclaimer banner --- */
.disclaimer-banner {
  background: rgba(201,168,76,0.10); border: 1px solid rgba(201,168,76,0.3);
  color: var(--text-secondary); font-size: 11.5px; padding: 8px 14px;
  border-radius: var(--radius-sm); margin-top: 16px; line-height: 1.4;
}

.placeholder-box { padding: 40px; text-align: center; color: var(--text-muted); border: 1px dashed var(--border-color); border-radius: var(--radius-md); }

/* --- F4 Interpretación --- */
.grid-1 { grid-template-columns: 1fr; }
.headline-card { border-left: 3px solid var(--brand); margin-bottom: 16px; }
.setup-card { border: 1px solid var(--border-light); }
.setup-dir { font-size: 13px; margin: 4px 0 12px; }
.setup-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.setup-cell { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; }
.ia-out { white-space: pre-wrap; font-size: 12px; font-family: var(--mono); background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px; margin-top: 12px; line-height: 1.5; color: var(--text-secondary); }
@media (max-width: 700px) { .setup-grid { grid-template-columns: repeat(2, 1fr); } }

/* --- F5 Decisiones / bitácora --- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.field input, .field select { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 7px 9px; font-size: 13px; font-family: var(--font); }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); }
/* Constructor de condiciones (Screener F6) y editores de alertas (F7) */
.cond-row select, .cond-row input, .alert-form select, .alert-form input {
  background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 6px 8px; font-size: 12.5px; font-family: var(--font); }
.cond-row select:focus, .cond-row input:focus, .alert-form select:focus, .alert-form input:focus { outline: none; border-color: var(--brand); }
.cond-row .cond-val-rating label { color: var(--text-secondary); }
.alert-active { border-left: 3px solid var(--brand); padding: 8px 12px; margin-bottom: 8px; background: var(--bg-input); border-radius: var(--radius-sm); }
.calc-row { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.calc-item { display: flex; flex-direction: column; }
.calc-item .lbl { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.calc-item .val { font-size: 16px; font-weight: 700; font-family: var(--mono); }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px; text-align: center; }
.stat-tile .big { font-size: 22px; font-weight: 800; font-family: var(--mono); }
.stat-tile .cap { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.status-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.status-planned { background: rgba(138,154,160,0.18); color: var(--neutral); }
.status-open { background: rgba(201,168,76,0.18); color: var(--accent); }
.status-closed { background: var(--up-soft); color: var(--up); }
.equity-svg { width: 100%; height: 160px; display: block; }
@media (max-width: 820px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }

/* --- Responsive --- */
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .top-bar { flex-wrap: wrap; row-gap: 8px; height: auto; padding-top: 8px; padding-bottom: 8px; }
  .top-bar-right { width: 100%; justify-content: flex-start; }
}

/* --- Pantallas chicas (teléfono) --- */
@media (max-width: 560px) {
  .page-content { padding: 14px; }
  .top-select { max-width: 42vw; }
  .breadcrumb { font-size: 12px; }
  .breadcrumb span:not(.current) { display: none; }
  .chart-toolbar { gap: 6px; }
  .chart-toolbar .group { flex-wrap: wrap; }
  .setup-grid { grid-template-columns: 1fr 1fr; }
  .page-header h2 { font-size: 18px; }
  .card { padding: 14px; }
}

/* El canvas del gráfico siempre ocupa el ancho disponible y tiene alto mínimo. */
#dpm-chart-host { width: 100%; min-height: 320px; }
#dpm-chart-host canvas { display: block; width: 100%; max-width: 100%; }

/* ============================================================
   Cinta de cotizaciones (ticker) — estilo plataforma de trading
   ============================================================ */
.market-ticker {
  display: flex; align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  height: 34px; overflow: hidden;
}
.ticker-tag {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 800; letter-spacing: .5px;
  color: var(--brand-light); background: var(--up-soft);
  padding: 3px 8px; margin: 0 10px; border-radius: 4px; white-space: nowrap;
}
.ticker-viewport { flex: 1 1 auto; overflow: hidden; position: relative; }
.ticker-track { display: inline-flex; white-space: nowrap; will-change: transform; }
.ticker-track.ticker-anim { animation: ticker-scroll 60s linear infinite; }
.ticker-viewport:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 16px; font-size: 12.5px; border-right: 1px solid var(--border-color);
}
.ticker-item .tk-sym { font-weight: 700; color: var(--text-primary); }
.ticker-item .tk-price { color: var(--text-secondary); font-size: 12px; }
.ticker-item .tk-chg { font-weight: 600; font-size: 12px; }
.ticker-item .tk-live { color: var(--accent-up, #16a34a); font-size: 9px; vertical-align: middle; animation: tkPulse 1.6s ease-in-out infinite; }
@keyframes tkPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ticker-track.ticker-anim { animation: none; } .ticker-item .tk-live { animation: none; } }

/* ============================================================
   Panorama enriquecido: tiles de resumen, movers y heatmap
   ============================================================ */
.pano-tiles {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
.pano-tile {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 14px 12px; text-align: center;
}
.pano-tile .pt-val { font-size: 24px; font-weight: 800; line-height: 1.1; }
.pano-tile .pt-cap { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }

.mover-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
}
.mover-row:hover { background: var(--bg-card-hover); }
.mover-row .mover-sym { font-weight: 700; font-size: 12.5px; }

.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 8px; }
.heat-cell {
  border-radius: 8px; padding: 10px 8px; cursor: pointer; text-align: center;
  color: #fff; border: 1px solid rgba(255,255,255,.08); transition: transform .08s ease;
}
.heat-cell:hover { transform: translateY(-2px); }
.heat-cell .heat-sym { display: block; font-weight: 800; font-size: 12.5px; }
.heat-cell .heat-chg { display: block; font-size: 11px; opacity: .92; margin-top: 2px; }
.heat-strongBuy { background: #0f9d58; }
.heat-buy       { background: #57bb8a; }
.heat-neutral   { background: #8a9aa0; }
.heat-sell      { background: #e8825a; }
.heat-strongSell{ background: #d24b3e; }

@media (max-width: 820px) { .pano-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .pano-tiles { grid-template-columns: repeat(2, 1fr); } .ticker-tag { display: none; } }

/* ===== Backtesting (Ola 4C) ===== */
.bt-metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 4px; }
.bt-metric-grid .stat-tile .big { font-size: 18px; }
@media (max-width: 900px) { .bt-metric-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .bt-metric-grid { grid-template-columns: repeat(2, 1fr); } }
.bt-heatmap { border-collapse: collapse; font-family: var(--mono); }
.bt-heatmap th, .bt-heatmap td { padding: 6px 9px; text-align: center; border: 1px solid var(--bg-card); }
.bt-heatmap td.bt-heat-cell { font-weight: 700; border-radius: 3px; }
