/* =====================================================================
   ABOGAINGE CRM — Estilos
   Identidad: violeta forense, sobrio, denso en información.
   ===================================================================== */

:root {
  /* Paleta ABOGAINGE */
  --violeta: #5B2A86;
  --violeta-700: #4A2270;
  --violeta-300: #9B59B6;
  --lavanda: #EDE3F5;
  --lavanda-50: #F7F2FB;

  /* Neutros */
  --tinta: #1F1B24;
  --gris-700: #4A4458;
  --gris-500: #7A7488;
  --gris-300: #C9C4D4;
  --gris-100: #ECE9F1;
  --gris-50: #F6F4F9;
  --blanco: #FFFFFF;

  /* Estados */
  --ok: #2E7D5B;
  --ok-bg: #E3F4EC;
  --alerta: #B7791F;
  --alerta-bg: #FBF1DD;
  --error: #C0392B;
  --error-bg: #FBE7E4;
  --info: #2E6C9B;
  --info-bg: #E4EFF8;

  /* Espaciado y formas */
  --radio: 8px;
  --radio-sm: 5px;
  --sombra: 0 1px 3px rgba(31, 27, 36, 0.08), 0 4px 12px rgba(31, 27, 36, 0.04);
  --sombra-lg: 0 8px 28px rgba(31, 27, 36, 0.12);
  --borde: 1px solid var(--gris-100);

  --fuente: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--fuente);
  color: var(--tinta);
  background: var(--gris-50);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--violeta); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Utilidades ---- */
.oculto { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap { gap: 16px; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--gris-500); }
.text-violeta { color: var(--violeta); }
.bold { font-weight: 600; }
.right { text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; }
.w-full { width: 100%; }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(155, 89, 182, 0.10), transparent),
    linear-gradient(160deg, var(--lavanda-50), var(--gris-50));
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra-lg);
  padding: 40px 36px;
  border-top: 4px solid var(--violeta);
}
.login-card .logo { text-align: center; margin-bottom: 8px; }
.login-card .logo img { height: 56px; }
.login-card h1 {
  font-size: 16px; font-weight: 600; text-align: center;
  color: var(--gris-700); margin-bottom: 28px; letter-spacing: 0.01em;
}
.login-card .sub { font-weight: 400; color: var(--gris-500); font-size: 13px; }

/* =====================================================================
   LAYOUT APP
   ===================================================================== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--violeta-700);
  color: var(--blanco);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .marca {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar .marca img { height: 38px; filter: brightness(0) invert(1); }
.sidebar .marca .tag { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 4px; letter-spacing: 0.04em; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav .grupo { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.45); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radio-sm);
  color: rgba(255,255,255,0.85); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background 0.12s;
}
.nav a:hover { background: rgba(255,255,255,0.10); text-decoration: none; }
.nav a.activo { background: var(--violeta-300); color: var(--blanco); }
.nav a .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }

.sidebar .usuario {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12.5px;
}
.sidebar .usuario .nombre { font-weight: 600; }
.sidebar .usuario .rol { color: rgba(255,255,255,0.6); font-size: 11px; }
.sidebar .usuario button {
  margin-top: 8px; width: 100%; background: rgba(255,255,255,0.12);
  color: var(--blanco); border: none; padding: 7px; border-radius: var(--radio-sm);
  cursor: pointer; font-size: 12.5px;
}
.sidebar .usuario button:hover { background: rgba(255,255,255,0.2); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--blanco); border-bottom: var(--borde);
  padding: 0 28px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar .crumb { font-size: 12px; color: var(--gris-500); }
.contenido { padding: 28px; flex: 1; max-width: 1280px; width: 100%; }

/* =====================================================================
   COMPONENTES
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--violeta); color: var(--blanco);
  border: none; padding: 9px 16px; border-radius: var(--radio-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background 0.12s;
}
.btn:hover { background: var(--violeta-700); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sec { background: var(--blanco); color: var(--violeta); border: 1px solid var(--gris-300); }
.btn.sec:hover { background: var(--gris-50); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { background: var(--error); }
.btn.danger:hover { background: #a93226; }

.card {
  background: var(--blanco); border-radius: var(--radio);
  box-shadow: var(--sombra); border: var(--borde);
}
.card .head {
  padding: 16px 20px; border-bottom: var(--borde);
  display: flex; align-items: center; justify-content: space-between;
}
.card .head h3 { font-size: 15px; font-weight: 600; }
.card .body { padding: 20px; }
.card .body.flush { padding: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi {
  background: var(--blanco); border-radius: var(--radio); border: var(--borde);
  box-shadow: var(--sombra); padding: 18px 20px; border-left: 3px solid var(--violeta-300);
}
.kpi .label { font-size: 12px; color: var(--gris-500); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .valor { font-size: 28px; font-weight: 700; color: var(--violeta-700); margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--gris-500); margin-top: 2px; }

/* Tablas */
.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th {
  text-align: left; padding: 11px 16px; background: var(--gris-50);
  color: var(--gris-700); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: var(--borde); white-space: nowrap;
}
.tabla td { padding: 12px 16px; border-bottom: var(--borde); }
.tabla tr:last-child td { border-bottom: none; }
.tabla tbody tr { cursor: default; transition: background 0.1s; }
.tabla tbody tr.clic { cursor: pointer; }
.tabla tbody tr.clic:hover { background: var(--lavanda-50); }
.tabla .vacio { text-align: center; color: var(--gris-500); padding: 40px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--gris-100); color: var(--gris-700);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.alerta { background: var(--alerta-bg); color: var(--alerta); }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.violeta { background: var(--lavanda); color: var(--violeta-700); }

/* Píldoras de tipo de servicio */
.pill-tipo { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 4px; }
.pill-RECURRENTE { background: #E4EFF8; color: #2E6C9B; }
.pill-PROYECTO { background: #E3F4EC; color: #2E7D5B; }
.pill-ASUNTO_LEGAL { background: #FBF1DD; color: #B7791F; }
.pill-AUDITORIA { background: #F0E7FB; color: #6B3FA0; }
.pill-PERICIAL { background: var(--lavanda); color: var(--violeta-700); }

/* Formularios */
.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: 13px; font-weight: 600; color: var(--gris-700); margin-bottom: 6px; }
.campo .hint { font-size: 12px; color: var(--gris-500); font-weight: 400; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gris-300);
  border-radius: var(--radio-sm); font-size: 14px; font-family: inherit;
  background: var(--blanco); color: var(--tinta); transition: border 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--violeta-300);
  box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.15);
}
textarea { resize: vertical; min-height: 80px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(31, 27, 36, 0.5);
  display: grid; place-items: center; z-index: 100; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--blanco); border-radius: var(--radio);
  box-shadow: var(--sombra-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
.modal.ancho { max-width: 760px; }
.modal .head { padding: 18px 22px; border-bottom: var(--borde); display: flex; justify-content: space-between; align-items: center; }
.modal .head h3 { font-size: 16px; font-weight: 600; }
.modal .head .x { cursor: pointer; color: var(--gris-500); font-size: 22px; line-height: 1; background: none; border: none; width: auto; }
.modal .body { padding: 22px; }
.modal .foot { padding: 16px 22px; border-top: var(--borde); display: flex; justify-content: flex-end; gap: 10px; }

/* Toast */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--tinta); color: var(--blanco); padding: 12px 18px;
  border-radius: var(--radio); box-shadow: var(--sombra-lg); font-size: 13.5px;
  min-width: 260px; animation: subir 0.2s ease;
}
.toast.ok { background: var(--ok); }
.toast.error { background: var(--error); }
@keyframes subir { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: var(--borde); margin-bottom: 20px; }
.tabs button {
  background: none; border: none; padding: 10px 16px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--gris-500);
  border-bottom: 2px solid transparent; width: auto;
}
.tabs button.activo { color: var(--violeta); border-bottom-color: var(--violeta); }

/* Barra de progreso */
.progress { background: var(--gris-100); border-radius: 20px; height: 8px; overflow: hidden; }
.progress > div { background: var(--violeta-300); height: 100%; transition: width 0.3s; }

/* Spinner */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%; animation: girar 0.7s linear infinite; display: inline-block;
}
.spinner.violeta { border-color: var(--lavanda); border-top-color: var(--violeta); }
@keyframes girar { to { transform: rotate(360deg); } }

.center-load { display: grid; place-items: center; padding: 60px; }

/* Línea de tiempo (audiencias/etapas) */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--gris-100); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--violeta-300); border: 2px solid var(--blanco);
}
.timeline li.done::before { background: var(--ok); }

/* Responsive */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; width: 240px; z-index: 50; transition: left 0.2s; }
  .sidebar.abierto { left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .contenido { padding: 18px; }
}
