/* base.css — Variables globales, layout, tipografia, botones */

:root {
  --bg:        #020810;
  --surface:   #080e18;
  --surface2:  #0d1622;
  --surface3:  #121d2c;
  --border:    #1a2e44;
  --border2:   #26435e;
  --accent:    #1adaff;
  --accent2:   #005f7a;
  --green:     #1af590;
  --green-dim: #00d865;
  --red:       #ff6868;
  --red-dim:   #ee3030;
  --yellow:    #ffe880;
  --orange:    #ffbb4d;
  --white:     #f0f8ff;
  --gray:      #8aacca;
  --purple:    #a855f7;
  --purple-dim: rgba(168,85,247,0.12);
  --gray2:     #263d55;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Syne', sans-serif;
  --ui:        'Inter', sans-serif;
  --ease:      cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --surface2:  #e8eef4;
  --border:    #c5d5e5;
  --border2:   #9ab0c8;
  --accent:    #0099cc;
  --accent2:   #ddf0f8;
  --green:     #007a40;
  --green-dim: #005830;
  --red:       #cc2020;
  --red-dim:   #991818;
  --yellow:    #a07800;
  --orange:    #b86a00;
  --white:     #1a2a3a;
  --gray:      #4a6a88;
  --gray2:     #c8d8e8;
}

[data-theme="light"] body::before {
  background-image:
    linear-gradient(rgba(0,153,204,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,153,204,0.05) 1px, transparent 1px);
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--mono);
  font-size: 17px;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content:'';
  position:fixed;
  inset:0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events:none;
  z-index:0;
}
.wrap { position:relative; z-index:1; max-width:1700px; margin:0 auto; padding:24px 20px; }

/* HEADER — legacy (elemento eliminado del HTML, conservado por .header-right en templates) */
#last-update { font-size:14px; color:var(--gray); letter-spacing:1px; }

/* SEARCH */
.search-section { display:flex; gap:10px; margin-bottom:24px; flex-wrap:wrap; }
.search-wrap { position:relative; flex:1; max-width:420px; }
.search-wrap svg { position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--gray); pointer-events:none; }
#search-input {
  width:100%; background:var(--surface); border:1px solid var(--border);
  border-radius:8px; padding:11px 14px 11px 42px; color:var(--white);
  font-family:var(--mono); font-size:17px; outline:none; transition:border-color 0.2s;
}
#search-input:focus { border-color:var(--accent); }
#search-input::placeholder { color:var(--gray); }

.btn {
  background:var(--accent2); border:1px solid var(--accent); color:var(--white);
  padding:11px 20px; border-radius:8px; font-family:var(--mono); font-size:15px;
  font-weight:600; cursor:pointer; transition:all 0.2s; letter-spacing:1px;
  text-transform:uppercase; white-space:nowrap;
}
.btn:hover { background:var(--accent); color:var(--bg); }
.btn-ghost { background:transparent; border:1px solid var(--border); color:var(--gray); }
.btn-ghost:hover { border-color:var(--accent); color:var(--accent); background:transparent; }
.btn-secondary { border-color:var(--border2); background:var(--surface2); color:var(--gray); }
.btn-secondary:hover { border-color:var(--accent); color:var(--accent); background:rgba(26,218,255,0.08); }
.btn-danger { border-color:var(--red-dim); background:transparent; color:var(--red); }
.btn-danger:hover { background:rgba(255,104,104,0.12); border-color:var(--red); }
.btn-sm { padding:7px 14px; font-size:14px; }
/* DS-1 — Semantic button variants */
.btn-primary {
  background: var(--accent2); border: 1px solid var(--accent); color: var(--white);
  padding: 11px 20px; border-radius: 8px; font-family: var(--mono); font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all 0.2s; letter-spacing: 1px;
  text-transform: uppercase; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.btn-success {
  background: var(--green); border: 1px solid var(--green); color: #000;
  padding: 11px 20px; border-radius: 8px; font-family: var(--mono); font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all 0.2s; letter-spacing: 1px;
  text-transform: uppercase; white-space: nowrap;
}
.btn-success:hover { background: color-mix(in srgb, var(--green) 85%, white); border-color: color-mix(in srgb, var(--green) 85%, white); }
.btn-success.btn-sm { padding: 7px 14px; font-size: 14px; }

/* Accessibility & utility */
.visually-hidden {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
.hidden { display: none !important; }

/* ===== NAV REDESIGN ===== */

/* Nav top bar */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-left  { display: flex; align-items: center; gap: 12px; }
.nav-center { display: flex; align-items: center; gap: 4px; }
.nav-right  { display: flex; align-items: center; }

/* Logo */
.nav-logo {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-decoration: none;
  color: var(--white);
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}
.nav-logo small {
  font-size: 10px;
  color: var(--gray);
  font-weight: 400;
  font-family: var(--mono);
  letter-spacing: 1px;
}

/* Hamburger */
.nav-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-radius: 6px;
  transition: background 0.15s;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all 0.2s;
}
.nav-hamburger:hover { background: var(--surface2); }

/* Nav links (center) */
.nav-link {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 200ms ease-out, background 200ms ease-out, border-color 200ms ease-out;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}
.nav-link.active {
  color: var(--accent);
  background: rgba(26, 218, 255, 0.08);
  border-color: rgba(26, 218, 255, 0.25);
  font-weight: 600;
}

/* User dropdown */
.nav-user-dropdown { position: relative; }
.nav-user-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--white);
  font-family: var(--mono);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.nav-user-btn:hover { background: var(--surface2); border-color: var(--border2); }
.nav-user-arrow {
  font-size: 10px;
  color: var(--gray);
  transition: transform 0.2s;
}
.nav-user-dropdown.open .nav-user-arrow { transform: rotate(180deg); }
.nav-user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 180px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 200;
}
.nav-user-dropdown.open .nav-user-menu { display: block; }
.nav-user-name {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  font-family: var(--mono);
}
.nav-user-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--white);
  font-family: var(--mono);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s;
}
.nav-user-item:hover { background: var(--surface); }
.nav-user-item--danger { color: var(--red); }
.nav-user-item--danger:hover { background: rgba(255, 104, 104, 0.1); }
.nav-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Sidebar */
.nav-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 300;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.nav-sidebar.open { transform: translateX(0); }
.nav-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 20, 0.55);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.nav-sidebar-overlay.open { opacity: 1; pointer-events: auto; }
.nav-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.nav-sidebar-title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}
.nav-sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}
.nav-sidebar-close:hover { background: var(--surface2); color: var(--white); }
.nav-sidebar-links {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-sidebar-link {
  display: block;
  padding: 10px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--white);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-sidebar-link:hover { background: var(--surface2); color: var(--accent); }
.nav-sidebar-link.active { background: rgba(26, 218, 255, 0.1); color: var(--accent); }
.nav-sidebar-divider { height: 1px; background: var(--border); margin: 8px 4px; }

/* Responsive: ocultar nav-center en mobile */
@media (max-width: 640px) {
  .nav-center { display: none; }
  .nav { padding: 0 12px; }
}

/* AUTH — legacy classes mantenidas por compatibilidad */
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.header-user { font-family: var(--mono); font-size: 13px; color: var(--gray); letter-spacing: 1px; }

/* INPUT BASE — estilos comunes a todos los inputs de la app */
.ta-field input, .ta-field select, .ta-field textarea,
.calc-field input, .calc-field select,
.pf-input, .pf-select,
.jn-input, .jn-select {
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  color: var(--white);
}
/* Focus ring uniforme — visible sin outline */
.ta-field input:focus-visible, .ta-field select:focus-visible, .ta-field textarea:focus-visible,
.calc-field input:focus-visible, .calc-field select:focus-visible,
.pf-input:focus-visible, .pf-select:focus-visible,
.jn-input:focus-visible, .jn-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* PAGE HEADER — estándar de encabezado para todas las páginas (fuera del contenedor principal) */
.page-header {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}
.page-title {
  font-family: var(--sans);
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 800;
  color: var(--white);
}
.page-title span { color: var(--accent); }
.page-sub {
  font-size: 13px;
  color: var(--gray);
  letter-spacing: 1px;
}

/* SECTION TITLE — compartida entre portfolio y journal */
.pf-section-title,
.jn-section-title {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
}
.pf-section-toggle,
.jn-section-toggle {
  font-size: 12px;
  color: var(--gray);
  transition: transform 0.2s;
}
.pf-section-toggle.collapsed,
.jn-section-toggle.collapsed { transform: rotate(180deg); }

/* FIELD — input group reutilizable (trade-analyzer, journal, portfolio) */
.ta-field {
  display:flex; flex-direction:column; gap:6px; flex:1; min-width:120px;
}
.ta-field label {
  font-size:10px; letter-spacing:2px; text-transform:uppercase; color:var(--gray);
}
.ta-field input, .ta-field select, .ta-field textarea {
  background:var(--surface2); border:1px solid var(--border);
  border-radius:8px; padding:10px 12px; color:var(--white);
  font-family:var(--mono); font-size:14px; outline:none; transition:border-color 0.2s;
}
.ta-field textarea { resize:vertical; min-height:72px; }
.ta-field input:focus, .ta-field select:focus, .ta-field textarea:focus { border-color:var(--accent); }

/* LOADING — spinner global */
.loading { text-align:center; padding:60px 20px; color:var(--gray); }
.spinner { width:32px; height:32px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin 0.8s linear infinite; margin:0 auto 16px; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ─── GLOBAL UTILITIES (P4.1) ──────────────────────────────────────────── */

/* Color text utilities */
.text-accent { color: var(--accent); }
.text-yellow { color: var(--yellow); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange  { color: var(--orange); }
.text-purple  { color: var(--purple); }
.text-gray    { color: var(--gray); }
.text-white   { color: var(--white); }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }

/* Layout utilities */
.col-full    { grid-column: 1 / -1; }
.flex-row     { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.flex-between { display:flex; align-items:center; justify-content:space-between; }

/* Label patterns (section headers repeated across templates) */
.section-label {
  font-size: 10px; color: var(--gray); letter-spacing: 1px; margin-bottom: 8px;
}
.label-xxs {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gray); margin-bottom: 8px;
}
.label-xs {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gray); margin-bottom: 8px;
}

/* Ticker inputs (always uppercase) */
.ticker-input { text-transform: uppercase; }

/* IC breakeven split panel (used in calculator sections) */
.ic-be-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.ic-leg-panel { background:var(--surface2); border-radius:8px; padding:12px; }
.ic-leg-panel.bull { border-left:3px solid var(--green); }
.ic-leg-panel.bear { border-left:3px solid var(--red); }
.ic-leg-panel-label { font-size:10px; letter-spacing:1px; margin-bottom:6px; }
.ic-leg-detail { font-size:11px; color:var(--gray); }

/* Inset info box (EMA/direction panels in search result + row detail) */
.sr-inset {
  background:var(--surface2); border-radius:8px; padding:12px; margin-bottom:16px;
}
.sr-inset.with-text { font-size:12px; color:var(--white); }
.rd-inset { background:var(--surface2); border-radius:8px; padding:12px; font-size:12px; margin-bottom:4px; }

/* Button color variants (replaces inline style + onmouseover/onmouseout) */
.btn.btn-orange { border-color:var(--orange); background:rgba(255,170,51,0.15); color:var(--orange); }
.btn.btn-orange:hover { background:var(--orange); color:#000; }
.btn.btn-purple { border-color:var(--purple); background:rgba(168,85,247,0.15); color:var(--purple); }
.btn.btn-purple:hover { background:var(--purple); color:#000; }
.btn.btn-yellow { border-color:var(--yellow); background:rgba(255,224,102,0.10); color:var(--yellow); }
.btn.btn-yellow:hover { background:var(--yellow); color:#000; }

/* badge-sm — badge pequeño en tablas */
.badge-sm { font-size: 11px; }

/* Margin top utilities (usadas en varios templates) */
.mt-8  { margin-top:  8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-28 { margin-top: 28px; }
.mb-8  { margin-bottom:  8px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mb-20 { margin-bottom: 20px; }
/* Small annotation text (em notes, hints) */
.text-note { font-size:10px; color:var(--gray); margin-top:6px; }

/* DS-2 — Input error state */
.input-error {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 2px rgba(255, 104, 104, 0.2);
}
.field-error-msg {
  color: var(--red);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

/* DS-3 — Numeric and action cell alignment in tables */
.num-cell { text-align: center; font-variant-numeric: tabular-nums; }
.actions-cell { text-align: center; }

/* DS-4 — Sticky table header */
.sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface2);
}

/* DS-5 — Toast notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: auto;
  max-width: 320px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); color: #fff; }
.toast-warning { background: var(--yellow); color: #000; }
.toast-info    { background: var(--accent); color: #fff; }

/* ── Pagination (DS-6) ───────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 4px;
}
.pagination-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: var(--white);
}
.pagination-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pagination-info {
  font-size: 13px;
  color: var(--gray);
  white-space: nowrap;
  font-family: var(--mono);
}
.pagination-total {
  opacity: 0.7;
}

/* ── Empty State (DS-7) ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--gray);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin: 0.75rem 0;
  line-height: 1.6;
}
.empty-state-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.7;
}
.empty-state-title {
  font-weight: 600;
  color: var(--white);
  margin-bottom: 4px;
  font-size: 14px;
  display: block;
}
.empty-state-action {
  margin-top: 12px;
}

/* ── Modal Overlay — base global (DS-8) ─────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 8, 20, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden {
  display: none;
}

/* ── Confirm Modal (DS-8) ───────────────────────────── */
.confirm-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.confirm-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 8px;
  font-family: var(--sans);
}
.confirm-modal-message {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 20px;
  line-height: 1.5;
  font-family: var(--mono);
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Tooltips CSS (DS-9) ─────────────────────────────────── */
/* Botones con [title] muestran tooltip flotante al hacer hover */
button[title]:not([title=""]) {
  position: relative;
}
button[title]:not([title=""])::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--gray);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--mono);
  white-space: normal;
  max-width: 220px;
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 8000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
button[title]:not([title=""]):hover::after {
  opacity: 1;
}
