@import url('https://fonts.googleapis.com/css?family=Inter:wght@400;600;700&display=swap');

/* ===== Base ===== */
body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  margin: 0;
  background: #f8fbfe;
  color: #222;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

/* ===== Login page (old version, kept for safety) ===== */
.login-bg { background: #f8fbfe; }

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(14, 78, 94, 0.08);
  text-align: center;
  width: 360px;
}

.logo { width: 42px; margin-bottom: 1rem; }
.academy-title { font-size: 1.1rem; font-weight: 700; color: #008aa6; }
.welcome-title { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 .5rem; }
.subtext, .footer-text { color: #6b7a87; font-size: .97rem; }

form label { margin: .8rem 0 .25rem 0; font-weight: 600; }
form input[type="text"], form input[type="password"] {
  width: 100%; padding: .8rem; border: 1px solid #d9e1e7; border-radius: 6px;
  font-size: 1rem; margin-bottom: .6rem;
}
.login-button {
  background: #008aa6; color: #fff; border: none; border-radius: 6px;
  padding: .9rem; margin-top: 1.2rem; font-size: 1.1rem; font-weight: 600;
  width: 100%; cursor: pointer; transition: background .2s;
}
.login-button:hover { background: #01586e; }
.error-message { color: #d20e37; margin-top: .4rem; font-size: .95rem; }

/* ===== Dashboard theme tokens ===== */
.dashboard-bg {
  --bg: #f6f9fc;
  --ink: #0c1b2a;
  --muted: #5b6b7b;
  --brand: #0ea5e9;
  --chip: #e8f4fb;
  --chip-ink: #0a4c6a;
  --card: #ffffff;
  --border: #e5eaf0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ===== Mobile top bar (hamburger) ===== */
.topbar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.brand-logo { height: 28px; width: 28px; object-fit: contain; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
.icon-btn .bar {
  display: block;
  width: 18px;
  height: 2px;
  background: #0c1b2a;
  border-radius: 999px;
  margin: 2px 0;
}

/* ===== Shell (sidebar + content) ===== */
.dashboard-wrapper {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar (desktop) */
.sidebar {
  background: #0f2738;
  color: #fff;
  padding: 1.25rem 1rem;
  /* Make sticky on desktop */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.sidebar-header { display: grid; gap: .5rem; margin-bottom: 2rem; }
.sidebar-logo   { width: 44px; height: 44px; object-fit: contain; }
.sidebar-title  { font-size: 14px; opacity: .85; margin: 0; line-height: 1.4; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.sidebar-nav li {
  padding: .75rem .9rem; border-radius: 10px; cursor: pointer;
  background: transparent;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
}
.sidebar-nav li.active { background: #0ea5e9; color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3); }
.sidebar-nav li:hover:not(.active)  { background: rgba(255,255,255,.1); transform: translateX(4px); }

/* Logout Button Special Styling */
#logout-btn {
  margin-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  border-radius: 0;
  padding-top: 1.5rem;
  color: #fca5a5;
}
#logout-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #f87171;
}

/* Main content */
.dashboard-content { 
  padding: 1.5rem clamp(1rem, 2.5vw, 2rem);
  overflow-x: hidden;
  box-sizing: border-box;
}
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 1rem;
}
.header-left { flex: 1; }
.header-left h1 { margin: 0 0 .25rem 0; font-size: clamp(22px, 3vw, 30px); }
.header-left p  { margin: 0 0 1rem 0; color: var(--muted); }
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Search row (non-sticky) */
.search-row { padding: .5rem 0; margin-bottom: 0.5rem; }
.dashboard-search {
  width: 100%; 
  padding: .9rem 1rem; 
  border-radius: 12px;
  border: 1px solid var(--border); 
  background: #fff; 
  font-size: 15px;
  box-sizing: border-box;
}

/* Chips */
.chips { display: flex; gap: .5rem; margin: .9rem 0; }
.chips--wrap   { flex-wrap: wrap; }
.chips--scroll { overflow: auto; scrollbar-width: none; -ms-overflow-style: none; }
.chips--scroll::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--chip-ink);
  padding: .5rem .75rem;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active { background: var(--brand); color: #002133; border-color: var(--brand); }
.chip--sub    { background: #eef7ff; }
.hidden       { display: none; }

/* Courses grid / cards */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}
.course-card {
  grid-column: span 12;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: .9rem;
  box-sizing: border-box;
  overflow: hidden;
}
.course-thumb {
  width: 100%; height: 125px; object-fit: cover; object-position: center 25%; border-radius: 10px;
  background: #fff;
  border: 1px solid #f0f0f0;
}
.course-meta   { display: grid; gap: .35rem; }
.course-kicker { color: var(--muted); font-size: 13px; }
.course-title  { margin: 0; font-size: 18px; }
.course-desc   { margin: 0; color: var(--muted); }
.course-actions { margin-top: .25rem; display: flex; align-items: center; gap: .75rem; }
.course-type   { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem .85rem; border-radius: 10px; text-decoration: none;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
}
.btn--primary { background: var(--brand); color: #002133; border-color: var(--brand); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .topbar { 
    display: flex; 
    justify-content: space-between;
  }

  .dashboard-wrapper { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
  }
  
  .sidebar.open { transform: translateX(0); }

  .dashboard-content { 
    margin-left: 0; 
    padding: 1rem;
    padding-top: 2rem; 
  }

  /* Make header stack vertically on mobile */
  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .header-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Optimize Filters (Chips) for mobile touch */
  .chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 5px; /* space for scrollbar */
    -webkit-overflow-scrolling: touch;
    margin: 1rem -1rem; /* Full width scroll */
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .chip {
    flex: 0 0 auto; /* Don't shrink */
    padding: 0.6rem 1rem;
    height: auto;
  }

  /* Stack Card Vertical */
  .course-card { 
    grid-template-columns: 1fr; 
    gap: 0;
    overflow: hidden;
  }
  
  .course-thumb { 
    width: 100%; 
    height: 180px; 
    border-radius: 12px 12px 0 0;
    border: none;
    border-bottom: 1px solid #f0f0f0;
  }
  
  .course-meta {
    padding: 1rem;
  }
  
  .menu-toggle { cursor: pointer; }
}
.course-thumb--placeholder {
  background: #ecf1f5;
}

.course-due {
  font-size: 13px;
  margin-top: 0.25rem;
  color: #b45309; 
}

.badge {
  display: inline-flex;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 11px;
  margin-left: 0.5rem;
}

.badge--assigned {
  background: #dbeafe;
  color: #1d4ed8;
}
/* --- Extra styles for dashboard cards & badges --- */
.course-thumb--placeholder {
  background: #ecf1f5;
}

.course-due {
  font-size: 13px;
  margin-top: 0.25rem;
  color: #b45309;
}

.badge {
  display: inline-flex;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 11px;
  margin-left: 0.5rem;
}

.badge--assigned {
  background: #dbeafe;
  color: #1d4ed8;
}

/* --- Backdrop for mobile sidebar --- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 70;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* --- Mobile layout: topbar + slide-in sidebar --- */
@media (max-width: 980px) {
  .dashboard-wrapper {
    grid-template-columns: 1fr;
  }

  .dashboard-content {
    padding: 0.75rem 1rem;
    padding-top: 3.5rem;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 80;
  }

  .sidebar.open {
    transform: translateX(0);
  }
}

/* ===================================================================
   NEW LOGIN PAGE (index.html uses body.login-page etc.)
   =================================================================== */

body.login-page {
  position: relative;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #f0fbff 0, #f9fafb 40%, #eef2ff 100%);
  overflow: hidden;
}

/* Decorative skincare/product bubbles */
.login-product-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.product-orb {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.20);
}

.orb-1 { top: -40px; left: -60px; }
.orb-2 { bottom: 15%; left: 5%; width: 130px; height: 130px; }
.orb-3 { top: 8%; right: 6%; width: 210px; height: 210px; }
.orb-4 { bottom: -40px; right: 10%; width: 140px; height: 140px; }

/* Floating buzz words */
.floating-words {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.floating-words span {
  position: absolute;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(15, 118, 110, 0.35);
}

.floating-words span:nth-child(1) { top: 12%; left: 8%; }
.floating-words span:nth-child(2) { top: 70%; left: 12%; }
.floating-words span:nth-child(3) { top: 30%; left: 70%; }
.floating-words span:nth-child(4) { top: 80%; left: 60%; }
.floating-words span:nth-child(5) { top: 45%; left: 30%; }
.floating-words span:nth-child(6) { top: 22%; left: 82%; }

/* Centering wrapper for login card */
.login-shell {
  position: relative;
  z-index: 1; 
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Login card */
.login-panel {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 18px;
  padding: 2.4rem 2.1rem 2rem;
  box-shadow: 0 22px 40px rgba(15, 23, 42, 0.16);
  text-align: center;
}

/* Brand block + logo */
.login-brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.login-logo {
  width: 150px;
  max-width: 80%;
  height: auto;
  display: block;
}

.login-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #008aa6;
}

/* Headings + description */
.login-heading {
  font-size: 1.7rem;
  margin: 0.8rem 0 0.3rem;
}

.login-subtext {
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  color: #6b7280;
}

/* Form fields */
.login-form {
  text-align: left;
}

.login-label {
  display: block;
  margin: 0.6rem 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.login-input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 0.98rem;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.login-input:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
  background: #ffffff;
  transform: translateY(-1px);
}

/* Login button */
.login-btn {
  width: 100%;
  margin-top: 1.3rem;
  padding: 0.9rem;
  border-radius: 999px;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #0ea5e9, #0f766e);
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(14, 165, 233, 0.5);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.login-btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 18px 40px rgba(14, 165, 233, 0.65);
  transform: translateY(-1px);
}

/* Secondary button (Send OTP / Login with Password) */
.login-btn-secondary {
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.8rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-btn-secondary:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

.full-width {
  width: 100%;
}

/* Animations */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

.login-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 0.6rem;
  min-height: 1.2rem;
}

.otp-info {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.recaptcha-container {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  min-height: 1px;
}

/* ===== Panel Transitions ===== */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  animation: fadeInSlide 0.3s ease-out;
}

.hidden {
  display: none !important;
}

/* Error + footer */
.login-error {
  min-height: 1.1rem;
  margin-top: 0.7rem;
  font-size: 0.9rem;
  color: #dc2626;
}

.login-footer {
  margin-top: 1.6rem;
  font-size: 0.88rem;
  color: #6b7280;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .login-panel {
    padding: 2rem 1.5rem 1.8rem;
    border-radius: 16px;
  }
  .login-logo {
    width: 130px;
  }
}

/* Language filter (header right) */
.language-filter-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: #2c3e50;
}
.language-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background-color: #fff;
}

/* AI Chat Styling - Copied from ai-portal/ai.css but adapted for Dashboard */
.ai-chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 0; /* Critical for flex overflow */
}

/* Desktop layout: side by side */
.ai-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  height: 100%;
  max-width: 1600px;
  flex: 1;
  min-height: 0;
}

.ai-main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  height: 100%;
}

.ai-chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: white;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.ai-history-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 100%;
}

.ai-history-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.ai-history-header h3 { 
  margin: 0; 
  font-size: 14px; 
  font-weight: 600;
  color: #1f2937; 
}

.ai-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ai-history-item-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: #f9fafb;
  transition: all 0.2s;
}

.ai-history-item-wrapper:hover {
  background: #f3f4f6;
}

.ai-history-item {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
}

.ai-history-item:hover {
  background: #e0f2fe;
  color: #0369a1;
}

.ai-history-item.active {
  background: #0ea5e9;
  color: white;
  font-weight: 500;
}

.ai-delete-chat-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 14px;
  flex-shrink: 0;
  transition: color 0.2s;
  display: none;
}

.ai-history-item-wrapper:hover .ai-delete-chat-btn {
  display: block;
  color: #ef4444;
}

.ai-delete-chat-btn:hover {
  color: #dc2626;
}

#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background-color: white;
}

.ai-msg {
  max-width: 85%;
  padding: 1rem 1.5rem;
  line-height: 1.6;
  font-size: 14px;
  position: relative;
  word-wrap: break-word;
  border-radius: 12px;
}

.ai-msg-bot {
  align-self: flex-start;
  background-color: #f3f4f6; 
  color: #1f2937;
  border-radius: 4px 12px 12px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-msg-user {
  align-self: flex-end;
  background-color: #0ea5e9; 
  color: white;
  border-radius: 12px 4px 12px 12px;
  box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}

.ai-chat-form-container {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  background-color: #ffffff;
  flex-shrink: 0;
}

#ai-chat-form {
  display: flex;
  gap: 8px;
  position: relative;
  width: 100%;
  align-items: center;
  max-width: 100%;
  padding: 12px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.ai-mic-btn {
  background: #f3f4f6;
  border: none;
  color: #4b5563;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 16px;
}

.ai-mic-btn:hover {
  background: #e5e7eb;
  color: #1f2937;
}

.ai-mic-btn.listening {
  background: #fee2e2;
  color: #ef4444;
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#ai-chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  outline: none;
  font-size: 14px;
  transition: all 0.2s ease;
  min-height: 36px;
  font-family: inherit;
}

#ai-chat-input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ai-send-btn {
  background: #0ea5e9;
  color: white;
  border: none;
  padding: 0 1.5rem;
  height: 40px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  background: #0284c7;
  transform: translateY(-1px);
}

/* Avatar styling helper */
.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  margin-right: 12px;
  flex-shrink: 0;
}
.ai-avatar-bot { background: #e0e7ff; color: #4338ca; }
.ai-avatar-user { background: #dbeafe; color: #1e40af; }

/* Markdown content in bot messages */
.ai-msg-bot p { margin-bottom: 0.75rem; }
.ai-msg-bot p:last-child { margin-bottom: 0; }
.ai-msg-bot ul, .ai-msg-bot ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.ai-msg-bot code { background: rgba(0,0,0,0.05); padding: 2px 4px; border-radius: 4px; font-family: monospace; }
.ai-msg-bot pre { background: #1f2937; color: #f9fafb; padding: 1rem; border-radius: 8px; overflow-x: auto; margin-bottom: 0.75rem; }
.ai-msg-bot a { color: #2563eb; text-decoration: underline; }

/* Typing animation */
.typing-dots {
  display: inline-flex;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.message-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

/* Sidebar on right now, layout order changed in HTML, but flex should handle it */
.ai-history-sidebar {
  width: 240px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  order: 2; /* Explicitly order it second (right) just in case */
}

.ai-history-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-history-header h3 { margin: 0; font-size: 16px; color: #1f2937; }

.ai-new-chat-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  width: 28px; 
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
  border: none;
}

.ai-new-chat-btn:hover { 
  background: #e5e7eb; 
  color: #1f2937;
}

.ai-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.ai-empty-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: white;
  font-size: 32px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.ai-empty-state h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #111827;
}

.ai-empty-state p {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 2rem;
  max-width: 400px;
}

.ai-suggestions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 600px;
}

.ai-suggestion-chip {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  font-size: 15px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ai-suggestion-chip:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  transform: translateY(-1px);
}

/* ===== UNIFIED OTP LOGIN ===== */

.login-input-group {
  position: relative;
  margin-bottom: 1rem;
}

.recaptcha-container {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
  transform: scale(0.9);
  transform-origin: center;
}

.otp-button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.otp-action-row {
  margin-top: 1rem;
}

.full-width {
  width: 100%;
}

.otp-info {
  font-size: 0.95rem;
  color: #6b7a87;
  margin-bottom: 1rem;
  text-align: center;
  padding: 0.75rem;
  background: #f0f7fa;
  border-radius: 0.4rem;
}

.otp-input {
  text-align: center;
  font-size: 1.75rem;
  letter-spacing: 0.75rem;
  font-weight: 700;
  font-family: 'Courier New', 'Courier', monospace;
}

.login-btn-secondary {
  padding: 0.75rem 1rem;
  background: #f0f5f8;
  border: 1px solid #d0dce8;
  border-radius: 0.5rem;
  color: #6b7a87;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn-secondary:hover {
  background: #e5ecf1;
  color: #008aa6;
  border-color: #008aa6;
}

.login-btn-secondary:active {
  transform: scale(0.98);
}

.login-btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* reCAPTCHA iframe scaling */
.recaptcha-container > iframe {
  transform: scale(0.9);
  transform-origin: center;
}

.login-btn-secondary {
  background: #f0f4f8;
  color: #008aa6;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  padding: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn-secondary:hover {
  background: #e8f1f7;
  border-color: #008aa6;
}

.login-btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mobile-First Login Page */
body.login-page {
  background: linear-gradient(135deg, #0f172a 0%, #020617 100%);
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem;
}

.login-shell {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.login-panel {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  text-align: center;
  position: relative;
  overflow: hidden;
  z-index: 10;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
  .login-panel {
    padding: 1.5rem;
  }
  
  .login-heading {
    font-size: 1.5rem;
  }
  
  .login-btn, 
  .login-btn-secondary {
    padding: 0.875rem;
    font-size: 1rem;
  }

  /* Dashboard mobile fixes */
  .dashboard-content {
    padding: 0.5rem 0.5rem;
    padding-top: 2.5rem;
  }

  .dashboard-header {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .header-left h1 {
    font-size: 18px;
  }

  .header-left p {
    font-size: 12px;
    margin-bottom: 0;
  }

  .header-right {
    width: 100%;
  }

  .dashboard-search {
    font-size: 14px;
    padding: 0.6rem 0.8rem;
  }

  /* Mobile chips */
  .chips {
    margin: 0.5rem -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .chip {
    padding: 0.4rem 0.6rem;
    font-size: 11px;
  }

  /* Mobile course cards - stack with small thumb */
  .course-card {
    grid-template-columns: 80px 1fr;
    gap: 0.6rem;
    padding: 0.6rem;
    border-radius: 8px;
  }

  .course-thumb {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .course-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }

  .course-kicker {
    font-size: 11px;
  }

  .course-title {
    font-size: 13px;
    line-height: 1.2;
  }

  .course-desc {
    font-size: 11px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .course-actions {
    gap: 0.4rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
  }

  .btn {
    padding: 0.4rem 0.6rem;
    font-size: 11px;
    border-radius: 6px;
  }

  .course-type {
    font-size: 11px;
  }
}

.login-brand-block {
  margin-bottom: 2rem;
}

.login-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

.login-brand-name {
  font-weight: 700;
  color: #0f172a;
}

/* Form Styles */
.login-input {
  width: 100%;
  box-sizing: border-box; /* Crucial for preventing overflow */
  padding: 0.75rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 16px; /* Prevents auto-zoom on iOS */
  margin-bottom: 1rem;
}

/* Login Background Animation (Product Orbs) */
.login-product-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0.6;
}

.product-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}

.orb-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: #3b82f6; opacity: 0.4; }
.orb-2 { bottom: -10%; right: -10%; width: 60vw; height: 60vw; background: #6366f1; opacity: 0.3; }

/* Playlist styles (needed if external file misses them) */
.playlist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  overflow-y: auto;
  max-height: 100%;
}
.playlist-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s;
}
.playlist-item:hover { background: #f8fafc; border-color: #cbd5e1; }
.playlist-item.active { background: #f0f9ff; border-color: #0ea5e9; }
.pl-thumb { width: 80px; height: 45px; border-radius: 4px; object-fit: cover; background: #cbd5e1; }
.pl-info { flex: 1; overflow: hidden; }
.pl-title { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-meta { font-size: 0.75rem; color: #64748b; }
.playlist-empty { text-align: center; color: #94a3b8; padding: 2rem; font-style: italic; }

/* Mobile specific overrides for AI Layout */
@media (max-width: 980px) {
  .ai-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0;
    overflow: hidden;
  }
  
  .ai-main-area {
    height: 100%;
    order: 1;
    display: flex;
    flex-direction: column;
    flex: 1;
    border-radius: 0;
    border: none;
  }

  .ai-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #ai-chat-messages {
    padding: 1.5rem;
    gap: 1rem;
  }

  /* Hide history sidebar on mobile by default */
  .ai-history-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    top: 0;
  }

  /* Adjust chat bubbles for small screens */
  .ai-msg {
    max-width: 90%;
    padding: 0.75rem 1rem;
    font-size: 14px;
  }
  
  .ai-empty-state h2 { font-size: 1.25rem; }
  .ai-empty-state p { font-size: 0.9rem; }
  .ai-suggestion-chip { padding: 0.75rem 1rem; font-size: 0.85rem; }

  /* Input area adjustments for mobile */
  .ai-chat-form-container {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
  }

  #ai-chat-form {
    gap: 6px;
    padding: 8px;
  }

  #ai-chat-input {
    font-size: 16px;
    padding: 8px 10px;
    min-height: 32px;
  }

  .ai-mic-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  #panel-ai-mentor {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  /* Show the toggle button */
  #ai-history-toggle {
    display: inline-flex !important;
  }
  
  /* When toggled open, show the sidebar */
  .ai-history-sidebar.open-mobile {
    display: flex;
    background: #fff;
    border-left: none;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  @keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }

  .ai-history-header {
    padding-right: 0.5rem;
  }
}

