@import url('/fonts/fira.css');

/* ============================================================
   FacelCR Central — tema del portal
   Estilo: Data-Dense Dashboard · Navy corporativo + verde acción
   ============================================================ */

:root {
  --fc-primary: #1E3A5F;
  --fc-primary-600: #24466f;
  --fc-primary-700: #17304e;
  --fc-primary-800: #122740;
  --fc-secondary: #2563EB;
  --fc-accent: #059669;
  --fc-accent-700: #047857;
  --fc-bg: #F8FAFC;
  --fc-surface: #FFFFFF;
  --fc-fg: #0F172A;
  --fc-muted: #64748B;
  --fc-muted-bg: #F1F5F9;
  --fc-border: #E4E7EB;
  --fc-border-strong: #CBD5E1;
  --fc-danger: #DC2626;
  --fc-warning: #B45309;
  --fc-radius: 10px;
  --fc-radius-sm: 7px;
  --fc-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --fc-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --fc-shadow-md: 0 4px 16px rgba(15, 23, 42, .10);

  /* Puente con variables de Bootstrap 5.3 */
  --bs-primary: var(--fc-primary);
  --bs-primary-rgb: 30, 58, 95;
  --bs-body-color: var(--fc-fg);
  --bs-body-bg: var(--fc-bg);
  --bs-border-color: var(--fc-border);
  --bs-link-color: var(--fc-secondary);
  --bs-link-color-rgb: 37, 99, 235;
  --bs-link-hover-color: #1d4ed8;
  --bs-font-sans-serif: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 15px; position: relative; min-height: 100%; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
  font-family: var(--bs-font-sans-serif);
  color: var(--fc-fg);
  background: var(--fc-bg);
  margin-bottom: 64px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Tipografía ---------- */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5 {
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--fc-fg);
}
h1, .h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.25rem; }
code, kbd, samp, pre, .mono, .font-mono {
  font-family: 'Fira Code', ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-variant-ligatures: none;
}
/* Cifras/columnas de datos alineadas */
.table td, .table th, .num, .mono { font-variant-numeric: tabular-nums; }
.fw-500 { font-weight: 500; }

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--fc-primary);
  box-shadow: var(--fc-shadow);
  padding-top: .4rem;
  padding-bottom: .4rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-navbar .navbar-brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}
.app-navbar .navbar-brand .brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563EB, #059669);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
}
.app-navbar .nav-link {
  color: rgba(255, 255, 255, .78) !important;
  font-weight: 500;
  border-radius: var(--fc-radius-sm);
  padding: .4rem .7rem !important;
  transition: color .15s ease, background-color .15s ease;
}
.app-navbar .nav-link:hover { color: #fff !important; background: rgba(255, 255, 255, .10); }
.app-navbar .nav-link.active { color: #fff !important; background: rgba(255, 255, 255, .16); }
.app-navbar .navbar-text, .app-navbar .user-chip { color: rgba(255, 255, 255, .65); }
.app-navbar .user-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .85rem;
  padding: .25rem .6rem;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
}
.app-navbar .user-chip .role {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: #fff; background: rgba(255, 255, 255, .16);
  padding: .05rem .4rem; border-radius: 999px;
}
.app-navbar .navbar-toggler { border-color: rgba(255,255,255,.3); }
.app-navbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ---------- Encabezado de página ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin: .5rem 0 1.25rem;
}
.page-head .page-title { margin: 0; }
.page-head .page-sub { color: var(--fc-muted); font-size: .9rem; margin: .15rem 0 0; }

/* ---------- Panel / tarjeta ---------- */
.panel {
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  box-shadow: var(--fc-shadow-sm);
}
.panel + .panel { margin-top: 1.25rem; }
.panel-head {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--fc-border);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.panel-body { padding: 1.1rem; }
.panel-body.p-0 { padding: 0; }
.toolbar { padding: .85rem 1.1rem; border-bottom: 1px solid var(--fc-border); background: #fcfdfe; }

/* ---------- Tablas ---------- */
.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  color: var(--fc-fg);
  border-color: var(--fc-border);
}
.table > thead th {
  background: var(--fc-muted-bg);
  color: var(--fc-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .045em;
  border-bottom: 1px solid var(--fc-border);
  padding: .6rem .9rem;
  white-space: nowrap;
}
.table > tbody td { padding: .62rem .9rem; vertical-align: middle; border-color: #eef1f4; }
.table.table-striped > tbody > tr:nth-of-type(odd) > td { background: #fbfcfe; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover > td { background: #eff5ff; }
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--fc-radius) var(--fc-radius); }

/* ---------- Paginación ---------- */
.pager { padding: .85rem 1.1rem; border-top: 1px solid var(--fc-border); display: flex; justify-content: flex-end; }

/* ---------- Botones ---------- */
.btn { font-weight: 500; border-radius: var(--fc-radius-sm); transition: all .15s ease; }
.btn:focus-visible { box-shadow: 0 0 0 .2rem rgba(30, 58, 95, .28); }

.btn-primary {
  --bs-btn-bg: var(--fc-primary); --bs-btn-border-color: var(--fc-primary);
  --bs-btn-hover-bg: var(--fc-primary-700); --bs-btn-hover-border-color: var(--fc-primary-700);
  --bs-btn-active-bg: var(--fc-primary-800); --bs-btn-active-border-color: var(--fc-primary-800);
  --bs-btn-disabled-bg: var(--fc-primary); --bs-btn-disabled-border-color: var(--fc-primary);
}
.btn-success {
  --bs-btn-bg: var(--fc-accent); --bs-btn-border-color: var(--fc-accent);
  --bs-btn-hover-bg: var(--fc-accent-700); --bs-btn-hover-border-color: var(--fc-accent-700);
  --bs-btn-active-bg: var(--fc-accent-700); --bs-btn-active-border-color: var(--fc-accent-700);
}
.btn-outline-secondary {
  --bs-btn-color: var(--fc-fg); --bs-btn-border-color: var(--fc-border-strong);
  --bs-btn-hover-bg: var(--fc-muted-bg); --bs-btn-hover-border-color: var(--fc-border-strong);
  --bs-btn-hover-color: var(--fc-fg);
}
.btn-link { text-decoration: none; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* Botón "Ver" en filas */
.row-action {
  display: inline-flex; align-items: center; gap: .3rem;
  font-weight: 500; color: var(--fc-secondary); text-decoration: none;
  padding: .2rem .55rem; border-radius: 999px;
}
.row-action:hover { background: #e6efff; color: #1d4ed8; }
.row-action svg { width: 14px; height: 14px; }

/* ---------- Formularios ---------- */
.form-label { font-weight: 500; font-size: .85rem; color: #334155; margin-bottom: .3rem; }
.form-control, .form-select {
  border-color: var(--fc-border-strong);
  border-radius: var(--fc-radius-sm);
  color: var(--fc-fg);
}
.form-control:focus, .form-select:focus {
  border-color: var(--fc-primary);
  box-shadow: 0 0 0 .18rem rgba(30, 58, 95, .16);
}
.form-control::placeholder { color: #94a3b8; }

.input-icon { position: relative; }
.input-icon svg {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: #94a3b8; pointer-events: none;
}
.input-icon .form-control { padding-left: 2.1rem; }

/* ---------- Badges de estado ---------- */
.badge-estado {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: .22rem .55rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-estado::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-estado.aceptado  { color: var(--fc-accent-700); background: #ecfdf5; border-color: #a7f3d0; }
.badge-estado.aprobado  { color: var(--fc-secondary);   background: #eef4ff; border-color: #bfdbfe; }
.badge-estado.aprobado::before { content: none; }
.badge-estado.rechazado { color: var(--fc-danger);     background: #fef2f2; border-color: #fecaca; }
.badge-estado.pendiente { color: var(--fc-warning);    background: #fffbeb; border-color: #fde68a; }
.badge-estado.neutro    { color: var(--fc-muted);      background: var(--fc-muted-bg); border-color: var(--fc-border); }

.badge-bool { font-size: .72rem; font-weight: 600; padding: .2rem .5rem; border-radius: 999px; }
.badge-bool.si { color: var(--fc-accent-700); background: #ecfdf5; }
.badge-bool.no { color: var(--fc-muted); background: var(--fc-muted-bg); }

/* ---------- Detalle (definiciones) ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; }
.detail-grid > dt {
  padding: .6rem 1.1rem; font-weight: 500; color: var(--fc-muted);
  border-bottom: 1px solid var(--fc-border); font-size: .88rem;
}
.detail-grid > dd {
  padding: .6rem 1.1rem; margin: 0; border-bottom: 1px solid var(--fc-border);
}
.detail-grid > dd:last-of-type, .detail-grid > dt:last-of-type { border-bottom: 0; }
@media (max-width: 575.98px) { .detail-grid { grid-template-columns: 1fr; } .detail-grid > dt { border-bottom: 0; padding-bottom: 0; } }

pre.code-block {
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--fc-radius-sm); padding: .9rem 1rem;
  font-size: .82rem; line-height: 1.55; overflow-x: auto; margin: 0;
}

/* ---------- Estado vacío ---------- */
.empty-state { text-align: center; color: var(--fc-muted); padding: 2.5rem 1rem; }
.empty-state svg { width: 40px; height: 40px; opacity: .5; margin-bottom: .6rem; }

/* Oculta el resumen de validación cuando no hay errores */
.validation-summary-valid { display: none; }

/* ---------- Catálogos: edición por fila ---------- */
/* Por defecto la fila está en solo lectura: se ocultan los controles de edición. */
tr[data-row] .only-edit { display: none; }
tr[data-row].editando .only-view { display: none; }
tr[data-row].editando .only-edit { display: inline-block; }
tr[data-row].editando { background: #f0f7ff !important; }
tr[data-row].editando > td { background: #f0f7ff !important; }

/* ---------- Hub de inicio ---------- */
.hub-card { color: var(--fc-fg); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.hub-card:hover { transform: translateY(-2px); box-shadow: var(--fc-shadow-md); border-color: var(--fc-border-strong); color: var(--fc-fg); }
.hub-icon {
  width: 42px; height: 42px; border-radius: 11px; margin-bottom: .75rem;
  display: flex; align-items: center; justify-content: center;
  background: #eef4ff; color: var(--fc-primary);
}
.hub-icon svg { width: 22px; height: 22px; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 180px); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; }
.login-brand {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto .9rem;
  background: linear-gradient(135deg, var(--fc-primary), #2563EB);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.25rem; box-shadow: var(--fc-shadow-md);
}

/* ---------- Footer ---------- */
.footer {
  position: absolute; bottom: 0; width: 100%; height: 44px; line-height: 44px;
  background: var(--fc-surface); border-top: 1px solid var(--fc-border);
  color: var(--fc-muted); font-size: .82rem;
}

/* ---------- Accesibilidad ---------- */
a:focus-visible, .btn:focus-visible, .form-control:focus-visible, .row-action:focus-visible {
  outline: 2px solid var(--fc-secondary); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
