/* ==========================================================================
   HIDROVEN · Sistema de Constancias de Trabajo
   Hoja de estilos institucional
   ========================================================================== */

:root {
  /* Azules institucionales (agua) */
  --azul-900: #02233f;
  --azul-800: #03396c;
  --azul-700: #044e86;
  --azul-600: #005b96;
  --azul-500: #0b74b8;
  --azul-300: #8fbcd9;
  --azul-200: #c4dced;
  --azul-100: #e3eef7;
  --azul-050: #f2f8fc;

  /* Acentos */
  --verde-700: #096b4f;
  --verde-600: #0b7a5a;
  --verde-100: #e2f4ee;

  --dorado-700: #8a6a1f;
  --dorado-500: #c8a24a;
  --dorado-100: #faf3df;

  --rojo-700: #7a271a;
  --rojo-600: #b42318;
  --rojo-100: #fef3f2;
  --rojo-200: #f6d2cd;

  /* Neutros */
  --gris-900: #16202c;
  --gris-800: #243342;
  --gris-700: #3f4d5c;
  --gris-600: #52606d;
  --gris-500: #6b7a8a;
  --gris-400: #94a3b3;
  --gris-300: #c7d2dd;
  --gris-200: #dde5ee;
  --gris-100: #eef3f8;
  --blanco: #ffffff;

  --fondo: #eef3f8;
  --superficie: var(--blanco);
  --borde: var(--gris-200);
  --texto: var(--gris-900);
  --texto-suave: var(--gris-600);

  --radio-sm: 6px;
  --radio: 10px;
  --radio-lg: 14px;

  --sombra-1: 0 1px 2px rgba(3, 57, 108, 0.06);
  --sombra-2: 0 10px 30px -12px rgba(3, 57, 108, 0.22);
  --sombra-3: 0 22px 50px -20px rgba(3, 57, 108, 0.35);

  --fuente: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --transicion: 160ms ease;
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--fuente);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background-color: var(--fondo);
  background-image:
    radial-gradient(900px 520px at 8% -12%, rgba(0, 91, 150, 0.10), transparent 62%),
    radial-gradient(720px 420px at 102% -4%, rgba(200, 162, 74, 0.12), transparent 58%);
  background-attachment: fixed;
}

img,
svg {
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--azul-600);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--azul-050);
  border: 1px solid var(--azul-100);
  color: var(--azul-800);
  padding: 1px 5px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--azul-200);
}

:focus-visible {
  outline: 2px solid var(--azul-500);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: var(--radio-sm);
  background: var(--azul-800);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transicion);
}

.skip-link:focus {
  top: 10px;
}

/* ---------- Barra institucional ---------- */
.govbar {
  flex: none;
  background: var(--azul-800);
  color: #d8e8f4;
  font-size: 12px;
}

.govbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  height: 36px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.govbar-brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.govbar-sep {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.28);
}

.govbar-sub {
  color: #b9d5ea;
}

.govbar-spacer {
  flex: 1;
}

.govbar-system {
  color: #b9d5ea;
  font-weight: 500;
}

/* ---------- Estructura ---------- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- Login ---------- */
.login-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px 30px;
}

.login-card {
  width: 100%;
  max-width: 470px;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-top: 4px solid var(--dorado-500);
  border-radius: var(--radio-lg);
  padding: 34px 34px 28px;
  box-shadow: var(--sombra-3);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--gris-100);
}

.login-logo {
  width: 56px;
  height: 56px;
  flex: none;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.login-org {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--azul-800);
}

.login-org-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--gris-500);
}

.login-heading {
  margin: 24px 0 22px;
}

.login-heading h1 {
  font-size: 26px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--azul-900);
}

.login-heading p {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--gris-600);
}

.login-footer {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--gris-500);
  text-align: center;
}

/* ---------- Formularios ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label,
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gris-700);
}

.label-optional {
  font-weight: 500;
  color: var(--gris-400);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--gris-300);
  border-radius: 8px;
  background: var(--blanco);
  color: var(--gris-900);
  font-size: 14.5px;
  transition: border-color var(--transicion), box-shadow var(--transicion), background var(--transicion);
}

.input::placeholder {
  color: var(--gris-400);
}

.input:hover {
  border-color: var(--gris-400);
}

.input:focus {
  outline: none;
  border-color: var(--azul-600);
  box-shadow: 0 0 0 3px rgba(0, 91, 150, 0.14);
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  cursor: pointer;
  padding-right: 34px;
}

.file-field {
  position: relative;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px dashed var(--gris-300);
  border-radius: 8px;
  background: var(--azul-050);
  color: var(--azul-800);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transicion), background var(--transicion);
}

.file-label:hover {
  border-color: var(--azul-500);
  background: var(--azul-100);
}

.file-field:focus-within .file-label {
  outline: 2px solid var(--azul-500);
  outline-offset: 2px;
}

.file-label .icon {
  color: var(--azul-600);
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  font-size: 12px;
  color: var(--gris-500);
  line-height: 1.45;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.form-actions .hint {
  margin: 0;
  max-width: 52ch;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transicion), border-color var(--transicion), color var(--transicion), box-shadow var(--transicion);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--azul-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(3, 57, 108, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: var(--azul-700);
}

.btn-primary:active:not(:disabled) {
  background: var(--azul-800);
}

.btn-secondary {
  background: var(--blanco);
  color: var(--azul-800);
  border-color: var(--gris-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--azul-050);
  border-color: var(--azul-300);
}

.btn-ghost {
  background: transparent;
  color: var(--gris-600);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gris-100);
  color: var(--gris-900);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}

/* ---------- Turnstile ---------- */
.turnstile-box {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--azul-100);
  border-radius: var(--radio);
  background: var(--azul-050);
}

.turnstile-label {
  margin-bottom: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gris-500);
  text-align: center;
}

.cf-turnstile {
  display: flex;
  justify-content: center;
}

/* ---------- Alertas ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.alert-dot {
  width: 8px;
  height: 8px;
  flex: none;
  margin-top: 6px;
  border-radius: 50%;
  background: currentColor;
}

.alert-error {
  background: var(--rojo-100);
  border-color: var(--rojo-200);
  color: var(--rojo-700);
}

.alert-success {
  background: var(--verde-100);
  border-color: #bfe3d6;
  color: var(--verde-700);
}

.alert-warning {
  background: var(--dorado-100);
  border-color: #ecdcb0;
  color: var(--dorado-700);
}

.alert-info {
  background: var(--azul-050);
  border-color: var(--azul-100);
  color: var(--azul-800);
}

/* ---------- Badges / estados ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-blue {
  background: var(--azul-100);
  color: var(--azul-800);
}

.badge-success {
  background: var(--verde-100);
  color: var(--verde-700);
}

.badge-neutral {
  background: var(--gris-100);
  color: var(--gris-600);
}

.badge-gold {
  background: var(--dorado-100);
  color: var(--dorado-700);
}

.badge-rrhh {
  background: var(--verde-100);
  color: var(--verde-700);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.status-ok {
  background: var(--verde-100);
  color: var(--verde-700);
}

.status-warning {
  background: var(--dorado-100);
  color: var(--dorado-700);
}

.status-pending {
  background: var(--gris-100);
  color: var(--gris-600);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--borde);
  backdrop-filter: blur(6px);
}

.topbar-inner {
  max-width: 1240px;
  min-height: 68px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--azul-800);
}

.brand-text small {
  margin-top: 2px;
  font-size: 11px;
  color: var(--gris-500);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid var(--borde);
}

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--azul-100);
  color: var(--azul-800);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.user-meta strong {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--gris-900);
}

.user-meta small {
  margin-top: 2px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--gris-500);
}

/* ---------- Página ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 28px 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dorado-700);
}

.page-title {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--azul-900);
}

.page-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--gris-600);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-top: 24px;
  border-bottom: 1px solid var(--borde);
}

.tab {
  position: relative;
  padding: 10px 16px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gris-600);
  transition: background var(--transicion), color var(--transicion);
}

.tab:hover {
  background: var(--azul-050);
  color: var(--azul-700);
}

.tab.is-active {
  color: var(--azul-700);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--azul-600);
}

/* ---------- Paneles / tarjetas ---------- */
.panel {
  margin-top: 24px;
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra-1);
  padding: 24px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.card-head-stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--azul-900);
}

.card-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--gris-500);
}

/* ---------- Ficha institucional ---------- */
.ficha-section {
  margin-top: 22px;
}

.ficha-section:first-child {
  margin-top: 0;
}

.ficha-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--azul-700);
}

.ficha-section h3::before {
  content: "";
  width: 3px;
  height: 13px;
  flex: none;
  border-radius: 2px;
  background: var(--dorado-500);
}

.ficha-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 44px;
}

.ficha-item {
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--gris-100);
}

.ficha-item-wide {
  grid-column: 1 / -1;
}

.ficha-item dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gris-500);
}

.ficha-item dd {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gris-900);
  overflow-wrap: anywhere;
}

/* ---------- Buscador admin ---------- */
.card-search {
  margin-bottom: 20px;
}

.card-search .card-head {
  margin-bottom: 14px;
}

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.search-row .field {
  flex: 1;
}

.search-row .btn {
  height: 44px;
  flex: none;
}

#search-feedback {
  margin-top: 14px;
}

/* ---------- Administración ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.admin-note {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--gris-500);
  text-align: center;
}

/* ---------- Estado vacío ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 34px 20px;
  border: 1px dashed var(--gris-300);
  border-radius: var(--radio);
  background: var(--azul-050);
  text-align: center;
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--azul-100);
  border-radius: 50%;
  background: var(--blanco);
  color: var(--azul-600);
}

.empty-state p {
  max-width: 46ch;
  font-size: 13.5px;
  color: var(--gris-600);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 390px;
  padding: 13px 16px;
  border: 1px solid var(--borde);
  border-left: 4px solid var(--azul-600);
  border-radius: var(--radio);
  background: var(--blanco);
  box-shadow: var(--sombra-3);
  font-size: 13.5px;
  color: var(--gris-800);
  animation: toast-in 180ms ease-out;
}

.toast-marker {
  width: 9px;
  height: 9px;
  flex: none;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--azul-600);
}

.toast-success {
  border-left-color: var(--verde-600);
}

.toast-success .toast-marker {
  background: var(--verde-600);
}

.toast-error {
  border-left-color: var(--rojo-600);
}

.toast-error .toast-marker {
  background: var(--rojo-600);
}

.toast-warning {
  border-left-color: var(--dorado-500);
}

.toast-warning .toast-marker {
  background: var(--dorado-500);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px 26px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--borde);
  font-size: 12px;
  color: var(--gris-500);
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .govbar-inner,
  .topbar-inner {
    padding: 0 20px;
  }

  .page {
    padding: 26px 20px 40px;
  }

  .page-title {
    font-size: 26px;
  }

  .ficha-grid {
    grid-template-columns: 1fr;
  }

  .ficha-item-wide {
    grid-column: auto;
  }

  .user-meta {
    display: none;
  }

  .topbar-user {
    gap: 10px;
  }

  .brand-text small {
    display: none;
  }
}

@media (max-width: 640px) {
  .govbar-sub,
  .govbar-system,
  .govbar-sep {
    display: none;
  }

  .govbar-inner {
    padding: 0 16px;
  }

  .login-view {
    padding: 28px 10px 24px;
  }

  .login-card {
    padding: 26px 18px 22px;
  }

  .login-heading h1 {
    font-size: 23px;
  }

  .page {
    padding: 22px 16px 32px;
  }

  .page-title {
    font-size: 23px;
  }

  .card {
    padding: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row .btn {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }

  #role-badge {
    display: none;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }

  .site-footer {
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
