/* Variables globales de diseño (theme tokens). */
:root {
  --color-primary: #163a5f;
  --color-primary-dark: #0f2740;
  --color-surface: #ffffff;
  --color-background: #f5f7fa;
  --color-border: #d7dee7;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-success-bg: #d4edda;
  --color-success-text: #155724;
  --color-info-bg: #d1ecf1;
  --color-info-text: #0c5460;
  --color-danger-bg: #f8d7da;
  --color-danger-text: #721c24;
  --shadow-sm: 0 10px 30px rgba(15, 39, 64, 0.08);
  --shadow-md: 0 20px 45px rgba(15, 39, 64, 0.12);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 40px;
  --space-7: 48px;
  --max-content-width: 1200px;
  --font-base: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* Bases de estilo globales para todos los elementos */
* {
  box-sizing: border-box;
}

/* Tamaño de fuente base para unidades rem */
html {
  font-size: 16px;
}

/* Estilos globales del body y tipografía */
body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.5;
}

/* Links globales */
a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Tipografía de encabezados */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  margin-bottom: var(--space-3);
  color: var(--color-primary-dark);
  line-height: 1.2;
}

/* Párrafos */
p {
  margin-top: 0;
  margin-bottom: var(--space-3);
}

/* Listas desordenadas */
ul {
  margin-top: 0;
  margin-bottom: var(--space-4);
  padding-left: 20px;
}

/* Separador horizontal */
hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

/* Texto pequeño / menor importancia */
small {
  color: var(--color-text-muted);
}

/* Estilos para la vista pública (no autenticada) */
.app-public {
  background: var(--color-background);
}

/* Contenedores de página pública centrados */
.public-header,
.public-main,
.public-footer {
  width: min(100% - 48px, var(--max-content-width));
  margin: 0 auto;
}

/* Cabecera pública */
.public-header {
  padding: var(--space-5) 0 var(--space-3);
}

.public-header h1 {
  margin-bottom: var(--space-2);
  font-size: clamp(2rem, 4vw, 3.5rem);
  letter-spacing: 0.02em;
}

/* Navegación de la página pública */
.public-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* Área principal en modo público */
.public-main {
  padding-bottom: var(--space-6);
}

/* Pie de página público */
.public-footer {
  padding: var(--space-4) 0 var(--space-6);
  color: var(--color-text-muted);
}

/* Fondo base para usuario autenticado */
.app-authenticated {
  background: #eef2f7;
}

/* Estructura principal de la app autenticada con sidebar */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

/* Estilos del sidebar */
.app-sidebar {
  background: linear-gradient(180deg, #122a43 0%, #163a5f 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
}

.app-sidebar-brand {
  margin-bottom: var(--space-6);
}

.app-brand-link {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  color: #ffffff;
  text-decoration: none;
}

.app-brand-link:hover {
  text-decoration: none;
}

.app-brand-mark,
.app-brand-text {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.app-sidebar-nav {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
}

.app-sidebar-link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Área de pie del sidebar (link de cerrar sesión) */
.app-sidebar-footer {
  display: grid;
  margin-top: auto;
  padding-top: var(--space-5);
}

/* Contenedor principal de área de contenido (lado derecho) */
.app-main-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Barra superior visible en modo autenticado */
.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 28px 40px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* Título de barra superior */
.app-topbar-title {
  margin: 0;
  font-size: 2rem;
}

/* Nombre del usuario en la barra superior */
.app-topbar-user {
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* Contenido principal dentro de la app autenticada */
.app-main {
  padding: 32px 40px 48px;
}

/* Pie de página dentro de app autenticada */
.app-footer {
  padding: 0 40px 24px;
  color: var(--color-text-muted);
}

/* Formularios: ancho completo para diseño responsivo */
form {
  width: 100%;
}

/* Etiquetas de campos */
label {
  display: inline-block;
  margin-bottom: var(--space-1);
  font-weight: 600;
  color: var(--color-primary-dark);
}

/* Hereda tipografía en inputs y botones para consistencia */
input,
select,
textarea,
button {
  font: inherit;
}

/* Estilos para campos de texto, selects y textarea */
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Altura y padding extra para textarea */
textarea {
  min-height: 120px;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  resize: vertical;
}

/* Estados de focus para campos para mostrar énfasis visual */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22, 58, 95, 0.12);
}

/* Botones primarios y variantes .button */
button,
.button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

/* Estado hover de botones */
button:hover,
.button:hover,
a.button:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
}

/* Estado active de botones */
button:active,
.button:active,
a.button:active {
  transform: translateY(1px);
}

/* Estilos de tabla base */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Celdas de tabla */
th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

/* Encabezados de tabla */
th {
  background: #eef3f8;
  color: var(--color-primary-dark);
  font-weight: 700;
}

/* Elimina línea inferior en la última fila */
tr:last-child td {
  border-bottom: 0;
}

/* Tarjetas de contenido */
.card {
  background: var(--color-surface);
  border: 1px solid rgba(215, 222, 231, 0.8);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

/* Mensajes de feedback (crear, editar, error) */
.feedback-message {
  padding: 12px 14px;
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

/* Variantes de mensaje de feedback */
.feedback-message.success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: rgba(21, 87, 36, 0.18);
}

.feedback-message.info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border-color: rgba(12, 84, 96, 0.18);
}

.feedback-message.danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-color: rgba(114, 28, 36, 0.18);
}

/* Texto atenuado */
.text-muted {
  color: var(--color-text-muted);
}

/* Separadores entre secciones de contenido */
.page-section {
  margin-bottom: var(--space-5);
}

/* Contenedor base con ancho completo */
.container {
  width: 100%;
}

/* Botones primarios con apariencia consistente */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-primary-dark);
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #f8fafc;
  text-decoration: none;
}

.table {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-yellow {
  background: #fef3c7;
  color: #b45309;
}

.dashboard-shell {
  display: grid;
  gap: var(--space-5);
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.dashboard-header h2 {
  margin-bottom: var(--space-2);
}

.dashboard-welcome {
  margin-bottom: 0;
  color: var(--color-text-muted);
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.metric-label {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.metric-value {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  color: var(--color-primary-dark);
  line-height: 1;
}

.metric-note {
  margin: 0;
  color: var(--color-text-muted);
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.dashboard-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.module-link {
  display: block;
  color: inherit;
}

.module-link:hover {
  text-decoration: none;
}

.module-card {
  height: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(22, 58, 95, 0.24);
}

.module-card h3 {
  margin-bottom: var(--space-2);
}

.module-card p {
  margin-bottom: 0;
}

.dashboard-table-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.form-card {
  max-width: 640px;
}

.form-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 0.9fr);
  gap: var(--space-5);
  align-items: stretch;
}

.auth-panel {
  background: linear-gradient(145deg, var(--color-primary-dark), var(--color-primary));
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow-md);
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-panel h2,
.auth-panel h3,
.auth-panel p,
.auth-panel li {
  color: #ffffff;
}

.auth-eyebrow {
  display: inline-block;
  margin-bottom: var(--space-3);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.auth-title {
  margin-bottom: var(--space-4);
  font-size: clamp(2rem, 4vw, 3.75rem);
}

.auth-lead {
  max-width: 34rem;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.88);
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: var(--space-5) 0 0;
  display: grid;
  gap: var(--space-3);
}

.auth-feature-list li {
  padding-left: 22px;
  position: relative;
  color: rgba(255, 255, 255, 0.92);
}

.auth-feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

.auth-card {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-card h2 {
  margin-bottom: var(--space-2);
}

.auth-card .text-muted {
  margin-bottom: var(--space-4);
}

.form-field {
  margin-bottom: var(--space-4);
}

.form-actions {
  margin-top: var(--space-4);
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
}

.checkbox-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.checkbox-inline label {
  margin: 0;
  font-weight: 500;
  color: var(--color-text);
}

.form-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

@media (max-width: 768px) {
  .public-header,
  .public-main,
  .public-footer {
    width: min(100% - 32px, var(--max-content-width));
  }

  .public-header {
    padding-top: var(--space-4);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    padding: 20px 16px;
    gap: var(--space-4);
  }

  .app-topbar,
  .app-main,
  .app-footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .card {
    padding: var(--space-4);
  }

  th,
  td {
    padding: 12px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-modules {
    grid-template-columns: 1fr;
  }

  .auth-panel,
  .auth-card {
    min-height: auto;
  }

  .auth-panel {
    padding: var(--space-5);
  }
}
