/* ==================== RESET BÁSICO ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  font-size: 16px;           /* tamaño base más grande */
  line-height: 1.5;
  background-color: #0f172a; /* fondo oscuro general */
}

/* Ajuste general de tipografía en inputs/botones */
body, input, button, select, textarea {
  font-size: 16px;
}

/* ==================== PANTALLAS ==================== */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* ==================== LOGIN ==================== */
#login-screen {
  padding: 24px 12px;
}

/* Tarjeta principal del login */
.auth-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 30px 26px 24px;
  width: 100%;
  max-width: 520px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.55);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.1), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(59, 130, 246, 0.15), transparent 55%);
  z-index: -1;
}

.auth-card h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}

/* Logo redondo arriba del login */
.login-logo-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #38bdf8, #1d4ed8);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.6);
  color: #f9fafb;
  font-size: 2.1rem;
}

/* Texto bajo el título */
.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
}

/* Tabs login/register */
.auth-tabs {
  display: flex;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 3px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.95rem;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  font-weight: 500;
}

.auth-tab.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.auth-form.hidden {
  display: none;
}

.helper-text {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ==================== FORM CONTROLES ==================== */

.form-group input,
.form-group select,
.form-group textarea {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 10px 12px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.form-group label {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* ==================== LAYOUT PRINCIPAL ==================== */

/* CAMBIO: quitamos display:flex aquí para que .screen pueda ocultarlo */
#main-layout {
  min-height: 100vh;
  background: #e5e7eb;
}

/* CAMBIO: solo cuando está activo queremos que sea flex */
#main-layout.screen.active {
  display: flex;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 270px;
  background: radial-gradient(circle at top, #020617, #020617 50%, #0b1120);
  color: #ffffff;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.55);
  border-right: 1px solid rgba(148, 163, 184, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f9fafb;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #9ca3af;
}

.menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
}

.menu-section-title {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 6px;
  padding-inline: 4px;
}

.menu-item {
  border: none;
  background: transparent;
  color: #e5e7eb;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.menu-item:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
  transform: translateX(3px);
}

.menu-item.active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: white;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.6);
}

.menu-icon {
  width: 24px;
  text-align: center;
  font-size: 1.1rem;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

/* ==================== MAIN / TOPBAR ==================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
}

#view-subtitle {
  margin: 3px 0 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #22c55e, #0f766e);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #ffffff;
}

.user-name {
  font-size: 0.95rem;
  color: #111827;
}

.user-role {
  font-size: 0.8rem;
  color: #6b7280;
}

/* ==================== CONTENIDO PRINCIPAL ==================== */
.view-container {
  padding: 24px 26px;
  overflow-y: auto;
  background: #e5e7eb;
  min-height: calc(100vh - 64px);
}

/* GRIDS QUE USA app.js */
.grid {
  display: grid;
  gap: 20px;
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* ==================== CARDS ==================== */
.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 24px;
  margin: 6px 0;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.card-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 4px;
}

.chip {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 0.85rem;
  color: #6b7280;
}

/* BADGES */
.badge.ok {
  background: #ecfdf5;
  color: #16a34a;
}

.badge.alerta {
  background: #fee2e2;
  color: #b91c1c;
}

/* PARAM BADGES */
.param-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  margin-right: 6px;
}

.param-ok {
  background: #ecfdf5;
  color: #16a34a;
}

.param-warn {
  background: #fef3c7;
  color: #92400e;
}

.param-bad {
  background: #fee2e2;
  color: #b91c1c;
}

.param-alert {
  color: #b91c1c;
  font-weight: 600;
}
/* Píldoras de parámetros más vistosas */
.param-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.param-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* Texto resumido debajo de los parámetros */
.param-summary {
  margin-top: 6px;
  font-size: 0.82rem;
  color: #6b7280;
}

/* Banner de alerta fuerte dentro de la tarjeta */
.alert-strip {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.alert-icon {
  font-size: 1rem;
}


/* ==================== TABLAS ==================== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table thead {
  background: #f3f4f6;
}

.table th,
.table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.table th {
  font-weight: 600;
  font-size: 0.9rem;
  color: #4b5563;
}

/* ==================== FORMULARIOS EN VISTAS ==================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  margin-top: 8px;
}

.form-group.full,
.form-actions.full {
  grid-column: 1 / -1;
}

/* ==================== MODAL PERSONALIZADO (si se usa) ==================== */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}

.modal-custom {
  background: #ffffff;
  padding: 20px 18px 18px;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
}

/* ==================== BOTONES (OVERWRITE BOOTSTRAP BÁSICO) ==================== */
.btn {
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary,
.btn.primary {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  border: none;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover,
.btn.primary:hover {
  background: linear-gradient(135deg, #1e40af, #1e3a8a);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.btn-outline-light {
  border-radius: 999px;
  border-width: 1px;
  font-weight: 600;
}

.btn-outline-light:hover {
  background: #f9fafb;
  color: #0f172a;
}

/* Botón “fantasma” que usa el JS (editar, eliminar, etc.) */
.btn.ghost {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn.ghost:hover {
  background: #e5e7eb;
}

/* ==================== UTILIDADES ==================== */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.text-right { text-align: right; }

.text-muted {
  color: #6b7280;
  font-size: 0.85rem;
}

/* Para mensajes de cambio de contraseña */
.text-danger { color: #b91c1c; }
.text-success { color: #15803d; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  #main-layout {
    flex-direction: column;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .view-container {
    padding-inline: 14px;
  }

  #login-screen {
    padding: 16px;
  }

  .auth-card {
    padding: 24px 20px;
  }
}
