/* ==========================================================================
   Sistema de Estilos y Paleta Relajante - Login & Dashboards
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Palette - Relaxing Slate & Soft Teal */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-light: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --primary-glow: rgba(13, 148, 136, 0.25);

  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --text-sub: #94a3b8;

  --border: #e2e8f0;
  --border-dark: #334155;

  --success-bg: #dcfce7;
  --success-text: #15803d;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;
  --info-bg: #e0f2fe;
  --info-text: #0369a1;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #f1f5f9;
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }

/* ==========================================================================
   VIEW 1: LOGIN SECTION
   ========================================================================== */

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0d9488 100%);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.5s ease-out;
  position: relative;
  z-index: 10;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  color: white;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-glow);
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  background: #f8fafc;
  color: var(--text-main);
  transition: var(--transition);
}

.form-control.no-icon {
  padding-left: 1rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.toggle-password {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
}

.btn-primary {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), #0f766e);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.demo-credentials {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
}

.demo-credentials h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-align: center;
}

.demo-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.demo-chip {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.demo-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.demo-chip strong {
  display: block;
  color: var(--text-main);
}

.demo-chip span {
  color: var(--text-muted);
}

/* Alert Boxes */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #fca5a5;
}

.alert-success {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #86efac;
}

.alert-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #fde047;
}

/* ==========================================================================
   VIEW 2 & 3: DASHBOARD LAYOUT
   ========================================================================== */

.dashboard-layout {
  display: flex;
  min-height: 100vh;
  background-color: #f8fafc;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-primary);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 20;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: white;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-menu {
  list-style: none;
  padding: 1.25rem 0.75rem;
  flex-grow: 1;
}

.sidebar-item {
  margin-bottom: 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-sub);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info {
  flex-grow: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--primary-light);
  text-transform: capitalize;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-logout:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.top-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.content-body {
  padding: 2rem;
  flex-grow: 1;
}

/* ==========================================================================
   CARDS & STATS WIDGETS
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* Línea separadora visual entre las cards persistentes y la sección activa */
.content-body > .stats-grid {
  padding-bottom: 1.25rem;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.35rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-info h5 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-info .stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success-text); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger-text); }
.stat-icon.info { background: var(--info-bg); color: var(--info-text); }

/* Data Tables & Cards */
.card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover { background: #f1f5f9; }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fecaca; }

.btn-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: #fde047;
}
.btn-warning:hover { background: #fef08a; }

.btn-icon {
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-main); background: var(--border); }

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #f8fafc;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease-out;
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   STAT CARDS CLICKEABLES (navegación)
   ========================================================================== */

.stat-card-link {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card-link::after {
  content: '\F282'; /* bi-arrow-right */
  font-family: "bootstrap-icons";
  position: absolute;
  bottom: 0.6rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: var(--primary);
  opacity: 0;
  transform: translateX(-4px);
  transition: var(--transition);
}

.stat-card-link:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--primary-light);
  border-color: var(--primary);
}

.stat-card-link:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.stat-card-link:active {
  transform: translateY(-1px);
}

/* ==========================================================================
   FORMULARIO TEXTAREA
   ========================================================================== */

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  width: 100%;
  color: var(--text-main);
  background: #fff;
  transition: var(--transition);
}

textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* File input */
input[type="file"].form-control {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  cursor: pointer;
  line-height: 1.4;
}

/* ==========================================================================
   BADGE DE CATEGORÍAS EN TABLAS
   ========================================================================== */

.badge-cat {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  white-space: nowrap;
}

.badge-version {
  display: inline-block;
  background: var(--info-bg);
  color: var(--info-text);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
}

/* ==========================================================================
   BOTÓN DESCARGA EN TABLA USUARIO
   ========================================================================== */

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-download:hover {
  opacity: 0.85;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13,148,136,0.35);
}

.btn-download:active {
  transform: translateY(0);
}

/* ==========================================================================
   CHECKBOX INSTITUCIONES EN MODAL DE DOCUMENTO
   ========================================================================== */

.inst-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.inst-checkbox-item:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.inst-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ==========================================================================
   ESTADO ACTIVO/INACTIVO EN DOCUMENTOS
   ========================================================================== */

.badge-active {
  display: inline-block;
  background: var(--success-bg);
  color: var(--success-text);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
}

.badge-inactive {
  display: inline-block;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
}

/* ==========================================================================
   PALABRAS CLAVE
   ========================================================================== */

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.keyword-tag {
  display: inline-block;
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
}

/* ==========================================================================
   INSTITUCIONES MULTI-LINE EN TABLA
   ========================================================================== */

.inst-list {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 180px;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
  }
  .content-body {
    padding: 1rem;
  }
}
