@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

/* Modo claro (por defecto) */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --text: #0b1220;
  --text-secondary: #6b7280;
  --border: #e6e9ef;
  --primary: #0b63ff;
  --primary-2: #0066d6;
  --primary-light: rgba(11, 99, 255, 0.06);
  --success: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 30px 80px rgba(11, 63, 128, 0.06);
}

/* Modo oscuro */
html.dark-mode {
  --bg: #0f172a;
  --surface: #1a2332;
  --surface-2: #233449;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border: #334155;
  --primary: #3b82f6;
  --primary-2: #1e40af;
  --primary-light: rgba(59, 130, 246, 0.1);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* ===== MEJORAS DARK MODE ===== */
html.dark-mode body {
  background: linear-gradient(180deg, var(--bg), #0b1220);
}

html.dark-mode .topbar {
  background: var(--surface);
  border-bottom-color: var(--border);
}

html.dark-mode .nav a:hover,
html.dark-mode .nav a.active {
  color: #93c5fd;
}

html.dark-mode .card,
html.dark-mode .comment-card,
html.dark-mode .list-item,
html.dark-mode .table,
html.dark-mode .table-wrap {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

html.dark-mode .table th {
  background: var(--surface-2);
  color: var(--text-secondary);
}

html.dark-mode .table td {
  border-bottom-color: var(--border);
}

html.dark-mode .badge {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.25);
}

html.dark-mode .btn.light {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}

html.dark-mode .alert.success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}

html.dark-mode .alert.error {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

html.dark-mode .user-menu .menu a:hover {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

html.dark-mode .login-left::before {
  filter: blur(4px) brightness(0.6);
}

html.dark-mode .login-alert {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

html.dark-mode .theme-toggle-login {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

html.dark-mode .theme-toggle-login:hover {
  background: rgba(255, 255, 255, 0.2);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), var(--surface));
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.section-title {
  margin: 16px 0 10px;
  font-size: 16px;
  font-weight: 800;
}

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

@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ===== TOPBAR/HEADER ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.brand-link {
  display: flex;
  align-items: center;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  margin-right: 6px;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav a.active {
  color: var(--primary);
  background: linear-gradient(90deg, rgba(11, 99, 255, 0.06), rgba(0, 102, 214, 0.04));
  box-shadow: inset 0 -2px 0 var(--primary);
}

.nav-spacer {
  flex: 1;
}

.theme-toggle {
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}

.user-menu {
  position: relative;
  margin-left: 6px;
}

.user-menu summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu summary:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.user-menu summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.user-menu .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 14px;
}

.user-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.user-menu .menu a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  transition: all 0.2s ease;
}

.user-menu .menu a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.user-menu[open] summary {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== BOTONES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn.primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}

.btn.primary:hover {
  filter: brightness(1.1);
}

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

.btn.danger:hover {
  filter: brightness(0.9);
}

.btn.light {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn.small {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
}

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

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}

.alert.success {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ===== TARJETAS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
}

.card .hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 16px;
}

.card .bd {
  padding: 12px 14px;
}

/* ===== GRID ===== */
.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

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

@media (max-width: 1024px) {
  .grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}

/* ===== UTILIDADES ===== */
.muted {
  color: var(--text-secondary);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid rgba(11, 99, 255, 0.08);
  white-space: nowrap;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

html.dark-mode .badge {
  border-color: rgba(59, 130, 246, 0.15);
}

/* ===== FORMULARIOS ===== */
.form label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 10px 0 6px;
}

.form input,
.form textarea,
.form select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}

.form input::placeholder,
.form textarea::placeholder {
  color: var(--text-secondary);
}

.form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .form .row {
    grid-template-columns: 1fr;
  }
}

/* ===== TABLAS ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
}

.table-wrap .table {
  border: 0;
}

.table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
  padding: 12px 10px;
  text-align: left;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}

.table tbody tr {
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

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

/* ===== LOGIN ===== */
.login-page {
  background: var(--surface);
}

.login-app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-left {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.login-left::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url('../img/salapersonas.png') center/cover no-repeat;
  filter: blur(4px) brightness(0.78);
  transform: scale(1.04);
}

.login-left::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.25) 45%, rgba(0,0,0,.1) 70%, rgba(0,0,0,0));
}

.login-left-copy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: clamp(20px, 6vw, 64px);
  color: #fff;
  text-shadow: 0 3px 18px rgba(0,0,0,.45);
}

.login-left-copy-inner {
  max-width: 620px;
}

.login-hero-line {
  font-weight: 800;
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.12;
  letter-spacing: 0.2px;
  margin-bottom: 10px;
  transition: opacity 0.35s ease;
}

.login-hero-sub {
  font-size: clamp(14px, 1.4vw, 18px);
  opacity: 0.95;
  max-width: 52ch;
  transition: opacity 0.35s ease;
}

.login-fade-out {
  opacity: 0;
}

.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 60px);
  background: var(--surface);
}

.login-content {
  width: min(100%, 500px);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.login-brand img {
  max-width: 320px;
  width: 100%;
  height: auto;
}

.login-title {
  text-align: center;
  font-size: 27px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
  color: var(--text);
}

.login-subtitle {
  text-align: center;
  font-size: 14.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.login-alert {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #b91c1c;
  font-size: 14px;
  margin-bottom: 12px;
}

.login-content form {
  display: grid;
  gap: 12px;
}

.login-content label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  display: block;
  font-weight: 600;
}

.login-content input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.login-content input::placeholder {
  color: var(--text-secondary);
}

.login-content input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-login {
  border: none;
  cursor: pointer;
  padding: 11px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  transition: filter 0.15s;
}

.btn-login:hover {
  filter: brightness(1.1);
}

.theme-toggle-login {
  position: fixed;
  top: 20px;
  right: 20px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 20px;
  z-index: 100;
  transition: all 0.2s ease;
}

.theme-toggle-login:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

@media (max-width: 900px) {
  .login-app { grid-template-columns: 1fr; }
  .login-left { height: 38vh; }
  .login-left-copy { align-items: flex-end; padding: 20px; }
  .login-hero-line { font-size: clamp(22px, 6vw, 30px); }
  .login-hero-sub { font-size: clamp(13px, 3.5vw, 15px); }
  .login-right { padding: 22px 16px; }
  .login-brand img { max-width: 240px; }
  .login-content { width: min(100%, 560px); }
}

/* ===== CURSOS ===== */
.course-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.course-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.course-card h3 {
  margin: 4px 0;
  font-size: 16px;
  font-weight: 700;
}

.progress {
  height: 12px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  width: 0%;
  transition: width 0.3s ease;
}

/* ===== OTROS ===== */
.player {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.lesson-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: all 0.2s ease;
}

.lesson-item:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}

.lesson-item .meta {
  flex: 1;
}

.lock {
  opacity: 0.6;
}

.footer {
  padding: 28px;
  text-align: center;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.flex-1 {
  flex: 1;
}

.ml-auto {
  margin-left: auto;
}

.self-end {
  align-self: flex-end;
}

.inline-form {
  display: inline;
}

.comments-admin {
  margin-top: 16px;
}

.comment-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
}

.comment-card h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
}

.comment-card .meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.comment-card .body {
  white-space: pre-wrap;
  margin: 8px 0;
  font-size: 14px;
}

.comment-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.demo-hint {
  margin-top: 12px;
  color: var(--text-secondary);
  text-align: center;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ===== TOAST ===== */
.toast {
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  font-size: 14px;
  line-height: 1.35;
}

.toast.show {
  display: block;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== ANIMACIONES ===== */
@media (prefers-reduced-motion: no-preference) {
  * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-top: 8px;
  }

  .container {
    padding: 16px;
  }

  .login-card {
    width: 90%;
    max-width: 420px;
  }
}

/* ===== ACCESIBILIDAD ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible para navegación por teclado */
.btn:focus-visible,
.nav a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
