/* ==========================================================================
   NICO Agent · Design System v2.1 (limpio · verdes del logotipo)
   1. Tokens  2. Base  3. Tipografía  4. Componentes  5. Layout  6. Accesibilidad
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Marca */
  /* Verdes del logotipo y el patrón NICO */
  --green-900: #1a2e1e;
  --green-800: #274428;
  --green-700: #2b5036;
  --green-600: #336d3a;
  --green-400: #5aa867;
  --green-300: #75a37c;
  --green-200: #a9d5b1;
  --green-50:  #eef6ef;
  --copper-500: #c4622d;
  --copper-50:  #fdf4ee;

  /* Superficies y texto — claro (predeterminado) */
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --sand: #f3efe7;
  --border: #e5e6e0;
  --border-strong: #d3d6ce;
  --text: #0e1a14;
  --text-2: #46554c;
  --text-3: #76837b;

  /* Semánticos */
  --primary: var(--green-700);
  --primary-hover: #223f2a;
  --primary-fg: #ffffff;
  --primary-soft: var(--green-50);
  --primary-soft-fg: var(--green-700);
  --accent: var(--copper-500);
  --accent-soft: var(--copper-50);
  --success: #336d3a;
  --warning: #b7791f;
  --danger: #d03b3b;
  --ring: rgba(90, 168, 103, 0.45);

  /* Navegación lateral (verde del logotipo, sólido) */
  --sidebar: var(--green-900);
  --sidebar-fg: #d6ecd9;
  --sidebar-muted: rgba(214, 236, 217, 0.66);
  --sidebar-active: rgba(169, 213, 177, 0.16);

  /* Forma y profundidad */
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(14, 26, 20, 0.05);
  --shadow: 0 1px 2px rgba(14, 26, 20, 0.04), 0 6px 20px -8px rgba(14, 26, 20, 0.10);
  --shadow-lg: 0 2px 4px rgba(14, 26, 20, 0.04), 0 18px 40px -16px rgba(14, 26, 20, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

.dark {
  --bg: #0b120d;
  --surface: #111c14;
  --surface-2: #15221a;
  --sand: #16241a;
  --border: #22352a;
  --border-strong: #2e4636;
  --text: #ecf5f0;
  --text-2: #a9bdb2;
  --text-3: #7f9389;
  --primary: var(--green-400);
  --primary-hover: #6fbb7b;
  --primary-fg: #0b1a0f;
  --primary-soft: rgba(90, 168, 103, 0.14);
  --primary-soft-fg: #a9d5b1;
  --accent: #e2834a;
  --accent-soft: rgba(226, 131, 74, 0.14);
  --sidebar: #070d09;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 40px -16px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* 2. Base ------------------------------------------------------------------ */
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-size: 0.9375rem; line-height: 1.6; }
::selection { background: var(--green-200); color: var(--green-900); }
:focus-visible { outline: 2px solid var(--green-400); outline-offset: 2px; border-radius: 6px; }
img { max-width: 100%; height: auto; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.bg-surface { background: var(--surface); }
.bg-sand { background: var(--sand); }
.border-base { border-color: var(--border); }
.link { color: var(--primary); font-weight: 500; text-underline-offset: 3px; }
.link:hover { text-decoration: underline; }

/* 3. Tipografía (escala modular 1.25 · base 15px) -------------------------- */
.font-display, .t-display, .t-h1, .t-h2, .t-h3, .t-num { font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, sans-serif; }
.t-display, .t-h1, .t-h2, .t-h3 { color: var(--text); }
.t-display { font-size: clamp(2.5rem, 4.6vw, 3.75rem); line-height: 1.06; font-weight: 800; letter-spacing: -0.035em; }
.t-h1 { font-size: clamp(1.75rem, 2.6vw, 2.25rem); line-height: 1.18; font-weight: 750; letter-spacing: -0.025em; }
.t-h2 { font-size: 1.5rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.018em; }
.t-h3 { font-size: 1.0625rem; line-height: 1.4; font-weight: 650; letter-spacing: -0.01em; }
.t-lead { font-size: 1.125rem; line-height: 1.65; color: var(--text-2); }
.t-body { font-size: 0.9375rem; line-height: 1.6; color: var(--text-2); }
.t-small { font-size: 0.8125rem; line-height: 1.5; color: var(--text-3); }
.t-num { font-family: "Plus Jakarta Sans", Inter, sans-serif; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.75rem; line-height: 1; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.highlight { color: var(--primary); }

/* 4. Componentes ----------------------------------------------------------- */
/* Tarjeta */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.5rem; }
.card-hover { transition: border-color 0.2s, box-shadow 0.2s var(--ease), transform 0.2s var(--ease); }
.card-hover:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: var(--shadow); transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.125rem 1.5rem; border-bottom: 1px solid var(--border); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.5rem; padding: 0 1rem; border-radius: var(--r); border: 1px solid transparent;
  font-size: 0.875rem; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn-lg { height: 3rem; padding: 0 1.375rem; font-size: 0.9375rem; }
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-icon { width: 2.5rem; padding: 0; }
.btn-primary { background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-soft-fg); }
.btn-light { background: #ffffff; color: var(--green-900); }
.btn-light:hover { background: var(--green-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b52f2f; }
.btn .arrow { transition: transform 0.2s var(--ease); }
.btn:hover .arrow { transform: translateX(2px); }

/* Insignias */
.badge { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.5rem; padding: 0 0.625rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--primary-soft); color: var(--primary-soft-fg); }
.badge-warn { background: #fdf3dc; color: #8a5a00; }
.badge-error { background: #fde8e8; color: #a12828; }
.badge-neutral { background: var(--sand); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.dark .badge-warn { background: rgba(232, 170, 40, 0.14); color: #f0c46a; }
.dark .badge-error { background: rgba(232, 80, 80, 0.14); color: #f39a9a; }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: currentColor; flex: none; }

/* Icono en recuadro */
.icon-tile { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--r); background: var(--primary-soft); color: var(--primary-soft-fg); flex: none; }
.icon-tile-accent { background: var(--accent-soft); color: var(--accent); }

/* Ilustraciones de NICO */
.art { position: relative; overflow: hidden; border-radius: var(--r-xl); background: var(--sand); }
.art img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }

/* Formularios */
.field-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 0.375rem; }
form input[type="text"], form input[type="email"], form input[type="password"], form input[type="url"],
form input[type="number"], form input[type="date"], form input[type="search"], form select, form textarea {
  width: 100%; height: 2.75rem; padding: 0 0.875rem; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
form textarea { height: auto; min-height: 7rem; padding: 0.75rem 0.875rem; }
form input::placeholder, form textarea::placeholder { color: var(--text-3); }
form input:hover, form select:hover, form textarea:hover { border-color: var(--text-3); }
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--green-400); box-shadow: 0 0 0 3px var(--ring); }
form input[type="checkbox"] { accent-color: var(--primary); width: 1rem; height: 1rem; }

/* Tablas */
.table { width: 100%; font-size: 0.875rem; }
.table th { text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); background: var(--surface-2); padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border); }
.table td { padding: 0.875rem 1.5rem; border-bottom: 1px solid var(--border); color: var(--text-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* Avisos */
.alert { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-radius: var(--r); border: 1px solid; font-size: 0.875rem; }
.alert-success { background: var(--primary-soft); border-color: color-mix(in srgb, var(--green-400) 35%, transparent); color: var(--primary-soft-fg); }
.alert-warning { background: #fdf6e7; border-color: #f0d79a; color: #7a5200; }
.alert-error { background: #fdeeee; border-color: #f2c0c0; color: #962626; }
.dark .alert-warning { background: rgba(232, 170, 40, 0.1); border-color: rgba(232, 170, 40, 0.3); color: #f0c46a; }
.dark .alert-error { background: rgba(232, 80, 80, 0.1); border-color: rgba(232, 80, 80, 0.3); color: #f39a9a; }

/* 5. Layout ---------------------------------------------------------------- */
.sidebar { background: var(--sidebar); color: var(--sidebar-fg); }
.side-link {
  display: flex; align-items: center; gap: 0.75rem; height: 2.5rem; padding: 0 0.75rem; border-radius: var(--r);
  font-size: 0.875rem; font-weight: 500; color: var(--sidebar-muted); transition: background-color 0.15s, color 0.15s;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
.side-link[aria-current="page"] { background: var(--sidebar-active); color: #ffffff; }
.side-link[aria-current="page"] svg { color: var(--green-400); }
.side-section { padding: 1rem 0.75rem 0.375rem; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(201, 240, 221, 0.4); }
.topbar { background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: saturate(180%) blur(8px); backdrop-filter: saturate(180%) blur(8px); }

/* Textura de marca: franja con el patrón geométrico NICO */
.pattern-strip { height: 6px; background: url("../img/brand/pattern.webp") center / 240px auto repeat-x, var(--green-700); }

/* Entrada suave al hacer scroll */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
.reveal.is-visible, .no-js .reveal { opacity: 1; transform: none; }

/* 6. Accesibilidad --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* Botón flotante «Habla con NICO»: el isotipo como llamada a la conversación de voz */
.nico-fab { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 25; display: flex; align-items: center; gap: .6rem;
  padding: .3rem; border-radius: 9999px; background: #2b5036; color: #fff; box-shadow: 0 12px 30px rgba(20, 40, 25, .35);
  transition: transform .2s, padding .2s; }
.nico-fab img { width: 3.5rem; height: 3.5rem; border-radius: 9999px; animation: nico-breathe 3.2s ease-in-out infinite; }
.nico-fab-label { max-width: 0; overflow: hidden; white-space: nowrap; font-weight: 700; font-size: .9rem; transition: max-width .25s, margin .25s; }
.nico-fab:hover, .nico-fab:focus-visible { transform: translateY(-2px); }
.nico-fab:hover .nico-fab-label, .nico-fab:focus-visible .nico-fab-label { max-width: 10rem; margin-right: .9rem; }
.nico-fab::after { content: ""; position: absolute; inset: 0; border-radius: 9999px; box-shadow: 0 0 0 0 rgba(196, 98, 45, .55); animation: nico-ping 2.6s infinite; pointer-events: none; }
@keyframes nico-breathe { 50% { transform: scale(1.06); } }
@keyframes nico-ping { 70% { box-shadow: 0 0 0 14px rgba(196, 98, 45, 0); } 100% { box-shadow: 0 0 0 0 rgba(196, 98, 45, 0); } }
@media (prefers-reduced-motion: reduce) { .nico-fab img, .nico-fab::after { animation: none; } }

/* Logos de tecnología: monocromos con el color del tema; el color de marca sólo al pasar el cursor */
.tech-logo svg { width: 1.4rem; height: 1.4rem; color: var(--text); opacity: .85; transition: color .2s, opacity .2s; }
.tech:hover .tech-logo svg { opacity: 1; color: var(--brand-color, var(--text)); }
