/* ============================================================
   UPTAG - Sistema de Laboratorios CONÉCTATE
   Hoja de Estilos Principal - Tema Oscuro
   ============================================================ */

:root {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-card:       #1c2128;
  --bg-input:      #21262d;
  --border-color:  #30363d;
  --accent:        #f0a500;
  --accent-hover:  #d4920a;
  --accent-light:  rgba(240,165,0,0.12);
  --danger:        #e74c3c;
  --danger-light:  rgba(231,76,60,0.12);
  --success:       #2ecc71;
  --success-light: rgba(46,204,113,0.12);
  --info:          #3498db;
  --info-light:    rgba(52,152,219,0.12);
  --warning:       #f39c12;
  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 4px 16px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
  --transition:    all 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   LAYOUT GENERAL
   ============================================================ */

.wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

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

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-logo h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  transition: var(--transition);
  font-size: 13.5px;
  border-left: 3px solid transparent;
  margin: 1px 8px;
  border-radius: var(--radius);
}

.nav-item:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}

.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--bg-primary);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-info .role {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.topbar .breadcrumb { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   COMPONENTES - CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--accent); }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.amber  { background: var(--accent-light);   color: var(--accent); }
.stat-icon.green  { background: var(--success-light);  color: var(--success); }
.stat-icon.blue   { background: var(--info-light);     color: var(--info); }
.stat-icon.red    { background: var(--danger-light);   color: var(--danger); }

.stat-info .value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-info .label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ============================================================
   TABLAS
   ============================================================ */

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-primary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(240,165,0,0.04); }

/* ============================================================
   HORARIO - VISTA PÚBLICA Y ADMIN
   ============================================================ */

.schedule-container { overflow-x: auto; }

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.schedule-table th {
  background: var(--bg-input);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.schedule-table .turno-header {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.schedule-table td {
  border: 1px solid var(--border-color);
  padding: 6px 150px;
  text-align: center;
  vertical-align: middle;
  font-size: 12px;
}

.schedule-table .hora-cell {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 110px;
}

.session-block {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 6px 8px;
  text-align: center;
}

.session-block.externa {
  background: var(--info-light);
  border-color: var(--info);
}

.session-block .pnf-name { font-weight: 700; color: var(--accent); font-size: 11px; }
.session-block.externa .pnf-name { color: var(--info); }
.session-block .docente-name { color: var(--text-primary); font-size: 11px; }
.session-block .uc-name { color: var(--text-secondary); font-size: 10px; }
.session-block .seccion { color: var(--text-muted); font-size: 10px; }

.libre-cell { color: var(--text-muted); font-size: 11px; font-style: italic; }

/* Badges de turno */
.badge-turno {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-matutino  { background: var(--accent-light);   color: var(--accent); }
.badge-vespertino{ background: var(--info-light);     color: var(--info); }
.badge-nocturno  { background: rgba(155,89,182,0.15); color: #9b59b6; }

/* ============================================================
   FORMULARIOS
   ============================================================ */

.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="time"],
input[type="date"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  width: 100%;
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select option { background: var(--bg-card); color: var(--text-primary); }
textarea { resize: vertical; min-height: 80px; }

.input-help { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--bg-primary); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }

.btn-success { background: var(--success); color: var(--bg-primary); }
.btn-success:hover:not(:disabled) { background: #27ae60; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-full { width: 100%; }

/* ============================================================
   ALERTS / MENSAJES
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-light); border: 1px solid var(--success); color: var(--success); }
.alert-danger   { background: var(--danger-light);  border: 1px solid var(--danger);  color: var(--danger); }
.alert-info     { background: var(--info-light);    border: 1px solid var(--info);    color: var(--info); }
.alert-warning  { background: rgba(243,156,18,.12); border: 1px solid var(--warning); color: var(--warning); }

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-amber   { background: var(--accent-light);  color: var(--accent); }
.badge-muted   { background: var(--bg-input);      color: var(--text-muted); }

/* ============================================================
   MODALES
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal { transform: translateY(0); }

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

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

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

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo .icon-wrap {
  width: 64px; height: 64px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 12px;
}

.login-logo h1 { font-size: 20px; font-weight: 800; }
.login-logo p { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }

/* ============================================================
   PÚBLIC SCHEDULE PAGE
   ============================================================ */

.public-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-header .brand { display: flex; align-items: center; gap: 12px; }
.public-header .brand .icon {
  width: 42px; height: 42px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.public-header .brand h1 { font-size: 18px; font-weight: 800; }
.public-header .brand p  { font-size: 12px; color: var(--text-secondary); }

.day-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius);
  overflow-x: auto;
}

.day-tab {
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  border: none;
  background: none;
  font-family: var(--font);
}

.day-tab.active, .day-tab:hover {
  background: var(--accent);
  color: var(--bg-primary);
}

.lab-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
}

.lab-tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  font-family: var(--font);
  margin-bottom: -1px;
}

.lab-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.lab-tab:hover  { color: var(--accent); }

/* ============================================================
   CHARTS
   ============================================================ */

.chart-container {
  position: relative;
  height: 280px;
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.toggle-wrap { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: var(--radius); }

.toggle-opt {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 5px;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
  text-align: center;
}

.toggle-opt.active { background: var(--accent); color: var(--bg-primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .form-grid.cols-2,
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px; }
  .page-content { padding: 14px; }
  .topbar { padding: 12px 14px; }
}

/* ============================================================
   UTILS
   ============================================================ */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }

/* Spinner */
.spinner {
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  width: 22px; height: 22px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  font-size: 13.5px;
}

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

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

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .hamburger { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
}