/* VCCE - Visual Clarity & Cognitive Ease
   Tema sobrio y de alta legibilidad (WCAG 2.2 AA como minimo).
   Se activa con <html data-style="vcce">. No cambia la estructura: solo la
   "piel" del diseno Juego (fuentes, color, espaciado, foco y densidad).
   Estilo reutilizable en futuros disenos. */

html[data-style="vcce"] {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
}

/* --- Paleta (oscuro) --- */
html[data-style="vcce"][data-theme="dark"] {
  --bg: #0f1419;
  --bg-elevated: #171d24;
  --elev: #171d24;
  --surface: #171d24;
  --ink: #e9edf1;
  --text: #e9edf1;
  --muted: #9aa6b2;
  --line: #2a333d;
  --border: #2a333d;
  --accent: #2f6fd0;
  --primary: #2f6fd0;
  --primary-end: #245cb0;
  --link: #7aaeff;
  --hud-cyan: #7aaeff;
  --hud-amber: #e3b341;
  --err: #e5484d;
  --danger: #e5484d;
  --input-bg: #121922;
  --hover: rgba(122, 174, 255, 0.12);
  --hud-glass: #171d24;
  --hud-line: #2a333d;
  --hud-head: #171d24;
  --topbar-bg: #171d24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --world-a: transparent;
  --world-b: transparent;
  --tile-bg: #171d24;
  --row-alt: #171d24;
  --row-hover: #1d2530;
  --ok-bg: rgba(46, 160, 67, 0.14);
  --ok-border: rgba(46, 160, 67, 0.4);
  --ok-text: #7ee2a8;
  --err-bg: rgba(229, 72, 77, 0.14);
  --err-border: rgba(229, 72, 77, 0.4);
  --err-text: #ffb4b6;
}

/* --- Paleta (claro) --- */
html[data-style="vcce"][data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --elev: #ffffff;
  --surface: #ffffff;
  --ink: #1b2027;
  --text: #1b2027;
  --muted: #55606c;
  --line: #d7dce2;
  --border: #d7dce2;
  --accent: #1d4ed8;
  --primary: #1d4ed8;
  --primary-end: #1a44bd;
  --link: #1d4ed8;
  --hud-cyan: #1d4ed8;
  --hud-amber: #8a5a00;
  --err: #b42318;
  --danger: #b42318;
  --input-bg: #ffffff;
  --hover: rgba(29, 78, 216, 0.08);
  --hud-glass: #ffffff;
  --hud-line: #d7dce2;
  --hud-head: #eef0f3;
  --topbar-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  --world-a: transparent;
  --world-b: transparent;
  --tile-bg: #ffffff;
  --row-alt: #f2f4f7;
  --row-hover: #e9edf2;
  --ok-text: #17663a;
  --err-text: #a4262c;
}

/* --- Tipografia base (16 px / 1.5) --- */
html[data-style="vcce"] .app-body,
html[data-style="vcce"] .hud-body {
  font-size: 16px;
  line-height: 1.5;
}
html[data-style="vcce"] h1,
html[data-style="vcce"] h2,
html[data-style="vcce"] h3,
html[data-style="vcce"] .app-title,
html[data-style="vcce"] .hud-stat-label,
html[data-style="vcce"] .hud-stat-value,
html[data-style="vcce"] .hud-telemetry,
html[data-style="vcce"] .app-header .hud-home .eyebrow,
html[data-style="vcce"] [data-markdown] code {
  font-family: var(--font) !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  text-shadow: none !important;
}
html[data-style="vcce"] h1 { font-size: 1.5rem; font-weight: 600; color: var(--ink); }
html[data-style="vcce"] h2 { font-size: 1.25rem; font-weight: 600; }
html[data-style="vcce"] h3 { font-size: 1rem; font-weight: 600; color: var(--muted); }
html[data-style="vcce"] .app-title { font-size: 1.25rem; font-weight: 600; color: var(--ink); }
html[data-style="vcce"] .hud-stat-label,
html[data-style="vcce"] .app-header .hud-home .eyebrow { font-size: 0.8125rem; color: var(--muted); }
html[data-style="vcce"] .hud-stat-value { font-size: 1rem; font-weight: 600; }

/* --- Fondo: sin rejilla ni rayado --- */
html[data-style="vcce"] .app-body::before,
html[data-style="vcce"][data-theme] .app-body::before,
html[data-style="vcce"][data-theme] body.crm-body::before { background-image: none !important; }
html[data-style="vcce"] .app-body::after,
html[data-style="vcce"][data-theme] .app-body::after,
html[data-style="vcce"][data-theme] body.crm-body::after,
html[data-style="vcce"] body::after { display: none !important; background: none !important; }
html[data-style="vcce"] .hud-world,
html[data-style="vcce"] .hud-scan { display: none !important; }

/* --- Cabecera --- */
html[data-style="vcce"] .app-header,
html[data-style="vcce"][data-theme="light"] .app-header,
html[data-style="vcce"] .hud-telemetry {
  background: var(--elev);
  border-color: var(--line);
  box-shadow: none;
  backdrop-filter: none;
  color: var(--ink);
}
html[data-style="vcce"][data-theme="light"] .app-header .hud-home .eyebrow,
html[data-style="vcce"][data-theme="light"] .hud-stat-label { color: var(--muted); }
html[data-style="vcce"][data-theme="light"] .app-header .hud-home .app-title,
html[data-style="vcce"][data-theme="light"] .hud-stat-value { color: var(--ink); }
html[data-style="vcce"][data-theme="light"] .app-header .hud-icon-btn,
html[data-style="vcce"][data-theme="light"] .app-header .hud-menu-btn { color: var(--ink); border-color: var(--line); }
html[data-style="vcce"][data-theme="light"] .app-header .hud-menu-btn span { background: var(--ink); }
html[data-style="vcce"][data-theme="light"] .hud-sec-link,
html[data-style="vcce"][data-theme="light"] .hud-sec-link:visited { color: var(--muted); }

/* --- Navegacion --- */
html[data-style="vcce"] .hud-sec-link {
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  border-radius: 6px;
}
html[data-style="vcce"] .hud-sec-link:hover { color: var(--accent); border-color: transparent; background: var(--hover); }
html[data-style="vcce"] .hud-sec-link.is-on,
html[data-style="vcce"] .hud-sec-link.is-on:visited,
html[data-style="vcce"][data-theme="light"] .hud-sec-link.is-on,
html[data-style="vcce"][data-theme="light"] .hud-sec-link.is-on:visited {
  color: var(--accent);
  border-color: transparent;
  background: var(--hover);
  box-shadow: none;
  font-weight: 700;
}

/* --- Botones --- */
html[data-style="vcce"] .btn,
html[data-style="vcce"] button.btn,
html[data-style="vcce"] button.button {
  border-radius: var(--radius);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  min-height: 40px;
}
/* Neutros: fondo de superficie + texto normal */
html[data-style="vcce"][data-theme] .btn:not(.btn-primary):not(.btn-save):not(.btn-solid):not(.btn-danger):not(.button-primary),
html[data-style="vcce"][data-theme] button.btn:not(.btn-primary):not(.btn-save):not(.btn-solid):not(.btn-danger) {
  background: var(--elev);
  border-color: var(--line);
  color: var(--ink) !important;
}
html[data-style="vcce"][data-theme] .btn:not(.btn-primary):not(.btn-save):not(.btn-solid):not(.btn-danger):hover {
  border-color: var(--accent);
  color: var(--accent) !important;
  filter: none;
}
/* Primarios: acento + texto blanco */
html[data-style="vcce"] .btn-primary,
html[data-style="vcce"] .btn-save,
html[data-style="vcce"] .btn-solid,
html[data-style="vcce"] button.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff !important;
}
html[data-style="vcce"] .btn-primary:hover,
html[data-style="vcce"] .btn-save:hover,
html[data-style="vcce"] .btn-solid:hover {
  background: var(--primary-end);
  border-color: var(--primary-end);
  filter: none;
}
html[data-style="vcce"][data-theme] .btn-danger:not(.btn-primary):not(.btn-save):not(.btn-solid) {
  background: var(--elev);
  border-color: var(--line);
  color: var(--err) !important;
}

/* --- Controles de icono y conmutador --- */
html[data-style="vcce"] .hud-icon-btn,
html[data-style="vcce"] .hud-menu-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}
html[data-style="vcce"] .hud-icon-btn:hover,
html[data-style="vcce"] .hud-menu-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: none; }
html[data-style="vcce"] .hud-menu-btn span { background: var(--ink); }
html[data-style="vcce"] .theme-switch { width: 48px; height: 28px; border-color: var(--line); background: var(--bg); }
html[data-style="vcce"] .theme-switch-thumb { background: var(--accent); }

/* --- Formularios (no toca los compactos de tabla .cell) --- */
html[data-style="vcce"] .input,
html[data-style="vcce"] input:not(.cell):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-style="vcce"] select:not(.cell),
html[data-style="vcce"] textarea { border-radius: var(--radius); min-height: 40px; }
html[data-style="vcce"] .label { color: var(--ink); }

/* --- Foco siempre visible --- */
html[data-style="vcce"] :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
html[data-style="vcce"] input:focus,
html[data-style="vcce"] select:focus,
html[data-style="vcce"] textarea:focus { border-color: var(--accent); }

/* --- Controles del toolbar y filtro de estados (misma altura) --- */
html[data-style="vcce"] .toolbar input.toolbar-search,
html[data-style="vcce"] .toolbar select.toolbar-group {
  height: auto;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.95rem;
}
html[data-style="vcce"] .est-filter-btn {
  height: auto;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.95rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
}
/* La tabla editable del CRM mantiene su densidad (que la fila y la confianza cuadren) */
html[data-style="vcce"] .crm-table tbody td,
html[data-style="vcce"] .crm-table tfoot td { padding: 2px 10px; }
html[data-style="vcce"] .crm-table tbody td.col-stars,
html[data-style="vcce"] .crm-table tfoot td.col-stars { padding: 0 0.5rem; }

/* --- Tarjetas, tablas y avisos --- */
html[data-style="vcce"] .card,
html[data-style="vcce"] .sys-card,
html[data-style="vcce"] .cfg-card { border-radius: var(--radius); }
html[data-style="vcce"] .card { background: var(--elev); border-color: var(--line); box-shadow: var(--shadow); }
html[data-style="vcce"] th,
html[data-style="vcce"] td { padding: 8px 12px; }
html[data-style="vcce"] thead th { text-transform: none; letter-spacing: normal; font-size: 0.8125rem; color: var(--muted); }
html[data-style="vcce"] .alert,
html[data-style="vcce"] .message { border-radius: var(--radius); }

/* --- Enlaces de contenido: subrayado (el color no es el unico indicador) --- */
html[data-style="vcce"] .app-main a:not(.btn):not(.hud-sec-link):not(.hud-icon-btn),
html[data-style="vcce"] .hud-canvas a:not(.btn):not(.hud-sec-link):not(.hud-icon-btn) {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Seleccion de estilo en Configuracion --- */
.ui-style-pick { display: grid; gap: 0.65rem; margin: 0.5rem 0 0; max-width: 520px; }

/* --- Menu lateral (solo VCCE y escritorio) --- */
html[data-style="vcce"] .vcce-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  padding: 14px 12px 24px;
  overflow-y: auto;
  background: var(--elev);
  border-right: 1px solid var(--line);
  z-index: 60;
}
html[data-style="vcce"] body:has(.vcce-rail) { padding-left: 280px; }
html[data-style="vcce"] body:has(.vcce-rail) .hud-telemetry { left: 292px; }
html.rail-collapsed body:has(.vcce-rail) .hud-telemetry { left: 80px; }

html[data-style="vcce"] .vcce-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 12px;
}
html[data-style="vcce"] .vcce-rail-brand { font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; color: var(--ink); }
html[data-style="vcce"] .vcce-rail-toggle {
  width: 40px;
  height: 40px;
  margin-left: 6px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
html[data-style="vcce"] .vcce-rail-toggle:hover { border-color: var(--accent); color: var(--accent); }

html[data-style="vcce"] .vcce-rail-section { margin-top: 14px; }
html[data-style="vcce"] .vcce-rail-title {
  margin: 0 8px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
html[data-style="vcce"] .vcce-rail-row { display: flex; align-items: center; gap: 2px; }

html[data-style="vcce"] .vcce-rail-link,
html[data-style="vcce"] .vcce-rail-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  color: var(--ink);
  text-decoration: none;
}
html[data-style="vcce"] .vcce-rail-link:hover,
html[data-style="vcce"] .vcce-rail-sublink:hover { background: var(--hover); color: var(--accent); text-decoration: none; }
html[data-style="vcce"] .vcce-rail .is-on {
  background: var(--hover);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
html[data-style="vcce"] .vcce-rail-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-style="vcce"] .vcce-rail-dot { display: none; }

html[data-style="vcce"] .vcce-rail-exp {
  flex: none;
  width: 34px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
html[data-style="vcce"] .vcce-rail-exp:hover { color: var(--accent); background: var(--hover); }
html[data-style="vcce"] .vcce-rail-exp svg { transition: transform 0.15s ease; }
html[data-style="vcce"] .vcce-group.is-open .vcce-rail-exp svg { transform: rotate(180deg); }

html[data-style="vcce"] .vcce-sub {
  display: none;
  margin: 2px 0 6px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
html[data-style="vcce"] .vcce-group.is-open .vcce-sub { display: block; }
html[data-style="vcce"] .vcce-rail-sublink { min-height: 38px; padding: 6px 10px; font-size: 0.95rem; color: var(--muted); }
html[data-style="vcce"] .vcce-rail-sublink:hover { color: var(--accent); }
html[data-style="vcce"] .vcce-rail-sublink.is-on { color: var(--accent); border-left-color: transparent; }

/* Plegado: el menu se oculta del todo; solo queda el boton en la cabecera */
html.rail-collapsed .vcce-rail { display: none; }
html.rail-collapsed body:has(.vcce-rail) { padding-left: 0; }

/* El menu superior de secciones se sustituye por el lateral (escritorio) */
@media (min-width: 901px) {
  html[data-style="vcce"] .hud-sec { display: none !important; }
}
/* En movil no hay lateral: se usa el menu superior de siempre */
@media (max-width: 900px) {
  html[data-style="vcce"] .vcce-rail { display: none !important; }
  html[data-style="vcce"] .vcce-rail-toggle { display: none !important; }
  html[data-style="vcce"] .hud-telemetry { left: 12px !important; }
  html[data-style="vcce"] body,
  html.rail-collapsed body { padding-left: 0 !important; }
}
