/*
 * Intranet360 — Sistema visual (estilo Apple / Google, blanco y limpio)
 * Capa de tema sobre Bootstrap 5.3 usando CSS custom properties + componentes propios.
 * Tokens de diseño derivados de la skill ui-ux-pro-max (dashboard minimal, WCAG AA).
 */

:root {
  /* ---- Tipografía nativa (look Apple/Google, sin fuentes externas) ---- */
  --a360-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* ---- Paleta ---- */
  --a360-blue: #0071e3;        /* azul acción (Apple system blue) */
  --a360-blue-hover: #0077ed;
  --a360-blue-soft: #e8f1fd;
  --a360-ink: #1d1d1f;         /* casi negro (texto principal) */
  --a360-ink-2: #6e6e73;       /* texto secundario */
  --a360-ink-3: #86868b;       /* texto terciario / hints */
  --a360-canvas: #f5f5f7;      /* fondo de la app */
  --a360-surface: #ffffff;     /* tarjetas / superficies */
  --a360-border: #e5e5ea;      /* bordes suaves */
  --a360-border-strong: #d2d2d7;

  /* ---- Radios y sombras ---- */
  --a360-radius: 14px;
  --a360-radius-sm: 10px;
  --a360-shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .05);
  --a360-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --a360-sidebar-w: 248px;

  /* ---- Overrides de tokens Bootstrap ---- */
  --bs-body-font-family: var(--a360-font);
  --bs-body-color: var(--a360-ink);
  --bs-body-bg: var(--a360-canvas);
  --bs-primary: var(--a360-blue);
  --bs-primary-rgb: 0, 113, 227;
  --bs-border-color: var(--a360-border);
  --bs-border-radius: var(--a360-radius-sm);
  --bs-link-color: var(--a360-blue);
  --bs-link-hover-color: var(--a360-blue-hover);
}

body {
  font-family: var(--a360-font);
  color: var(--a360-ink);
  background: var(--a360-canvas);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ============================ App shell ============================ */
.app {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: var(--a360-sidebar-w);
  flex: 0 0 var(--a360-sidebar-w);
  background: var(--a360-surface);
  border-right: 1px solid var(--a360-border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--a360-ink);
  letter-spacing: -0.02em;
}

.sidebar__brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--a360-blue), #34c0ff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .82rem;
}

.sidebar__section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--a360-ink-3);
  font-weight: 600;
  padding: 16px 12px 6px;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--a360-ink-2);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}

.nav-item-link .bi { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item-link:hover { background: var(--a360-canvas); color: var(--a360-ink); }
.nav-item-link.active { background: var(--a360-blue-soft); color: var(--a360-blue); font-weight: 600; }

/* ============================ Contenido ============================ */
.content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--a360-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__title { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.page { padding: 28px; max-width: 1280px; width: 100%; }
.page__header { margin-bottom: 22px; }
.page__header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 4px; }
.page__header p { color: var(--a360-ink-2); margin: 0; font-size: .95rem; }

/* ============================ Tarjetas ============================ */
.card {
  background: var(--a360-surface);
  border: 1px solid var(--a360-border);
  border-radius: var(--a360-radius);
  box-shadow: var(--a360-shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--a360-border);
  padding: 16px 20px;
  font-weight: 600;
}
.card-body { padding: 20px; }

/* KPI tiles */
.kpi {
  background: var(--a360-surface);
  border: 1px solid var(--a360-border);
  border-radius: var(--a360-radius);
  padding: 18px 20px;
  box-shadow: var(--a360-shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
  height: 100%;
}
.kpi:hover { box-shadow: var(--a360-shadow); transform: translateY(-2px); }
.kpi__label { color: var(--a360-ink-2); font-size: .82rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi__label .bi { color: var(--a360-blue); font-size: 1rem; }
.kpi__value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi__meta { color: var(--a360-ink-3); font-size: .8rem; margin-top: 2px; }

/* ============================ Botones ============================ */
.btn { border-radius: 980px; font-weight: 500; padding: .5rem 1.1rem; transition: all .15s ease; }
.btn-primary { --bs-btn-bg: var(--a360-blue); --bs-btn-border-color: var(--a360-blue);
  --bs-btn-hover-bg: var(--a360-blue-hover); --bs-btn-hover-border-color: var(--a360-blue-hover);
  --bs-btn-active-bg: #0064c8; --bs-btn-disabled-bg: var(--a360-blue); }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--a360-border-strong); --bs-btn-hover-bg: var(--a360-canvas); }
.btn-sm { padding: .35rem .8rem; font-size: .82rem; }

/* ============================ Tablas ============================ */
.table { --bs-table-border-color: var(--a360-border); margin: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--a360-ink-3); font-weight: 600; border-bottom: 1px solid var(--a360-border);
  padding: 12px 16px;
}
.table tbody td { padding: 14px 16px; vertical-align: middle; border-color: var(--a360-border); }
.table tbody tr { transition: background-color .12s ease; }
.table-hover tbody tr:hover { background: var(--a360-canvas); }
.table-card { border: 1px solid var(--a360-border); border-radius: var(--a360-radius); overflow: hidden; background: #fff; box-shadow: var(--a360-shadow-sm); }

/* ============================ Badges de estatus ============================ */
.badge-status { font-weight: 600; font-size: .74rem; padding: .35em .7em; border-radius: 980px; letter-spacing: .01em; }
.st-gray   { background: #f0f0f2; color: #6e6e73; }
.st-blue   { background: var(--a360-blue-soft); color: var(--a360-blue); }
.st-green  { background: #e3f6ea; color: #1a8a4a; }
.st-amber  { background: #fdf0dc; color: #b5730f; }
.st-red    { background: #fde7e7; color: #c62828; }
.st-purple { background: #eee9fb; color: #6c3fd1; }

/* ============================ Formularios ============================ */
.form-label { font-weight: 500; font-size: .85rem; color: var(--a360-ink); margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: var(--a360-radius-sm); border-color: var(--a360-border-strong);
  padding: .55rem .8rem; font-size: .92rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--a360-blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, .15);
}
.form-text { color: var(--a360-ink-3); }

/* Zona de subida de fotos / documentos */
.dropzone {
  border: 1.5px dashed var(--a360-border-strong); border-radius: var(--a360-radius);
  padding: 26px; text-align: center; color: var(--a360-ink-2); background: #fafafc;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--a360-blue); background: var(--a360-blue-soft); }
.dropzone .bi { font-size: 1.6rem; color: var(--a360-blue); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--a360-radius-sm); border: 1px solid var(--a360-border); }

/* ============================ Utilidades ============================ */
.text-muted-2 { color: var(--a360-ink-2) !important; }
.text-muted-3 { color: var(--a360-ink-3) !important; }
.hstack-gap { display: flex; align-items: center; gap: 10px; }
.divider { height: 1px; background: var(--a360-border); border: 0; margin: 20px 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--a360-blue-soft); color: var(--a360-blue); display: grid; place-items: center; font-weight: 600; font-size: .82rem; }
a { text-decoration: none; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--a360-ink-2); }
.empty-state .bi { font-size: 2.4rem; color: var(--a360-border-strong); }

/* Flash / alertas */
.flash { position: fixed; top: 76px; right: 24px; z-index: 1080; max-width: 380px; }
.alert { border-radius: var(--a360-radius-sm); border: 1px solid var(--a360-border); box-shadow: var(--a360-shadow); }

/* Responsive: colapsa sidebar en pantallas chicas */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex-basis: auto;
    display: flex; gap: 4px; overflow-x: auto; padding: 10px; }
  .sidebar__brand, .sidebar__section { display: none; }
  .nav-item-link span { display: none; }
  .nav-item-link { padding: 10px 12px; }
  .page { padding: 18px; }
}

/* ============================ Refinamientos UI ============================ */
/* Secciones de KPIs en el panel */
.kpi-section { margin-bottom: 24px; }
.kpi-section__title { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--a360-ink-3); font-weight: 600; margin: 0 0 10px 2px; }

/* KPIs que son enlaces: sin subrayado, con feedback */
a.kpi { text-decoration: none; }
a.kpi:hover .kpi__value { color: var(--a360-blue); }

/* Foco accesible visible en toda la app */
a:focus-visible, button:focus-visible, .btn:focus-visible,
.form-control:focus-visible, .form-select:focus-visible, .nav-item-link:focus-visible {
  outline: 2px solid var(--a360-blue); outline-offset: 2px;
}
.btn:focus-visible { outline-offset: 3px; }

/* Botones: micro-interacción al presionar */
.btn:active { transform: translateY(0.5px); }

/* Scrollbar discreta en el menú lateral */
.sidebar { scrollbar-width: thin; scrollbar-color: var(--a360-border-strong) transparent; }
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--a360-border-strong); border-radius: 8px; border: 2px solid var(--a360-surface); }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* Encabezado de tabla que permanece visible al desplazar tablas altas */
.table thead th { position: sticky; top: 0; background: var(--a360-surface); z-index: 1; }
.table-responsive { border-radius: inherit; }

/* Buscador de tablas */
.table-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-search { position: relative; flex: 1 1 260px; max-width: 340px; }
.table-search .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--a360-ink-3); font-size: .95rem; }
.table-search input { padding-left: 34px; }
.table-search input.form-control { height: 40px; }
.row-hidden { display: none !important; }
.no-results { text-align: center; padding: 32px; color: var(--a360-ink-3); }

/* Fondo sutil de marca en la pantalla de acceso */
.auth-bg { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(1100px 520px at 15% -10%, rgba(0,113,227,.10), transparent 60%),
  radial-gradient(900px 500px at 100% 110%, rgba(52,192,255,.10), transparent 55%),
  var(--a360-canvas); }

/* Barra de acciones de formularios: fija al fondo en formularios largos */
.form-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 24px; padding: 14px 0 16px;
  background: linear-gradient(to top, var(--a360-canvas) 62%, transparent);
}

/* Formularios: un poco más de aire y encabezados de sección claros */
.card-header { font-size: .95rem; letter-spacing: -0.01em; }
form .card { margin-bottom: 16px; }
.form-select, .form-control { transition: border-color .12s ease, box-shadow .12s ease; }
.input-group-text { background: var(--a360-canvas); border-color: var(--a360-border-strong); color: var(--a360-ink-2); }

/* Páginas de detalle: pares etiqueta/valor consistentes */
.detail-item { margin-bottom: 4px; }
.detail-item__label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--a360-ink-3); font-weight: 600; }
.detail-item__value { font-weight: 500; }

/* Enlace de regreso en cabeceras de detalle */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--a360-ink-2); font-size: .88rem; }
.back-link:hover { color: var(--a360-blue); }

/* ============================ Constructor visual de flujos (estilo n8n) ============================ */
.flow-builder { max-width: 680px; margin: 0 auto; }
.flow-endpoint { display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .85rem; width: max-content; margin: 0 auto; }
.flow-endpoint--start { background: var(--a360-blue-soft); color: var(--a360-blue); }
.flow-endpoint--end { background: #e3f6ea; color: #1a8a4a; }
.flow-pipe { width: 2px; height: 22px; background: var(--a360-border-strong); margin: 0 auto; }
.flow-pipe--arrow { position: relative; }
.flow-pipe--arrow::after { content: ""; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--a360-border-strong); }
.flow-steps { display: flex; flex-direction: column; gap: 0; }
.flow-steps:empty { min-height: 8px; }
.flow-node { background: var(--a360-surface); border: 1px solid var(--a360-border); border-radius: 14px;
  box-shadow: var(--a360-shadow-sm); transition: box-shadow .15s ease, border-color .15s ease; }
.flow-node + .flow-node { margin-top: 0; }
.flow-node:hover { border-color: var(--a360-border-strong); }
.flow-node.dragging { opacity: .45; }
.flow-node__head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.flow-node__handle { cursor: grab; color: var(--a360-ink-3); font-size: 1.05rem; }
.flow-node__handle:active { cursor: grabbing; }
.flow-node__num { width: 26px; height: 26px; border-radius: 50%; background: var(--a360-blue); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: 0 0 auto; }
.flow-node__name { flex: 1 1 auto; min-width: 0; border: 1px solid transparent; font-weight: 600; font-size: .96rem;
  background: transparent; padding: 5px 8px; border-radius: 8px; color: var(--a360-ink); }
.flow-node__name:focus { background: var(--a360-canvas); border-color: var(--a360-border); outline: none; }
.flow-node__summary { padding: 0 14px 12px 50px; color: var(--a360-ink-2); font-size: .82rem; }
.flow-node__summary .bi { color: var(--a360-blue); }
.flow-node__config { padding: 12px 14px 16px 50px; border-top: 1px solid var(--a360-border); }
.flow-connector { display: flex; flex-direction: column; align-items: center; }
.flow-add { display: flex; justify-content: center; margin: 4px 0; }
.flow-add .btn { border-radius: 999px; border-style: dashed; }

/* ============================ Cadena de aprobación (timeline) ============================ */
.approval-chain { list-style: none; margin: 0; padding: 0; }
.approval-step { display: flex; align-items: flex-start; gap: 12px; padding: 0 0 16px; position: relative; }
.approval-step:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--a360-border); }
.approval-step__dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--a360-border-strong); background: #fff; flex: 0 0 auto; margin-top: 2px; z-index: 1; }
.approval-step__body { flex: 1 1 auto; min-width: 0; }
.approval-step--approved .approval-step__dot { background: #1a8a4a; border-color: #1a8a4a; }
.approval-step--rejected .approval-step__dot { background: #c62828; border-color: #c62828; }
.approval-step--skipped .approval-step__dot { background: var(--a360-border); }
.approval-step.is-current .approval-step__dot { border-color: var(--a360-blue); box-shadow: 0 0 0 3px rgba(0,113,227,.2); }

/* ============================ Notificaciones ============================ */
.notif-btn { position: relative; background: none; border: 0; color: var(--a360-ink-2); font-size: 1.25rem; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.notif-btn:hover { background: var(--a360-canvas); color: var(--a360-ink); }
.notif-badge { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: #c62828; color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center; }
.notif-menu { width: 340px; max-width: 92vw; max-height: 440px; overflow-y: auto; padding: 0; }
.notif-menu__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--a360-border); font-weight: 600; font-size: .9rem; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--a360-border); text-decoration: none; color: inherit; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--a360-canvas); }
.notif-item.unread { background: var(--a360-blue-soft); }
.notif-item .bi { color: var(--a360-blue); font-size: 1.05rem; margin-top: 2px; }
.notif-empty { padding: 28px 14px; text-align: center; color: var(--a360-ink-3); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .kpi:hover, .card:hover, .btn:active { transform: none !important; }
}
