
:root {
  --brand: #D7AE2A;
  --brand-600: #b89220;
  --brand-50: #fbf5df;
  --secondary: #2D3073;
  --secondary-700: #22255f;
  --secondary-50: #eef0ff;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f6f7fb;
  --border: #e5e7eb;
  --warning: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --shadow-soft: 0 18px 45px -28px rgba(15, 23, 42, .35);
}

html, body { height: 100%; margin: 0; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

/* Brand utilities */
.text-brand { color: var(--brand) !important; }
.bg-brand   { background: var(--brand) !important; color: #fff; }
.bg-brand-50{ background: var(--brand-50) !important; }
.btn-brand {
  background: var(--brand); border-color: var(--brand); color: #151515;
  font-weight: 700;
}
.btn-brand:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-outline-brand {
  border-color: var(--brand); color: var(--brand);
}
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.badge-brand { background: var(--brand-50); color: #7b6111; font-weight: 700; }

/* Navbar */
.navbar-brand-logo {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--brand) !important;
}
.navbar .nav-link { color: var(--ink); font-weight: 500; }
.navbar .nav-link.active, .navbar .nav-link:hover { color: var(--brand); }
.search-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.search-pill input {
  background: transparent;
  border: 0;
}
.search-pill input:focus { box-shadow: none; outline: 0; }

/* Hero */
.hero {
  background: radial-gradient(1200px 500px at 80% -10%, #c7d2fe 0%, transparent 60%),
              linear-gradient(180deg, #ffffff, #f8fafc 80%);
  padding: 80px 0 60px;
}
.hero h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero p.lead { color: var(--muted); font-size: 1.1rem; max-width: 560px; }

/* Course card */
.course-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
  background: #fff;
  height: 100%;
}
.course-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px -16px rgba(15,23,42,.18);
}
.course-card .thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  display:flex; align-items:center; justify-content:center;
  font-size: 2rem;
  font-weight: 700;
}
.course-card .thumb.alt-1 { background: linear-gradient(135deg,#0ea5e9,#22d3ee); }
.course-card .thumb.alt-2 { background: linear-gradient(135deg,#f59e0b,#fbbf24); }
.course-card .thumb.alt-3 { background: linear-gradient(135deg,#ef4444,#f97316); }
.course-card .thumb.alt-4 { background: linear-gradient(135deg,#10b981,#34d399); }
.course-card .thumb.alt-5 { background: linear-gradient(135deg,#8b5cf6,#c4b5fd); }
.course-card h6 {
  font-weight: 700;
  line-height: 1.35;
}
.course-card .meta { color: var(--muted); font-size: .85rem; }
.rating-stars { color: #f59e0b; }

/* Category tile */
.category-tile {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  text-align: center;
  background: #fff;
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.category-tile:hover {
  border-color: var(--brand);
  background: var(--brand-50);
  color: var(--brand);
}
.category-tile i { font-size: 1.8rem; color: var(--brand); }

/* Sidebar (dashboard) */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px 1fr; }
@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    z-index: 1050;
    transition: transform .22s ease;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .app-sidebar.show { transform: translateX(0); }
}
.app-sidebar {
  background: linear-gradient(180deg, var(--secondary), var(--secondary-700));
  color: rgba(255,255,255,.78);
  padding: 1.15rem .75rem;
  width: 272px;
  min-height: 100vh;
  box-shadow: 18px 0 40px -32px rgba(15,23,42,.55);
  display: flex;
  flex-direction: column;
}
.sidebar-shell { position: relative; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
}
.app-sidebar .brand {
  color: #fff;
  font-weight: 800;
  padding: .3rem .65rem 1.1rem;
  font-size: 1.12rem;
  display: flex;
  align-items: center;
  gap: .7rem;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #171717;
  box-shadow: 0 12px 24px -16px rgba(215,174,42,.75);
}
.app-sidebar .nav-section { color: rgba(255,255,255,.48); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; padding: 1rem .75rem .45rem; font-weight: 800; }
.app-sidebar .nav-link {
  color: rgba(255,255,255,.78);
  padding: .72rem .8rem;
  border-left: 3px solid transparent;
  border-radius: 10px;
  display: flex; align-items: center; gap: .65rem;
  transition: background .18s ease, color .18s ease, transform .18s ease, border-color .18s ease;
  margin-bottom: .18rem;
  font-weight: 650;
}
.app-sidebar .nav-link i { width: 1.25rem; text-align: center; font-size: 1.05rem; }
.app-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); transform: translateX(2px); }
.app-sidebar .nav-link.active {
  color: #fff;
  background: rgba(215,174,42,.18);
  border-left-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(215,174,42,.16);
}
.nav-badge {
  margin-left: auto;
  min-width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #171717;
  font-size: .72rem;
  font-weight: 800;
}
.sidebar-spacer { flex: 1; min-height: 1rem; }
.app-main { background: var(--bg); padding: 1.65rem; min-width: 0; }
.app-page-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--bg);
  padding-block: .25rem .85rem;
}
.section-title { color: var(--secondary); font-weight: 800; }

@media (max-width: 991.98px) {
  html,
  body {
    min-height: 100%;
    height: auto;
  }

  .app-shell {
    min-height: 100dvh;
    display: block;
  }

  .app-main {
    min-height: 100dvh;
    padding: .85rem .85rem 1.25rem;
  }

  .app-page-header {
    margin: -.85rem -.85rem 1rem;
    padding: .8rem .85rem .65rem;
    box-shadow: 0 10px 24px -24px rgba(15, 23, 42, .45);
  }

  .app-page-header .section-title {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .app-page-header .btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .app-main > .bg-white,
  .app-main [class*="rounded-4"] {
    max-width: 100%;
  }

  .app-main .table {
    min-width: 640px;
  }

  .app-main .table-responsive,
  .app-main .bg-white:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-spacer {
    flex: 0 0 .75rem;
    min-height: .75rem;
  }

  .app-sidebar .nav-section.mt-3 {
    margin-top: .75rem !important;
    padding-top: .75rem;
    border-top: 1px solid rgba(255,255,255,.12);
  }

  .app-sidebar form .nav-link {
    background: rgba(239,68,68,.12) !important;
    color: #fecaca !important;
    border: 1px solid rgba(248,113,113,.24) !important;
    border-left: 3px solid rgba(248,113,113,.8) !important;
    justify-content: flex-start;
  }
}

/* Stat card */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card:hover { transform: translateY(-3px); border-color: rgba(215,174,42,.35); }
.stat-card .icon {
  width: 44px; height: 44px; border-radius: 10px;
  display:flex; align-items:center; justify-content:center;
  background: var(--brand-50); color: var(--brand);
  font-size: 1.2rem;
}
.stat-card .value { font-size: 1.7rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: .85rem; }

.card {
  border-color: rgba(226, 232, 240, .95);
}

.table > :not(caption) > * > * {
  padding-top: .9rem;
  padding-bottom: .9rem;
}

.progress {
  background-color: #e9ecf5;
  overflow: hidden;
}

.progress-bar,
.bg-primary {
  background-color: var(--brand) !important;
}

.text-primary {
  color: #9b7817 !important;
}

.btn-primary {
  --bs-btn-bg: var(--secondary);
  --bs-btn-border-color: var(--secondary);
  --bs-btn-hover-bg: var(--secondary-700);
  --bs-btn-hover-border-color: var(--secondary-700);
  --bs-btn-focus-shadow-rgb: 45,48,115;
}

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

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fbfcff;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.25s ease-in-out infinite;
}

.skeleton-line { height: .85rem; }
.skeleton-title { height: 1.35rem; }

@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-up {
  animation: fade-up .28s ease both;
}

.sidebar-enter { transition: transform .22s ease; }
.sidebar-enter-start { transform: translateX(-100%); }
.sidebar-enter-end { transform: translateX(0); }

/* Auth */
.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(820px 420px at 15% -10%, rgba(215,174,42,.24), transparent 62%),
    linear-gradient(135deg, #f8fafc 0%, #eef0ff 100%);
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.auth-panel {
  width: min(100%, 460px);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: 1rem;
  text-decoration: none;
  color: var(--secondary);
  font-weight: 800;
}
.auth-card {
  background: #fff;
  border: 1px solid rgba(226,232,240,.95);
  border-radius: 18px;
  box-shadow: 0 24px 70px -42px rgba(15,23,42,.55);
  padding: clamp(1.35rem, 4vw, 2rem);
}
.auth-card label,
.auth-card .form-label {
  font-weight: 700;
  color: var(--secondary);
}
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
  border-radius: 12px;
  border-color: #dbe1ea;
  min-height: 46px;
}
.auth-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(215,174,42,.18);
}
.auth-card button[type="submit"],
.auth-card .inline-flex.items-center {
  border-radius: 12px;
}
.auth-card button[type="submit"] {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
  color: #fff !important;
  min-height: 44px;
}
.auth-card button[type="submit"]:hover {
  background: var(--secondary-700) !important;
}

/* Lesson player */
.lesson-shell { display: grid; grid-template-columns: 1fr 340px; min-height: 100vh; }
@media (max-width: 991.98px) { .lesson-shell { grid-template-columns: 1fr; } }
.video-frame {
  aspect-ratio: 16/9;
  background: #0f172a;
  color: #fff;
  display:flex; align-items:center; justify-content:center;
  font-size: 3rem;
}
.lesson-sidebar {
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  max-height: 100vh;
}
.lesson-sidebar .lesson-item {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .65rem;
  cursor: pointer;
}
.lesson-sidebar .lesson-item:hover { background: var(--bg); }
.lesson-sidebar .lesson-item.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.lesson-sidebar .chapter-title {
  background: #f1f5f9;
  padding: .65rem 1rem;
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 3rem 0 1.5rem;
}
.site-footer h6 { color: #fff; font-weight: 700; margin-bottom: 1rem; }
.site-footer a { color: #cbd5e1; text-decoration: none; display:block; padding: .25rem 0; }
.site-footer a:hover { color: #fff; }

/* Certificate */
.certificate {
  background: #fff;
  border: 12px double var(--brand);
  padding: 3rem;
  text-align: center;
  position: relative;
  font-family: 'Georgia', serif;
}
.certificate h1 { font-size: 2.5rem; letter-spacing: .1em; color: var(--brand); }
.certificate .name { font-size: 2rem; font-weight: 700; border-bottom: 2px solid var(--ink); display:inline-block; padding: 0 2rem 4px; margin: 1rem 0; }

/* RTL */
html[dir="rtl"] .app-shell { grid-template-columns: 1fr 260px; }
html[dir="rtl"] .app-sidebar .nav-link { border-left: none; border-right: 3px solid transparent; }
html[dir="rtl"] .app-sidebar .nav-link.active { border-right-color: var(--brand); }
html[dir="rtl"] .lesson-sidebar { border-left: 0; border-right: 1px solid var(--border); }

/* Dark mode */
body.dark {
  --ink: #e7edf7;
  --muted: #a8b4c7;
  --bg: #09111f;
  --border: #263449;
  --brand-50: rgba(215, 174, 42, .15);
  background: #09111f;
  color: #e7edf7;
}

body.dark .app-main,
body.dark .app-page-header {
  background: #09111f;
  color: #e7edf7;
}

body.dark .navbar,
body.dark .card,
body.dark .modal-content,
body.dark .dropdown-menu,
body.dark .course-card,
body.dark .stat-card,
body.dark .category-tile,
body.dark .auth-card,
body.dark .lesson-sidebar,
body.dark .phase-content,
body.dark .accordion-item,
body.dark .list-group-item {
  background: #121c2f !important;
  border-color: #263449 !important;
  color: #e7edf7 !important;
}

body.dark .bg-white,
body.dark .bg-light,
body.dark .bg-light-subtle,
body.dark .table-light,
body.dark .modal-header,
body.dark .modal-footer,
body.dark .dropdown-item:hover,
body.dark .dropdown-item:focus,
body.dark .empty-state,
body.dark .search-pill {
  background: #17243a !important;
  color: #e7edf7 !important;
  border-color: #263449 !important;
}

body.dark .navbar .nav-link,
body.dark .navbar-brand-logo,
body.dark .dropdown-item,
body.dark .section-title,
body.dark .phase-title,
body.dark .lesson-title,
body.dark .fw-bold,
body.dark .fw-semibold,
body.dark h1,
body.dark h2,
body.dark h3,
body.dark h4,
body.dark h5,
body.dark h6 {
  color: #f6f8fc !important;
}

body.dark .navbar .nav-link.active,
body.dark .navbar .nav-link:hover,
body.dark .text-brand,
body.dark .phase-day {
  color: #f2cc55 !important;
}

body.dark .text-dark,
body.dark .text-body,
body.dark .text-black {
  color: #e7edf7 !important;
}

body.dark .text-muted,
body.dark .text-secondary,
body.dark .small,
body.dark small {
  color: #a8b4c7 !important;
}

body.dark .border,
body.dark .border-light,
body.dark .border-top,
body.dark .border-bottom,
body.dark .border-start,
body.dark .border-end,
body.dark hr {
  border-color: #263449 !important;
}

body.dark .table {
  --bs-table-bg: transparent;
  --bs-table-color: #e7edf7;
  --bs-table-border-color: #263449;
  --bs-table-striped-bg: #111d31;
  --bs-table-striped-color: #e7edf7;
  --bs-table-hover-bg: #1b2a43;
  --bs-table-hover-color: #f6f8fc;
  color: #e7edf7;
}

body.dark .table > :not(caption) > * > * {
  background-color: var(--bs-table-bg);
  border-color: #263449;
  color: #e7edf7;
}

body.dark .table thead th,
body.dark .table th {
  background: #17243a;
  color: #f6f8fc;
}

body.dark .form-control,
body.dark .form-select,
body.dark .form-check-input,
body.dark textarea,
body.dark input {
  background-color: #0d1728 !important;
  border-color: #334760 !important;
  color: #e7edf7 !important;
}

body.dark .form-control:focus,
body.dark .form-select:focus,
body.dark .form-check-input:focus {
  border-color: #d7ae2a !important;
  box-shadow: 0 0 0 .2rem rgba(215, 174, 42, .18) !important;
}

body.dark .form-control::placeholder,
body.dark input::placeholder,
body.dark textarea::placeholder {
  color: #728299 !important;
}

body.dark .form-check-input:checked {
  background-color: #d7ae2a !important;
  border-color: #d7ae2a !important;
}

body.dark .btn-light,
body.dark .btn-outline-secondary {
  background: #17243a;
  border-color: #334760;
  color: #e7edf7;
}

body.dark .btn-light:hover,
body.dark .btn-outline-secondary:hover {
  background: #21314d;
  color: #fff;
}

body.dark .btn-outline-brand {
  border-color: #d7ae2a;
  color: #f2cc55;
}

body.dark .btn-outline-brand:hover,
body.dark .btn-brand {
  background: #d7ae2a;
  border-color: #d7ae2a;
  color: #151515;
}

body.dark .badge.bg-light,
body.dark .text-bg-light,
body.dark .badge-brand {
  background: #24344f !important;
  border: 1px solid #334760;
  color: #f2cc55 !important;
}

body.dark .alert-info {
  background: #0d2a42;
  border-color: #1d587e;
  color: #b7e5ff;
}

body.dark .alert-warning {
  background: #3a2a09;
  border-color: #7a5b16;
  color: #fde68a;
}

body.dark .alert-danger {
  background: #3a1117;
  border-color: #84202b;
  color: #fecdd3;
}

body.dark .alert-success {
  background: #0e3025;
  border-color: #1f7a55;
  color: #bbf7d0;
}

body.dark .pagination .page-link {
  background: #121c2f;
  border-color: #263449;
  color: #e7edf7;
}

body.dark .pagination .page-item.active .page-link {
  background: #d7ae2a;
  border-color: #d7ae2a;
  color: #151515;
}

body.dark .lesson-sidebar .chapter-title {
  background: #1b2a43;
  color: #c8d2e1;
}

body.dark .roadmap-pro-container .phase-content,
body.dark .roadmap-step .phase-content {
  background: #121c2f !important;
  border-color: #334760 !important;
  color: #e7edf7 !important;
}

body.dark .roadmap-pro-container .active .phase-content,
body.dark .roadmap-step.active .phase-content {
  background: #272612 !important;
  border-color: #d7ae2a !important;
}

body.dark .roadmap-pro-container .planned .phase-content,
body.dark .roadmap-step.planned .phase-content,
body.dark .roadmap-step.locked .phase-content {
  background: #1a2438 !important;
  opacity: .82;
}

/* Util */
.divider-dot { color: var(--muted); margin: 0 .35rem; }
.section-title { font-weight: 800; letter-spacing: -0.01em; }
.bg-soft { background: var(--bg); }
