/* =============================================================
   MihiTraining – Custom Styles
   Complements Bootstrap 5 (loaded via CDN in base.html)
   ============================================================= */

/* ── Root variables ────────────────────────────────────────── */
:root {
  --sidebar-bg: #1e293b;
  --sidebar-hover: rgba(255, 255, 255, 0.10);
  --sidebar-active: rgba(255, 255, 255, 0.18);
  --sidebar-width: 260px;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --card-radius: 0.75rem;
}

/* ── Body & layout ─────────────────────────────────────────── */
body {
  background-color: #f1f5f9;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-bs-theme="dark"] body {
  background-color: #0b1220;
  color: #ffffff;
}

[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: var(--sidebar-bg);
  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(255, 255, 255, 0.75);
  text-decoration: none;
  border-radius: 0.5rem;
  margin: 0.1rem 0.5rem;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  font-size: 0.9rem;
}

.sidebar-link i {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 1.4rem;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: 0.75rem 1.5rem 0.25rem;
  margin-top: 0.5rem;
}

/* User card inside sidebar */
.sidebar-user-card {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 0.6rem;
  margin: 0.75rem;
  padding: 0.75rem;
}

.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 {
  background: #0f172a;
  border-bottom-color: #1f2937;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .card {
  border-color: #1f2937;
  background-color: #111827;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .text-muted {
  color: #ffffff !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: #ffffff !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: #1f2937 !important;
}

[data-bs-theme="dark"] .list-group-item {
  background-color: #111827;
  color: #e2e8f0;
  border-color: #1f2937;
}

[data-bs-theme="dark"] .alert-info {
  background-color: rgba(8, 47, 73, 0.45);
  border-color: rgba(56, 189, 248, 0.28);
  color: #bae6fd;
}

.card-hover {
  transition: transform 0.18s, box-shadow 0.18s;
}

.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.10);
}

/* Stat / KPI cards */
.stat-card {
  border-radius: var(--card-radius);
  color: #fff;
  padding: 1.25rem 1.5rem;
}

.stat-card .stat-icon {
  font-size: 2rem;
  opacity: 0.85;
}

.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: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.prose h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: #1e293b;
}

.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: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.9rem;
}

.prose code {
  background: #f1f5f9;
  color: #7c3aed;
  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 #6366f1;
  padding: 0.5rem 1rem;
  color: #64748b;
  font-style: italic;
  margin: 1rem 0;
  background: #f8fafc;
  border-radius: 0 0.4rem 0.4rem 0;
}

.course-intro-text {
  color: #334155;
}

[data-bs-theme="dark"] .course-intro-text {
  color: #ffffff;
}

/* ── 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: #6366f1;
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.ai-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 0.25rem;
  border: 1px solid #e2e8f0;
}

/* 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;
}

/* ── Quiz ───────────────────────────────────────────────────── */
.quiz-option {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-option:hover {
  border-color: #6366f1 !important;
  background: #f5f3ff;
}

.quiz-option input[type="radio"]:checked + label,
.quiz-option.selected {
  border-color: #6366f1 !important;
  background: #f5f3ff;
}

/* 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: #dcfce7; color: #15803d; }
.level-pro     { background: #dbeafe; color: #1d4ed8; }
.level-master  { background: #f3e8ff; color: #7e22ce; }

/* ── 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 #6366f1;
}

/* ── 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.07) !important; }

.text-muted-sm {
  font-size: 0.8rem;
  color: #94a3b8;
}

.overflow-y-auto { overflow-y: auto; }

/* ── 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;
  }
}
