/* ═══════════════════════════════════════════════
   ALCOCERMED — PANEL DE CONTROL (ADMIN)
   Estilos consistentes con la app principal
   ═══════════════════════════════════════════════ */

:root {
  --orange: #ff6b00;
  --orange-light: #ff8c00;
  --orange-grad: linear-gradient(135deg, #ff8c00, #ff4500);
  --orange-soft: rgba(255, 107, 0, 0.12);
  --sidebar-bg: #111318;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 107, 0, 0.18);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --text-muted: rgba(255, 255, 255, 0.38);
  --text-soft: rgba(255, 255, 255, 0.65);
  --bg-white: #f9fafb;
  --bg-soft: #f3f4f6;
  --text-dark: #111827;
  --text-medium: #374151;
  --border-light: #e5e7eb;
  --card-bg: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --purple: #7c3aed;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', sans-serif;
  text-transform: lowercase;
}

body {
  background: var(--bg-soft);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
}

/* ── LOGIN ── */
.admin-login-screen {
  position: fixed;
  inset: 0;
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  overflow: hidden;
}

.admin-login-screen.hidden {
  display: none;
}

.login-bg-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 107, 0, 0.22) 0%, transparent 70%);
  top: -120px;
  left: -120px;
  pointer-events: none;
}

.login-bg-glow-2 {
  top: auto;
  bottom: -120px;
  left: auto;
  right: -120px;
  background: radial-gradient(circle, rgba(255, 140, 0, 0.18) 0%, transparent 70%);
}

.login-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 1;
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--orange-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  overflow: hidden;
}

.login-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.login-brand-pre {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.login-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.login-brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.login-title-wrap {
  margin-bottom: 28px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--orange);
}

.login-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.login-btn {
  background: var(--orange-grad);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  margin-top: 4px;
}

.login-btn:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-error.hidden {
  display: none;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── SIDEBAR ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-text .logo-pre {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sidebar-logo-text .logo-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.sidebar-logo-text .logo-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.user-session {
  padding: 14px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--orange-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

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

.user-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  color: var(--success);
  font-size: 0.5rem;
}

.sidebar-logout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logout-btn:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

.nav-section {
  padding: 16px 14px;
}

.nav-section + .nav-section {
  border-top: 1px solid var(--sidebar-border);
}

.section-title {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-links {
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
  width: 100%;
}

.nav-item a:hover,
.nav-item.active a {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active a {
  background: var(--sidebar-active);
  color: var(--orange-light);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-bar {
  height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

.top-bar-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
}

.top-bar-left p {
  font-size: 0.75rem;
  color: var(--text-medium);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-admin {
  background: var(--orange-soft);
  color: var(--orange);
  border: 1px solid rgba(255, 107, 0, 0.2);
}

/* ── CONTENT SCROLL AREA ── */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ── SECTIONS ── */
.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-medium);
  font-weight: 500;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-icon.green { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.stat-icon.purple { background: rgba(124, 58, 237, 0.1); color: var(--purple); }

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1;
}

.stat-delta {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── CHARTS / BARS ── */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-subtitle {
  font-size: 0.78rem;
  color: var(--text-medium);
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.progress-meta .label {
  font-weight: 600;
  color: var(--text-dark);
}

.progress-meta .value {
  color: var(--text-medium);
  font-weight: 500;
}

.progress-track {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-fill.orange { background: var(--orange-grad); }
.progress-fill.blue { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.progress-fill.green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.progress-fill.purple { background: linear-gradient(90deg, #7c3aed, #a78bfa); }

/* ── TABLES ── */
.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 240px;
}

.table-search i {
  color: var(--text-medium);
  font-size: 0.85rem;
}

.table-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--text-dark);
  width: 100%;
}

.table-search input::placeholder {
  color: #9ca3af;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 12px 20px;
  font-weight: 600;
  color: var(--text-medium);
  background: var(--bg-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-dark);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(249, 250, 251, 0.8);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-cell-info {
  display: flex;
  flex-direction: column;
}

.user-cell-name {
  font-weight: 600;
  color: var(--text-dark);
}

.user-cell-email {
  font-size: 0.75rem;
  color: var(--text-medium);
}

.tag {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-success { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.tag-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.tag-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.tag-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.tag-muted { background: var(--bg-soft); color: var(--text-medium); }

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
}

.score-high { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.score-mid { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.score-low { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.mini-bar {
  width: 60px;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--orange-grad);
}

/* ── GRID LAYOUTS ── */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.three-col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-medium);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 16px;
  color: #d1d5db;
}

.empty-state h4 {
  font-size: 1rem;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
}

/* ── LOADING ── */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 12px;
  color: var(--text-medium);
}

.loading-overlay i {
  font-size: 1.5rem;
  color: var(--orange);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card-bg);
  border-radius: 20px;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-soft);
  color: var(--danger);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── BUTTONS ── */
.btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text-dark);
  border: 1px solid var(--border-light);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-medium);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Outfit', sans-serif;
  text-transform: lowercase;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--text-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col-grid { grid-template-columns: 1fr; }
  .three-col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .stats-grid { grid-template-columns: 1fr; }
  .top-bar { padding: 0 16px; }
  .content-scroll { padding: 16px; }
  table { font-size: 0.78rem; }
  th, td { padding: 10px 12px; }
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toastSlide 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastSlide {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
