/* =============================================================
   MihiTraining – Modern Blue Theme
   Complements Bootstrap 5 (loaded via CDN in base.html)
   ============================================================= */

/* ── Root variables ────────────────────────────────────────── */
:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --blue-950: #172554;

  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(59, 130, 246, 0.15);
  --sidebar-active: rgba(59, 130, 246, 0.25);
  --sidebar-width: 260px;
  --brand-gradient: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-400) 100%);
  --card-radius: 0.875rem;
}

/* ── Body & layout ─────────────────────────────────────────── */
body {
  background-color: #f8fafc;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1e293b;
}

[data-bs-theme="dark"] body {
  background-color: #030712;
  color: #f1f5f9;
}

[data-bs-theme="dark"] p,
[data-bs-theme="dark"] li,
[data-bs-theme="dark"] span,
[data-bs-theme="dark"] label,
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
  color: #ffffff;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  transition: width 0.25s ease;
  overflow: hidden;
  flex-shrink: 0;
}

#sidebar.collapsed {
  width: 64px;
}

#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .sidebar-section-title,
#sidebar.collapsed .user-card-text {
  display: none !important;
}

#sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 0.75rem 0;
}

/* Sidebar links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  color: rgba(148, 163, 184, 0.9);
  text-decoration: none;
  border-radius: 0.5rem;
  margin: 0.1rem 0.5rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 450;
}

.sidebar-link i {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 1.4rem;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.sidebar-link.active {
  background: var(--blue-600);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.sidebar-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(148, 163, 184, 0.5);
  padding: 0.75rem 1.5rem 0.25rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

/* User card inside sidebar */
.sidebar-user-card {
  background: rgba(59, 130, 246, 0.08);
  border-radius: 0.6rem;
  margin: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(59, 130, 246, 0.12);
}

.sidebar-user-card .avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
#topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  height: 56px;
  z-index: 100;
}

[data-bs-theme="dark"] #topbar,
[data-bs-theme="dark"] .navbar.sticky-top {
  background: rgba(15, 23, 42, 0.9) !important;
  border-bottom-color: #1e293b;
}

[data-bs-theme="dark"] .navbar.sticky-top .navbar-brand {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] footer {
  background: #030712 !important;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}

[data-bs-theme="dark"] .card {
  border-color: #1e293b;
  background-color: #0f172a;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .text-muted {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-secondary,
[data-bs-theme="dark"] .text-body,
[data-bs-theme="dark"] .text-body-secondary,
[data-bs-theme="dark"] .small {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .bg-white {
  background-color: #0f172a !important;
}

[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border {
  border-color: #1e293b !important;
}

[data-bs-theme="dark"] .list-group-item {
  background-color: #0f172a;
  color: #e2e8f0;
  border-color: #1e293b;
}

[data-bs-theme="dark"] .alert-info {
  background-color: rgba(30, 58, 138, 0.3);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.course-card-description {
  font-size: 0.72rem;
  line-height: 1.4;
  color: #64748b;
  margin-bottom: 0.5rem;
}

[data-bs-theme="dark"] .course-card-description {
  color: #cbd5e1;
}

/* Stat / KPI cards */
.stat-card {
  border-radius: var(--card-radius);
  color: #fff;
  padding: 1.25rem 1.5rem;
  background: var(--brand-gradient);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 200%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.stat-card .stat-icon {
  font-size: 2rem;
  opacity: 0.9;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

/* ── Badges / Insignias ─────────────────────────────────────── */
.badge-card {
  text-align: center;
  padding: 1.25rem 0.75rem;
  border-radius: var(--card-radius);
  transition: transform 0.18s;
}

.badge-card:hover {
  transform: translateY(-2px);
}

.badge-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.badge-locked {
  filter: grayscale(100%);
  opacity: 0.45;
}

.grayscale {
  filter: grayscale(100%);
}

/* ── Progress bars ──────────────────────────────────────────── */
.progress {
  border-radius: 999px;
  background-color: #e2e8f0;
}

.progress-bar {
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* Level progress bar (gradient) */
.progress-level .progress-bar {
  background: var(--brand-gradient);
}

/* ── Prose / course content ─────────────────────────────────── */
.prose {
  font-size: 1rem;
  line-height: 1.85;
  color: #334155;
}

.prose h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--blue-900);
}

.prose h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--blue-800);
}

.prose p {
  margin-bottom: 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
  margin-bottom: 1rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.9rem;
  border: 1px solid #1e293b;
}

.prose code {
  background: var(--blue-50);
  color: var(--blue-700);
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  font-size: 0.88em;
}

.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.prose blockquote {
  border-left: 4px solid var(--blue-500);
  padding: 0.5rem 1rem;
  color: #64748b;
  font-style: italic;
  margin: 1rem 0;
  background: var(--blue-50);
  border-radius: 0 0.5rem 0.5rem 0;
}

.course-intro-text {
  color: #334155;
}

[data-bs-theme="dark"] .course-intro-text {
  color: #e2e8f0;
}



/* ── AI Chat ────────────────────────────────────────────────── */
#chatMessages {
  scroll-behavior: smooth;
}

#chatMessages::-webkit-scrollbar {
  width: 4px;
}

#chatMessages::-webkit-scrollbar-track {
  background: transparent;
}

#chatMessages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.chat-msg {
  max-width: 78%;
  word-break: break-word;
}

.chat-msg.user-msg {
  margin-left: auto;
}

.chat-msg.ai-msg {
  margin-right: auto;
}

.chat-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.92rem;
  line-height: 1.55;
}

.user-bubble {
  background: var(--blue-600);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.ai-bubble {
  background: var(--blue-50);
  color: #1e293b;
  border-bottom-left-radius: 0.25rem;
  border: 1px solid var(--blue-100);
}

/* Typing indicator */
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Notification bell ──────────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(35%, -35%);
  font-size: 0.65rem;
  min-width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

/* ── Auth pages (login/register) ────────────────────────────── */
.auth-card {
  max-width: 440px;
  width: 100%;
}

.auth-card .card {
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.brand-gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons (blue override) ──────────────────────────────── */
.btn-primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
}

.btn-primary:hover {
  background: var(--blue-700);
  border-color: var(--blue-700);
}

.btn-primary:active,
.btn-primary:focus-visible {
  background: var(--blue-800);
  border-color: var(--blue-800);
  box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.25);
}

.btn-outline-primary {
  color: var(--blue-600);
  border-color: var(--blue-600);
}

.btn-outline-primary:hover {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}

/* ── Quiz ───────────────────────────────────────────────────── */
.quiz-option {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-option:hover {
  border-color: var(--blue-500) !important;
  background: var(--blue-50);
}

.quiz-option input[type="radio"]:checked + label,
.quiz-option.selected {
  border-color: var(--blue-600) !important;
  background: var(--blue-50);
}

/* Result states */
.answer-correct {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
}

.answer-wrong {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
}

/* ── Rankings ───────────────────────────────────────────────── */
.rank-1 { color: #f59e0b; font-weight: 700; }
.rank-2 { color: #9ca3af; font-weight: 600; }
.rank-3 { color: #b45309; font-weight: 600; }

/* ── Toasts ─────────────────────────────────────────────────── */
.toast-container {
  z-index: 1090;
}

/* ── Level badges ───────────────────────────────────────────── */
.level-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2em 0.6em;
  border-radius: 999px;
}

.level-rookie  { background: var(--blue-100); color: var(--blue-700); }
.level-pro     { background: #c7d2fe; color: #3730a3; }
.level-master  { background: #172554; color: var(--blue-300); }

/* ── Marketplace / Rewards ──────────────────────────────────── */
.reward-card .reward-icon {
  font-size: 3rem;
  line-height: 1;
}

.reward-card .points-chip {
  background: #fef9c3;
  color: #854d0e;
  border-radius: 999px;
  padding: 0.2em 0.7em;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Certificates ───────────────────────────────────────────── */
.cert-card {
  border-left: 5px solid var(--blue-500);
}

/* ── Utilities ──────────────────────────────────────────────── */
.rounded-xl  { border-radius: 0.75rem !important; }
.rounded-2xl { border-radius: 1rem !important; }
.shadow-soft { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05) !important; }
.shadow-blue { box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12) !important; }

.text-muted-sm {
  font-size: 0.8rem;
  color: #94a3b8;
}

.overflow-y-auto { overflow-y: auto; }

/* ── Bootstrap overrides (blue primary) ───────────────────── */
.bg-primary {
  background-color: var(--blue-600) !important;
}

.text-primary {
  color: var(--blue-600) !important;
}

.border-primary {
  border-color: var(--blue-600) !important;
}

.badge.bg-primary {
  background-color: var(--blue-600) !important;
}

/* ── Progress bar blue ────────────────────────────────────── */
.progress-bar {
  background: var(--brand-gradient);
}

/* ── Focus ring blue ──────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

/* ── Links ────────────────────────────────────────────────── */
a {
  color: var(--blue-600);
}

a:hover {
  color: var(--blue-800);
}

/* ── Navbar public blue ───────────────────────────────────── */
.navbar.bg-primary {
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-600) 100%) !important;
}

/* ── Selection highlight ──────────────────────────────────── */
::selection {
  background: var(--blue-200);
  color: var(--blue-900);
}

/* ── Scrollbar styling ────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--blue-200);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--blue-400);
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 767.98px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  #sidebar.mobile-open {
    transform: translateX(0);
  }

  #sidebar.collapsed {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  #main-content {
    margin-left: 0 !important;
  }
}

/* --- Sticky Sidebar for Desktop --- */
@media (min-width: 768px) {
  #sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: flex-start;
    z-index: 1040;
  }
}

/* --- Sticky Sidebar for Mobile (optional, keep overlay behavior) --- */
@media (max-width: 767.98px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
}

/* --- Scroll interno para sidebar cuando el contenido es mayor al alto de la pantalla --- */
@media (min-width: 768px) {
  #sidebar {
    overflow-y: auto;
    max-height: 100vh;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #1e293b;
  }
  #sidebar::-webkit-scrollbar {
    width: 6px;
    background: transparent;
  }
  #sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
  }
}
