/* =========================================================================
   CapacitaPro - Sistema de diseño
   Las variables de color se sobreescriben en línea (ver app/includes/header.php)
   con los valores guardados en la tabla `settings`, así todo el look & feel
   es parametrizable desde el panel de administración sin tocar este archivo.
   ========================================================================= */

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-secondary: #0ea5e9;
  --color-accent: #f59e0b;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --bg-app: #f4f5fb;
  --bg-card: #ffffff;
  --text-main: #1e2130;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;

  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  --sidebar-width: 264px;
  --topbar-height: 68px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-family);
  background: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}
body { font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 12px; color: var(--text-muted); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Layout general (shell con sidebar) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px;
  font-weight: 800; font-size: 18px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-brand img { height: 32px; width: auto; border-radius: 6px; background: #fff; padding: 2px; }
.sidebar-brand .brand-badge {
  width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  opacity: .6; margin: 18px 10px 6px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.85); font-weight: 500; font-size: 14px;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }
.sidebar-nav .icon { width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 14px 20px; font-size: 12px; opacity: .65; border-top: 1px solid rgba(255,255,255,.12); }

.main-wrap { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-weight: 700; font-size: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-main);
}

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 8px; border-radius: 999px; }
.user-chip:hover { background: var(--bg-app); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: var(--color-secondary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 88px; height: 88px; font-size: 28px; }

.content { padding: 26px; flex: 1; }

/* ---------- Tarjetas / componentes ---------- */
.card {
  background: var(--bg-card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { margin: 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Layouts de "contenido + panel lateral" que se usan con estilo en línea
   en varias páginas (curso, reportes, panel admin). Se colapsan a una sola
   columna en pantallas angostas para que la plataforma se vea bien en celular. */
.grid-side-r  { grid-template-columns: 2fr 1fr; }
.grid-side-r-wide { grid-template-columns: 1fr 380px; }
.grid-side-r-narrow { grid-template-columns: 1fr 360px; }
.grid-side-l  { grid-template-columns: 320px 1fr; }
@media (max-width: 900px) {
  .grid-side-r, .grid-side-r-wide, .grid-side-r-narrow, .grid-side-l { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-card); border-radius: var(--radius-md); padding: 20px;
  border: 1px solid var(--border-color); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
}
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; }

.course-card {
  background: var(--bg-card); border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--border-color); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; transition: transform .15s ease, box-shadow .15s ease;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.course-cover {
  height: 130px; background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 36px;
}
.course-card .course-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.course-card .course-category { font-size: 12px; font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: .04em; }
.course-card h4 { margin: 0; font-size: 16px; }
.course-card .course-desc { font-size: 13px; color: var(--text-muted); flex: 1; }
.course-card .course-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

/* ---------- Barra de progreso ---------- */
.progress { background: #eef0f7; border-radius: 999px; height: 10px; overflow: hidden; width: 100%; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--color-primary), var(--color-secondary)); border-radius: 999px; transition: width .3s ease; }
.progress.thin { height: 6px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s ease;
  background: var(--bg-card); color: var(--text-main);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-control, select.form-control, textarea.form-control {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); font-family: inherit; font-size: 14px;
  background: #fff; color: var(--text-main);
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 14px; }
.form-row > .form-group { flex: 1; }
.form-check { display: flex; align-items: center; gap: 8px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 10px 14px; border-bottom: 2px solid var(--border-color); }
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.table tr:hover td { background: #fafaff; }

/* ---------- Insignias / etiquetas ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f2f6; color: var(--text-muted); }

/* ---------- Alertas / flash messages ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Login / pantallas públicas ---------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; padding: 36px 32px;
}
.auth-card .brand { text-align: center; margin-bottom: 22px; }
.auth-card .brand .brand-badge {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px;
}
.auth-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* ---------- Leaderboard / gamificación ---------- */
.leaderboard-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-app); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.leaderboard-rank.top1 { background: #fde68a; }
.leaderboard-rank.top2 { background: #e5e7eb; }
.leaderboard-rank.top3 { background: #fdba74; }
.leaderboard-points { margin-left: auto; font-weight: 700; color: var(--color-primary); }

.badge-tile { text-align: center; padding: 16px 8px; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.badge-tile .badge-icon { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; }
.badge-tile.locked { opacity: .4; filter: grayscale(1); }

/* ---------- Quiz ---------- */
.quiz-question { padding: 18px 0; border-bottom: 1px solid var(--border-color); }
.quiz-question:last-child { border-bottom: none; }
.quiz-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-top: 8px; cursor: pointer; }
.quiz-option:hover { border-color: var(--color-primary); }
.quiz-option input { accent-color: var(--color-primary); }
.quiz-option.correct { border-color: var(--success); background: #ecfdf3; }
.quiz-option.incorrect { border-color: var(--danger); background: #fef2f2; }

/* ---------- Utilidades ---------- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .form-row { flex-direction: column; }
}
.overlay { position: fixed; inset: 0; background: rgba(15,17,25,.4); z-index: 35; display: none; }
.overlay.show { display: block; }
