:root {
  --bg-color: #0f111a;
  --panel-bg: rgba(26, 29, 46, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #374151;
  --secondary-hover: #4b5563;
  --success-color: #10b981;
  --success-hover: #059669;
  --warning-color: #f59e0b;
  --warning-hover: #d97706;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent-glow: rgba(79, 70, 229, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #0f111a 70%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.app-header {
  padding: 2.5rem 1rem 1.5rem;
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 10px var(--primary-color));
}

.logo h1 {
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #a5b4fc, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: var(--text-muted);
  font-weight: 300;
  font-size: 1.1rem;
}

.main-container {
  max-width: 1100px;
  width: 95%;
  margin: 0 auto 3rem;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 1. Tarjeta de Autenticación */
.auth-card {
  width: 100%;
  max-width: 450px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: all 0.4s ease;
  animation: fadeIn 0.4s ease-out;
}

.auth-card:hover {
  border-color: rgba(79, 70, 229, 0.25);
  box-shadow: 0 12px 40px 0 rgba(79, 70, 229, 0.1);
}

.card-header {
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* 2. Tarjeta del Dashboard */
.dashboard-card {
  width: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  animation: fadeIn 0.4s ease-out;
}

.dashboard-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}

.user-greeting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.connected {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sub-card {
  background: rgba(15, 17, 26, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
}

h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
  border-left: 3px solid var(--primary-color);
  padding-left: 0.5rem;
}

/* Campos de Formulario */
.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

input {
  background-color: rgba(15, 17, 26, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.button-row {
  display: flex;
  gap: 0.75rem;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

.btn-success {
  background-color: var(--success-color);
  color: #fff;
}

.btn-success:hover {
  background-color: var(--success-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-warning {
  background-color: var(--warning-color);
  color: #fff;
}

.btn-warning:hover {
  background-color: var(--warning-hover);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #fff;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Info de Perfil */
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-info p {
  font-size: 0.9rem;
}

.profile-info span {
  font-family: monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* Listado de Conexiones */
.connections-list-container {
  max-height: 150px;
  overflow-y: auto;
}

.connections-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.connections-list li {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.connections-list li::before {
  content: "👤";
  font-size: 0.9rem;
}

.connections-list li.empty-state {
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
  background: none;
  border: none;
}

.connections-list li.empty-state::before {
  content: "";
}

/* Generador de Tokens */
.token-generator {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.token-display {
  background-color: rgba(16, 185, 129, 0.03);
  border: 1px dashed rgba(16, 185, 129, 0.25);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  animation: slideDown 0.3s ease-out;
}

.token-value-container {
  display: flex;
  background: #0f111a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  align-items: center;
}

.token-code {
  flex: 1;
  padding: 0.6rem 0.8rem;
  font-family: monospace;
  color: var(--success-color);
  font-size: 0.95rem;
  overflow-x: auto;
  white-space: nowrap;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-left: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0 1rem;
  height: 100%;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.1);
}

.expiry-timer {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.expiry-timer span {
  font-weight: 700;
  color: var(--warning-color);
}

/* Logs */
.console-logs {
  background-color: #08090f;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.console-logs h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.console-logs pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 100px;
  overflow-y: auto;
  color: #a5b4fc;
}

.app-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; overflow: hidden; }
  to { opacity: 1; max-height: 100px; }
}

/* 3. Menú Lateral (Sidebar) y Layout del Dashboard */
.dashboard-layout {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .dashboard-layout {
    flex-direction: row;
    min-height: 580px;
  }
}

.dashboard-sidebar {
  width: 100%;
  background: rgba(10, 11, 18, 0.4);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .dashboard-sidebar {
    width: 240px;
    border-bottom: none;
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px var(--primary-color));
}

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  background: none;
  border-left: none;
  padding-left: 0;
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: normal;
}

.sidebar-nav {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    flex: 1;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background: transparent;
  width: 100%;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #fff;
  background: var(--primary-color);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.nav-icon {
  font-size: 1.1rem;
}

.sidebar-footer {
  margin-top: auto;
  width: 100%;
}

.dashboard-content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .dashboard-content {
    padding: 2rem;
  }
}

/* 10. Módulo de Salud y Novedades Médicas */
.dashboard-grid-health {
  animation: fadeIn 0.3s ease-out;
}

#health-event-form input[type="text"],
#health-event-form input[type="date"],
#health-event-form input[type="datetime-local"],
#health-event-form select {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  background: #27272a;
  border: 1px solid #3f3f46;
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

#health-event-form input:focus,
#health-event-form select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#health-events-container {
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #18181b;
}

#health-events-container::-webkit-scrollbar {
  width: 6px;
}

#health-events-container::-webkit-scrollbar-track {
  background: #18181b;
}

#health-events-container::-webkit-scrollbar-thumb {
  background-color: #3f3f46;
  border-radius: 3px;
}

