/* Prevent horizontal overflow globally */
body {
  overflow-x: hidden;
  transition: all 0.2s ease;
}

img, video {
  max-width: 100%;
  height: auto;
}

/* =========================
   🧱 APP LAYOUT STRUCTURE
   ========================= */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Right side (topbar + content) */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}


/* =========================
   🧱 APP HEIGHT CONTROL
   ========================= */

.app-layout {
  height: 100vh;
}


/* Main scroll */
.main {
  height: 100vh;
  display: flex;
  flex-direction: column;
}


/* =========================
   🔝 TOPBAR
   ========================= */

.topbar {
  height: 70px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-5);

  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Left section */
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Right section */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar select {
  border-radius: 8px;
  padding: 6px 10px;
}

/* =========================
   🔝 STICKY TOPBAR
   ========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;

  height: 70px;

  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);

  border-bottom: 1px solid var(--color-border);
}

/* =========================
   📄 CONTENT
   ========================= */

/* Content scroll only */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* 🔥 ADD THIS */
}


.content {
  padding: 16px;
  background: #ffffff;
}


/* Prevent overflow issues */
.content-wrapper {
  width: 100%;
  max-width: none;
  overflow-x: hidden;
  margin: 0 auto;
}

/* =========================
   PREMIUM CONTENT AREA
   ========================= */

/* MOBILE FIX */
@media (max-width: 640px) {
  .content {
    padding: 24px;
  }
}

/* =========================
   📱 MOBILE (DEFAULT)
   ========================= */

/* When open */
.sidebar.active {
  left: 0;
}

/* Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;

  background: rgba(15,23,42,0.5);

  z-index: 1500;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

.sidebar-overlay.active {
  display: block;
}


/* =========================
   🍔 MENU BUTTON
   ========================= */

.menu-toggle {
  display: inline-flex;
  font-size: var(--text-xl);
  cursor: pointer;
}

/* Hide on desktop */
@media (min-width: 1024px) {
  .menu-toggle {
    display: none;
  }
}


/* =========================
   🔝 TOPBAR MOBILE FIX
   ========================= */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;
  cursor: pointer;

  transition: 0.2s ease;
}

.icon-btn:hover {
  background: #f1f5f9;
}

.profile-dropdown:hover .profile-menu {
  display: flex;
}

/* =========================
 MOBILE / DESKTOP CONTROL FOR TOPBAR
   ========================= */

/* MOBILE */
@media (max-width: 768px) {

  .collapse-toggle {
    display: none;
  }

  .page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }

  .currency-btn {
    display: none;
  }

}

/* DESKTOP */
@media (min-width: 769px) {

  .menu-toggle {
    display: none;
  }

}

/* =========================
 MAIN CONTENT ADJUST
   ========================= */

.main {
  transition: all 0.3s ease;
}

.main {
  min-width: 0; /* 🔥 CRITICAL FLEX FIX */
}


/* =========================
   📚 SIDEBAR (FINAL CLEAN)
   ========================= */

/* Logo */
.sidebar .logo {
  font-size: 18px;
  font-weight: 600;

  padding: 10px 12px;

  display: flex;
  align-items: center;
  gap: 8px;
}

/* Navigation */
.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Links */
.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;

  border-radius: 10px;

  font-size: 14px;
  font-weight: 500;

  color: #334155;
  
  position: relative;
  transition: all 0.2s ease;
}

/* Hover */
.sidebar .nav a:hover {
  background: rgba(37, 99, 235, 0.08);
  transform: translateX(2px);
}

.sidebar .nav a.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-primary);
}

.sidebar .nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
}

.sidebar.collapsed .nav a span {
  display: none;
}

.sidebar.collapsed .nav a:hover::after {
  content: attr(data-label);

  position: absolute;
  left: 60px;

  background: #0f172a;
  color: #fff;

  padding: 6px 10px;
  border-radius: 6px;

  font-size: 12px;
  white-space: nowrap;
}

/* Icon refinement */
.sidebar .nav a i {
  font-size: 16px;
  opacity: 0.7;
}

/* Icons */
.sidebar .nav a i {
  font-size: 18px;
  font-style: normal;
  opacity: 0.7;
}

.sidebar .nav a i {
  color: var(--color-text-muted);
}

.sidebar .nav a.active i {
  color: var(--color-primary);
}

/* Center icons */
.sidebar.collapsed .nav a {
  justify-content: center;
}

/* Logo adjust */
.sidebar.collapsed .logo {
  text-align: center;
  font-size: 18px;
}

/* Section title */
.nav-section {  
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: var(--space-4);
  padding-left: var(--space-4);
}


/* =========================
   ✨ CUSTOM SCROLLBAR
   ========================= */

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.2);
}

/* =========================
   💱 CURRENCY PANEL
   ========================= */

/* PANEL DEFAULT HIDDEN */
.currency-panel {
  position: absolute;
  top: 45px;
  right: 0;

  width: 246px;

  max-height: 70vh; /* 🔥 FIX */
  overflow-y: auto; /* 🔥 SCROLL */

  border-radius: 16px;

  background: rgba(15, 15, 25, 0.95);
  backdrop-filter: blur(18px);

  border: 1px solid rgba(255,255,255,0.05);

  box-shadow: 
    0 20px 50px rgba(0,0,0,0.35);

  opacity: 0;
  transform: translateY(10px) scale(0.95);

  pointer-events: none;

  transition: all 0.25s ease;
}

.currency-panel {
  background: rgba(15, 15, 25, 0.95);
  backdrop-filter: blur(18px);

  border-radius: 16px;

  border: 1px solid rgba(255,255,255,0.05);

  box-shadow: 
    0 20px 50px rgba(0,0,0,0.35),
    0 0 0 1px rgba(255,255,255,0.02);

  overflow: hidden;
}


/* ACTIVE STATE */
.currency-panel.active {
  right: 0;
}

/* ITEMS */
.currency-item {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 12px 16px;

  font-size: 14px;

  color: #eee;
  text-decoration: none;

  transition: all 0.2s ease;
}


/* hover */
.currency-item:hover {
  background: rgba(255,255,255,0.05);
  padding-left: 20px;
}

/* active */
.currency-item.active {
  background: linear-gradient(135deg, #4D44E1, #6C63FF);
  color: #fff;
}

/* HEADER */
.currency-header {
  padding: 14px 16px;

  font-size: 13px;
  font-weight: 600;

  color: #aaa;

  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.currency-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);

  opacity: 0;
  pointer-events: none;

  transition: 0.3s ease;
}

.currency-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}


.currency-wrapper {
  position: fixed;
  top: 110px;
  right: 20px;
  z-index: 999;
}

/* 🔥 HOVER TRIGGER */
.currency-wrapper:hover .currency-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.currency-wrapper.open .currency-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.currency-panel::-webkit-scrollbar {
  width: 6px;
}

.currency-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}

/* =========================
   💱 FLOATING CURRENCY BUTTON
   ========================= */

.currency-float {
  position: fixed;
  top: 110px;
  right: 15px;

  padding: 8px 14px;

  font-size: 13px;
  font-weight: 600;

  color: #fff;

  background: linear-gradient(135deg, #4D44E1, #6C63FF);

  border-radius: 8px; /* 🔥 less round = tag look */

  box-shadow: 0 8px 20px rgba(77, 68, 225, 0.25);

  cursor: pointer;

  display: flex;
  align-items: center;
  gap: 6px;

  transition: all 0.25s ease;

  z-index: 999;
}

/* optional icon */
.currency-float::before {
  content: "💱";
  font-size: 12px;
  opacity: 0.8;
}

.currency-float:hover {
  transform: translateY(-2px);
}

/* ============================
 💱 CURRENCY BUTTON FOR MOBILE
============================ */

@media (max-width: 768px) {
  .currency-float {
    top: 80px;
    right: 12px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

.currency-wrapper {
  padding-bottom: 10px; /* 🔥 hover bridge */
}

/* =========================
   📚 SIDEBAR (CLEAN FINAL)
   ========================= */

.sidebar {
  width: 210px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;

  background: #FCFCFC; /* ✅ solid, clean */

  border-right: 1px solid #f1f5f9;

  padding: 18px 12px;

  display: flex;
  flex-direction: column;
  gap: 10px;

  overflow-y: auto;

  transition: width 0.25s ease;
}

.main-wrapper {
  margin-left: 240px;
}

.sidebar .nav a span {
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .nav a span {
  opacity: 0;
}

/* COLLAPSED */
.sidebar.collapsed {
  width: 70px;
}

/* Hide text ONLY when collapsed */
.sidebar.collapsed .nav a span,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-section {
  display: none;
}
/* =========================
   SIDEBAR OVERLAY
   ========================= */

.sidebar-overlay {
  position: fixed;
  inset: 0;

  background: rgba(15,23,42,0.4); /* lighter */

  z-index: 1500;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* =========================
   📱 MOBILE SIDEBAR CLEAN
   ========================= */

@media (max-width: 1023px) {

  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;

    width: 240px;
    height: 100vh;

    background: #ffffff;

    z-index: 2000;

    overflow-y: auto;

    transition: left 0.3s ease;
  }

  .sidebar.active {
    left: 0;
  }

}


/* =========================
   💻 DESKTOP
   ========================= */

@media (min-width: 1024px) {

  .sidebar {
    position: static;
    left: 0;
    height: auto;
  }

  .sidebar-overlay {
    display: none !important;
  }

}

@media (max-width: 640px) {

  .sidebar .nav a.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-primary);
  }

}

/* =========================
   TOPBAR FINAL CLEAN
   ========================= */

.page-title {
  font-size: 14px;
  font-weight: 600;

  max-width: 160px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapse-toggle {
  cursor: pointer;
  font-size: 16px;
}

@media (max-width: 1023px) {
  .collapse-toggle {
    display: none;
  }
}

/* =========================
   SIDEBAR USER PROFILE
   ========================= */

.sidebar-user {
  display: flex; /* ✅ ALWAYS visible */
  align-items: center;
  gap: 12px;

  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #eef2ff;
  color: #4D44E1;

  font-weight: 600;

  flex-shrink: 0; /* 🔥 prevents oval */
}


/* SHOW ONLY ON MOBILE */
@media (max-width: 768px) {

  .sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 16px;
    margin-bottom: 10px;

    border-bottom: 1px solid #eee;
  }

  .user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;

    background: linear-gradient(135deg, #4D44E1, #22c55e);
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 600;
    font-size: 16px;
  }

  .user-info {
    display: flex;
    flex-direction: column;
  }

  .user-name {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
  }
  
  .sidebar-user {
  background: rgba(77, 68, 225, 0.03);
  border-radius: 12px;
}

  .user-welcome {
    font-size: 12px;
    color: #6b7280;
  }

  .user-email {
    font-size: 12px;
    color: #9ca3af;
  }
}

@media (max-width: 768px) {
  .sidebar.open .sidebar-user {
    display: flex;
  }

  .sidebar .logo {
    display: none;
  }
}

/* ONLY HIDE ON DESKTOP */
@media (min-width: 769px) {
  .sidebar-user {
    display: none;
  }
}

/*===========================
 HANDLE RATING
============================*/

.course-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.course-rating {
  font-size: 13px;
  margin-top: 6px;
  font-weight: 500;
}

/*=========================
Flash Message Toast CSS
==========================*/

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 260px;
    padding: 16px 18px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }

/*=========================
 PROFILE DROPDOWN CSS
==========================*/

/* PROFILE DROPDOWN */

.profile-dropdown {
  position: relative;
}

.profile-trigger {
  cursor: pointer;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: 55px;

  width: 220px;
  background: #fff;

  border: 1px solid var(--color-border);
  border-radius: 12px;

  box-shadow: 0 10px 30px rgba(0,0,0,0.08);

  padding: 10px;

  display: none;
  flex-direction: column;
  gap: 8px;

  z-index: 999;
}

.profile-menu.active {
  display: flex;
}

.profile-header {
  padding: 10px;
  border-bottom: 1px solid var(--color-border);
}

.profile-menu a {
  padding: 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: 14px;
}

.profile-menu a:hover {
  background: var(--color-surface-alt);
}

.profile-menu .danger {
  color: #dc2626;
}

.divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 0;
}

/*=========================
 REPLACE TITLE WITH LOGO CSS
==========================*/

/* VISIBILITY CONTROL */
.desktop-only {
  display: inline;
}

.mobile-logo {
  display: none;
  font-weight: 600;
  font-size: 16px;
  align-items: center;
  gap: 6px;
}

/* MOBILE */
@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .mobile-logo {
    display: flex;
  }
}


/*=========================
 ERROR 404 PAGE CSS
==========================*/

.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70vh;
}

.error-box {
  text-align: center;
  padding: 40px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

.error-icon {
  font-size: 40px;
  margin-bottom: 10px;
}


/*=========================
 RIGHT SIDEBAR LAYOUT CSS
==========================*/

.page-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 10px;
  align-items: start;
}

.page-main {
  width: 100%;
  min-width: 0;
}


.page-main,
.page-main-full {
  padding-top: 5px;
}

/* FULL WIDTH (no sidebar pages) */
.page-main-full {
  width: 100%;
}

.page-sidebar {
  position: fixed;
  top: 70px;
  right: 0;                 /* ✅ REMOVE GAP */
  width: 270px;

  height: calc(100vh - 90px);

  overflow-y: auto;

  padding: 0 10px 10px 10px;

  background: #fff;         /* optional: makes it clean edge */
  border-left: 1px solid #f1f5f9;

  box-shadow: -8px 0 25px rgba(0,0,0,0.06); /* subtle premium depth */
}

.page-sidebar {
  scroll-behavior: smooth;
}

.page-sidebar.animate {
  transform: translateX(10px);
  opacity: 0;
}

.page-sidebar.show {
  transform: translateX(0);
  opacity: 1;
}

/*=========================
 MOBILE RIGHT SIDEBAR AND PANEL
=========================*/

@media (max-width: 992px) {

  .page-sidebar {
    position: fixed;
    top: 0;
    right: -280px;   /* match width exactly */
    width: 280px;
    height: 100vh;

    background: #fff;
    z-index: 3000;

    transition: right 0.3s ease;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
  }

  .page-sidebar.active {
    right: 0;
  }

  .page-with-sidebar {
    grid-template-columns: 1fr;
  }

}
