/* ================================================================
   OPTICORE — styles.css  v4.0
   Tema: Sidebar oscuro · Área principal clara · Marca por empresa
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400&display=swap');

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  /* Colores de empresa — sobrescritos por JS según ID */
  --co-primary:     #CC1F1F;
  --co-primary-dk:  #A81010;
  --co-primary-rgb: 204,31,31;

  /* Sidebar oscuro */
  --sb-bg:          #111118;
  --sb-bg2:         #1A1A24;
  --sb-border:      rgba(255,255,255,.06);
  --sb-text:        rgba(255,255,255,.55);
  --sb-text-hover:  rgba(255,255,255,.9);
  --sb-text-active: #ffffff;

  /* Main — tema claro */
  --bg:             #F4F5F9;
  --bg-2:           #ECEEF5;
  --surface:        #FFFFFF;
  --surface-2:      #F8F9FC;
  --border:         rgba(0,0,0,.08);
  --border-2:       rgba(0,0,0,.14);

  /* Texto */
  --text:           #1A1A2E;
  --text-2:         #4A5568;
  --text-3:         #9AA5B4;

  /* Semánticos */
  --green:          #10B981;
  --green-dim:      rgba(16,185,129,.1);
  --amber:          #F59E0B;
  --amber-dim:      rgba(245,158,11,.1);
  --red:            #EF4444;
  --red-dim:        rgba(239,68,68,.1);
  --blue:           #3B82F6;
  --blue-dim:       rgba(59,130,246,.1);
  --violet:         #8B5CF6;
  --violet-dim:     rgba(139,92,246,.1);
  --cyan:           #06B6D4;
  --cyan-dim:       rgba(6,182,212,.1);

  /* Aliases */
  --white:          var(--text);
  --white-70:       var(--text-2);
  --white-40:       var(--text-3);
  --white-15:       rgba(0,0,0,.05);
  --white-08:       rgba(0,0,0,.03);
  --primary:        var(--co-primary);
  --primary-2:      var(--co-primary-dk);
  --accent:         var(--co-primary);
  --accent-2:       var(--co-primary);

  --font-main:   'Sora', 'Segoe UI', sans-serif;
  --font-body:   'DM Sans', sans-serif;
  --font-mono:   'DM Mono', monospace;

  --sidebar-w:   240px;
  --header-h:    60px;
  --radius:      8px;
  --radius-lg:   12px;
  --ease:        cubic-bezier(0.16, 1, 0.3, 1);
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:   0 4px 24px rgba(0,0,0,.1);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ── Layout ──────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100vh;
}

/* ══════════════════════════════════
   SIDEBAR
══════════════════════════════════ */
.sidebar {
  grid-area: sidebar;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 100%;
  max-height: 50px;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--co-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: white;
  font-family: var(--font-main);
  flex-shrink: 0;
  position: relative;
}
.sidebar-avatar::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 9px; height: 9px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--sb-bg);
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
  font-size: 0.8rem; font-weight: 600;
  color: var(--sb-text-active);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.62rem;
  color: var(--co-primary);
  font-family: var(--font-mono);
}

.sidebar-section {
  padding: 14px 16px 4px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.22);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 8px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--sb-text);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--sb-text-hover); }
.nav-item.active { background: var(--co-primary); color: white; }
.nav-item.active .nav-icon { opacity: 1; color: white; }
.nav-icon { width: 15px; height: 15px; opacity: 0.45; flex-shrink: 0; transition: opacity 0.15s; }
.nav-item:hover .nav-icon { opacity: 0.75; }
.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: white;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 50px;
  min-width: 18px;
  text-align: center;
}
.nav-item:not(.active) .nav-badge { background: var(--co-primary); }
.nav-badge.green { background: var(--green) !important; }
.nav-badge.amber { background: var(--amber) !important; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.powered-by {
  font-size: 0.58rem;
  color: rgba(255,255,255,.22);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  line-height: 1.7;
}
.powered-by span { color: var(--co-primary); }

/* ══════════════════════════════════
   HEADER
══════════════════════════════════ */
.header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 10;
  box-shadow: var(--shadow);
}
.header-title { font-family: var(--font-main); font-size: 1rem; font-weight: 600; color: var(--text); }
.header-subtitle { font-size: 0.7rem; color: var(--text-3); font-family: var(--font-mono); }
.header-spacer { flex: 1; }
.header-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 0.82rem;
  color: var(--text-3);
  min-width: 220px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.header-search:hover { border-color: var(--border-2); }
.header-search svg { width: 14px; height: 14px; }
.header-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all 0.2s;
  position: relative;
}
.header-btn:hover { border-color: var(--border-2); color: var(--text); }
.header-btn .badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--co-primary);
  border-radius: 50%;
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-mono);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px;
  cursor: pointer; transition: border-color 0.2s;
}
.user-chip:hover { border-color: var(--border-2); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--co-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: white;
  font-family: var(--font-main);
}
.user-name { font-size: 0.78rem; color: var(--text-2); font-weight: 500; }
.user-role { font-size: 0.62rem; color: var(--co-primary); font-family: var(--font-mono); }

/* ══════════════════════════════════
   MAIN
══════════════════════════════════ */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}
.page { display: none; animation: fadeIn 0.22s var(--ease); }
.page.active { display: block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-family: var(--font-main); font-size: 1.3rem; font-weight: 700; color: var(--text); }
.page-sub { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; font-family: var(--font-mono); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 0.8rem; font-weight: 500;
  transition: all 0.2s; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--co-primary); color: white; border: 1px solid var(--co-primary); }
.btn-primary:hover { background: var(--co-primary-dk); box-shadow: 0 4px 16px rgba(var(--co-primary-rgb),.3); }
.btn-ghost { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-2); color: var(--text); }
.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,.2); }
.btn-danger  { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,.2); }
.btn-sm { padding: 6px 12px; font-size: 0.73rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--font-main); font-size: 0.88rem; font-weight: 600; color: var(--text); }
.card-sub { font-size: 0.7rem; color: var(--text-3); font-family: var(--font-mono); margin-top: 2px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  position: relative; overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad);
}
.stat-card.indigo { --grad: linear-gradient(90deg,#6366F1,#8B5CF6); }
.stat-card.violet { --grad: linear-gradient(90deg,#8B5CF6,#A78BFA); }
.stat-card.green  { --grad: linear-gradient(90deg,#10B981,#34D399); }
.stat-card.amber  { --grad: linear-gradient(90deg,#F59E0B,#FBBF24); }
.stat-card.cyan   { --grad: linear-gradient(90deg,#06B6D4,#38BDF8); }
.stat-card.red    { --grad: linear-gradient(90deg,#EF4444,#F87171); }
.stat-card.brand  { --grad: linear-gradient(90deg,var(--co-primary),var(--co-primary-dk)); }

.stat-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; font-size: 16px;
}
.stat-icon.indigo { background: rgba(99,102,241,.1);  color: #6366F1; }
.stat-icon.violet { background: rgba(139,92,246,.1);  color: #8B5CF6; }
.stat-icon.green  { background: var(--green-dim);      color: var(--green); }
.stat-icon.amber  { background: var(--amber-dim);      color: var(--amber); }
.stat-icon.cyan   { background: var(--cyan-dim);       color: var(--cyan); }
.stat-icon.red    { background: var(--red-dim);        color: var(--red); }
.stat-icon.brand  { background: rgba(var(--co-primary-rgb),.1); color: var(--co-primary); }

.stat-val { font-family: var(--font-main); font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.73rem; color: var(--text-3); line-height: 1.3; }
.stat-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.68rem; font-family: var(--font-mono);
  margin-top: 8px; padding: 2px 7px; border-radius: 50px;
}
.stat-delta.up   { background: var(--green-dim); color: var(--green); }
.stat-delta.down { background: var(--red-dim);   color: var(--red); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.col-span-2 { grid-column: span 2; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th {
  text-align: left; padding: 10px 14px;
  font-size: 0.67rem; font-family: var(--font-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 50px;
  font-size: 0.68rem; font-family: var(--font-mono);
  letter-spacing: 0.04em; white-space: nowrap; font-weight: 500;
}
.pill-green  { background: var(--green-dim);  color: var(--green); }
.pill-amber  { background: var(--amber-dim);  color: var(--amber); }
.pill-red    { background: var(--red-dim);    color: var(--red); }
.pill-indigo { background: rgba(99,102,241,.1);  color: #6366F1; }
.pill-violet { background: rgba(139,92,246,.1);  color: #8B5CF6; }
.pill-gray   { background: var(--bg-2); color: var(--text-3); }
.pill-cyan   { background: var(--cyan-dim);   color: var(--cyan); }
.pill-brand  { background: rgba(var(--co-primary-rgb),.1); color: var(--co-primary); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.72rem; font-family: var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.form-input {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 13px;
  color: var(--text); font-size: 0.85rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus { border-color: var(--co-primary); box-shadow: 0 0 0 3px rgba(var(--co-primary-rgb),.08); }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* Progress */
.progress-bar { height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg,var(--co-primary),var(--co-primary-dk)); transition: width 0.6s var(--ease); }

/* List items */
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--co-primary);
  font-family: var(--font-main); flex-shrink: 0;
}
.list-name { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.list-sub  { font-size: 0.7rem; color: var(--text-3); margin-top: 1px; }
.list-end  { margin-left: auto; text-align: right; }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding-bottom: 16px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; position: relative; z-index: 1; }
.tl-item::before { content:''; position:absolute; left:4px; top:15px; bottom:0; width:1px; background:var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot.done    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.tl-dot.active  { background: var(--co-primary); box-shadow: 0 0 6px var(--co-primary); }
.tl-dot.pending { background: var(--border-2); }
.tl-content { flex: 1; }
.tl-label { font-size: 0.8rem; font-weight: 500; color: var(--text); }
.tl-meta  { font-size: 0.7rem; color: var(--text-3); margin-top: 2px; font-family: var(--font-mono); }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 0.82rem; line-height: 1.5; }
.bubble.bot { background: var(--bg); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 2px; color: var(--text); }
.bubble.user { background: rgba(var(--co-primary-rgb),.08); border: 1px solid rgba(var(--co-primary-rgb),.18); align-self: flex-end; border-bottom-right-radius: 2px; color: var(--text); }
.bubble-time { font-size: 0.62rem; color: var(--text-3); margin-top: 4px; font-family: var(--font-mono); }

/* Mini bars */
.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.mini-bar { width: 5px; background: var(--co-primary); border-radius: 1px 1px 0 0; opacity: 0.4; transition: opacity 0.2s; }
.mini-bar:hover { opacity: 1; }

/* Chart SVG */
.chart-svg { width: 100%; height: 160px; }

/* Responsive */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .app { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px; }
}
