/* =============================================================
   AYUNTAMIENTO DE ANTARES — dashboard.css
   Paleta: azul institucional + cyan accent
   Modos: dark (default) / light (toggle)
   Font: Inter (UI) + JetBrains Mono (SQL/code)
   ============================================================= */

/* ── MODO OSCURO (default) ──────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg-base:       #0D1B2A;
  --bg-surface:    #112236;
  --bg-elevated:   #163049;
  --bg-hover:      #1C3A58;
  --border:        #1E3A55;
  --border-subtle: #163049;

  --cyan:          #00B4D8;
  --cyan-dim:      rgba(0,180,216,.12);
  --cyan-hover:    #00CFF7;
  --navy:          #1A3A6B;
  --blue:          #4A90D9;
  --blue-dim:      rgba(74,144,217,.12);
  --green:         #2DC653;
  --green-dim:     rgba(45,198,83,.12);
  --orange:        #F4A261;
  --orange-dim:    rgba(244,162,97,.12);
  --red:           #E63946;
  --red-dim:       rgba(230,57,70,.12);
  --yellow:        #FFB703;
  --yellow-dim:    rgba(255,183,3,.12);

  /* alias accent = cyan para compatibilidad con componentes */
  --accent:        #00B4D8;
  --accent-dim:    rgba(0,180,216,.12);
  --accent-hover:  #00CFF7;

  --text-primary:  #E8EEF4;
  --text-secondary:#7A90A8;
  --text-muted:    #4A6072;

  --sidebar-w:     250px;
  --topbar-h:      56px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,.5);
  --transition:    .18s cubic-bezier(.4,0,.2,1);
}

/* ── MODO CLARO ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:       #F4F7FB;
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #EDF2F7;
  --bg-hover:      #E2EAF4;
  --border:        #C8D8E8;
  --border-subtle: #E2EAF4;

  --cyan:          #0096B4;
  --cyan-dim:      rgba(0,150,180,.10);
  --cyan-hover:    #007A96;
  --navy:          #1A3A6B;
  --blue:          #2B6CB0;
  --blue-dim:      rgba(43,108,176,.10);
  --green:         #22A64A;
  --green-dim:     rgba(34,166,74,.10);
  --orange:        #D47A2A;
  --orange-dim:    rgba(212,122,42,.10);
  --red:           #C62828;
  --red-dim:       rgba(198,40,40,.10);
  --yellow:        #C87F00;
  --yellow-dim:    rgba(200,127,0,.10);

  --accent:        #0096B4;
  --accent-dim:    rgba(0,150,180,.10);
  --accent-hover:  #007A96;

  --text-primary:  #1A2B3C;
  --text-secondary:#4A6072;
  --text-muted:    #8A9BAC;

  --shadow:        0 2px 12px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .badge-ai,
.sidebar.collapsed .user-info div { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-brand { padding: 16px 12px; justify-content: center; }
.sidebar.collapsed .brand-icon { margin: 0; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  flex-shrink: 0;
}
.brand-name { display: block; font-weight: 700; font-size: 13px; color: var(--text-primary); }
.brand-sub  { display: block; font-size: 9px; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  transition: background var(--transition), color var(--transition);
  position: relative;
  margin-bottom: 2px;
}
.nav-item i { font-size: 15px; flex-shrink: 0; width: 18px; text-align: center; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.badge-ai {
  margin-left: auto;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: .05em;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.user-info {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary); font-size: 13px;
  min-width: 0;
}
.btn-logout {
  color: var(--text-muted);
  font-size: 18px;
  text-decoration: none;
  flex-shrink: 0;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--red); }

/* ── MAIN WRAPPER ───────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.main-wrapper.sidebar-collapsed { margin-left: 64px; }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--accent); }
.topbar-breadcrumb { flex: 1; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-date { font-size: 12px; }

/* Toggle tema */
.btn-theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
}
.btn-theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── CONTENT ────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  width: 100%;
}

/* ── PAGE HEADER ────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-header p { color: var(--text-secondary); font-size: 13px; }

/* ── KPI CARDS ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.kpi-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, var(--accent-dim));
  pointer-events: none;
}
.kpi-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  margin-bottom: 12px;
}
.kpi-icon.cyan   { background: var(--cyan-dim);   color: var(--cyan);   }
.kpi-icon.blue   { background: var(--blue-dim);   color: var(--blue);   }
.kpi-icon.green  { background: var(--green-dim);  color: var(--green);  }
.kpi-icon.orange { background: var(--orange-dim); color: var(--orange); }
.kpi-icon.red    { background: var(--red-dim);    color: var(--red);    }
.kpi-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-top: 4px;
}

/* ── PANELS ─────────────────────────────────────────────────── */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.panel-title i { color: var(--accent); }
.panel-body { padding: 20px; }
.panel-body.p0 { padding: 0; }

/* ── CHARTS ─────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 240px; }
.chart-wrap canvas { max-height: 240px; }

/* ── TABLES ─────────────────────────────────────────────────── */
.qds-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.qds-table thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.qds-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.qds-table tbody tr:hover { background: var(--bg-hover); }
.qds-table tbody td { padding: 9px 14px; color: var(--text-primary); }
.qds-table tbody tr:last-child { border-bottom: none; }

/* ── BADGES MUNICIPALES ─────────────────────────────────────── */
.badge-ant {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
/* Estados expediente */
.badge-en_tramite, .badge-registrado    { background: var(--blue-dim);   color: var(--blue);   }
.badge-resuelto_favorable, .badge-cobrado, .badge-activo, .badge-justificada { background: var(--green-dim); color: var(--green); }
.badge-subsanacion, .badge-vencido, .badge-en_riesgo { background: var(--orange-dim); color: var(--orange); }
.badge-caducado, .badge-ejecutiva, .badge-resuelto_desfavorable, .badge-error { background: var(--red-dim); color: var(--red); }
.badge-suspendido, .badge-desistido, .badge-anulado { background: var(--bg-elevated); color: var(--text-muted); }
.badge-concedida, .badge-solicitada     { background: var(--cyan-dim);   color: var(--cyan);   }
.badge-identificada, .badge-en_preparacion { background: var(--yellow-dim); color: var(--yellow); }
/* Estados recibo */
.badge-emitido    { background: var(--blue-dim);   color: var(--blue);   }
.badge-aplazado   { background: var(--yellow-dim); color: var(--yellow); }
/* Tipos contrato */
.badge-funcionario       { background: var(--blue-dim);   color: var(--blue);  }
.badge-laboral_fijo      { background: var(--green-dim);  color: var(--green); }
.badge-interino, .badge-laboral_temporal { background: var(--yellow-dim); color: var(--yellow); }
.badge-eventual          { background: var(--orange-dim); color: var(--orange); }
/* Integraciones */
.badge-activo_int  { background: var(--green-dim);  color: var(--green);  }
.badge-mantenimiento { background: var(--yellow-dim); color: var(--yellow); }
.badge-pendiente_int { background: var(--blue-dim);   color: var(--blue);   }
.badge-desconectado  { background: var(--bg-elevated); color: var(--text-muted); }

/* ── PRIORIDADES ────────────────────────────────────────────── */
.text-urgente { color: var(--red) !important; }
.text-alta    { color: var(--orange) !important; }
.text-media   { color: var(--blue) !important; }
.text-baja    { color: var(--text-muted) !important; }

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress-bar-wrap {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  width: 100px;
  display: inline-block;
  vertical-align: middle;
}
.progress-bar-fill { height: 100%; border-radius: 3px; transition: width .4s; }

/* ── LOGIN ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 28px; text-align: center;
}
.login-logo .logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 18px; font-weight: 700; margin: 0; }
.login-logo p  { font-size: 11px; color: var(--text-muted); margin: 3px 0 0; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-dim) !important;
}
.form-label { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.form-control::placeholder { color: var(--text-muted); }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-accent {
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  color: #fff;
  border: none;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-size: 13.5px;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-accent:hover { opacity: .9; transform: translateY(-1px); }
.btn-outline-primary { border-color: var(--accent) !important; color: var(--accent) !important; }
.btn-outline-primary:hover { background: var(--accent-dim) !important; }
.btn-outline-danger { border-color: var(--red) !important; color: var(--red) !important; }
.btn-outline-danger:hover { background: var(--red-dim) !important; }
.btn-outline-success { border-color: var(--green) !important; color: var(--green) !important; }
.btn-outline-success:hover { background: var(--green-dim) !important; }

/* ── IA / TARES ─────────────────────────────────────────────── */
.ia-prompt-area {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.ia-textarea {
  width: 100%;
  min-height: 72px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
  transition: border-color var(--transition);
}
.ia-textarea:focus { outline: none; border-color: var(--accent); }
.sql-block {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: #7DD3E8;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.ia-interpretation {
  background: var(--cyan-dim);
  border: 1px solid rgba(0,180,216,.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.75;
  margin-bottom: 16px;
}
.ia-suggestion-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.ia-suggestion-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.ia-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── TARES CHAT BUBBLE ──────────────────────────────────────── */
.tares-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border-bottom: 1px solid var(--border);
}
.tares-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}

/* ── SPINNER ────────────────────────────────────────────────── */
.spinner-ant {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AUTOMATIZACIONES ───────────────────────────────────────── */
.auto-card { transition: border-color .2s, transform .2s; }
.auto-card:hover { border-color: rgba(0,180,216,.4); transform: translateY(-2px); }
.auto-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; margin-bottom: 16px;
}
.auto-title { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.auto-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.65; margin-bottom: 20px; min-height: 56px; }
.auto-btn {
  width: 100%; padding: 11px 0; border: none; border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--navy));
  color: #fff; font-weight: 700; font-size: 13.5px;
  cursor: pointer; transition: opacity .2s, transform .2s;
  display: flex; align-items: center; justify-content: center;
}
.auto-btn:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.auto-btn:disabled { opacity: .5; cursor: not-allowed; }
.auto-status { margin-top: 10px; min-height: 22px; font-size: 12px; text-align: center; font-weight: 600; }

/* ── INTEGRACIONES ──────────────────────────────────────────── */
.integracion-card {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.integracion-card:hover { background: var(--bg-hover); }
.integracion-card:last-child { border-bottom: none; }
.integracion-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.integracion-estado {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.integracion-estado.activo      { background: var(--green-dim); color: var(--green); }
.integracion-estado.error       { background: var(--red-dim);   color: var(--red);   }
.integracion-estado.mantenimiento { background: var(--yellow-dim); color: var(--yellow); }
.integracion-estado.pendiente   { background: var(--blue-dim);  color: var(--blue);  }
.integracion-estado.desconectado { background: var(--bg-elevated); color: var(--text-muted); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 16px; }
}
@media (max-width: 480px) { .kpi-grid { grid-template-columns: 1fr; } }

/* ── UTILS ──────────────────────────────────────────────────── */
.fw-500    { font-weight: 500; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.text-accent { color: var(--accent) !important; }
.text-cyan   { color: var(--cyan) !important; }
.text-dim    { color: var(--text-muted); }
.text-success { color: var(--green) !important; }
.text-orange  { color: var(--orange) !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px)  { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
