/* ============================================
   Strivelin Learning Hub Styling
   ============================================ */

/* --- Language Visibility Rules --- */
html[data-lang="en"] .lang-ml { display: none !important; }
html[data-lang="ml"] .lang-en { display: none !important; }

/* --- Layout Container --- */
.learn-container {
  padding-top: calc(var(--nav-height) + var(--space-xl));
  padding-bottom: var(--space-4xl);
  min-height: 80vh;
}

.learn-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

/* --- Sidebar styling --- */
.learn-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: sticky;
  top: calc(var(--nav-height) + var(--space-md));
  max-height: calc(100vh - var(--nav-height) - var(--space-2xl));
  overflow-y: auto;
  scrollbar-width: thin;
}

.learn-sidebar::-webkit-scrollbar {
  width: 4px;
}

.learn-sidebar::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

.sidebar-title {
  font-size: 1.25rem;
  font-family: var(--font-heading);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--bg-glass-border);
  color: var(--text-primary);
}

.topic-group {
  margin-bottom: var(--space-md);
}

.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.topic-header:hover {
  background: var(--bg-card-hover);
}

.topic-toggle-icon {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-base);
  color: var(--text-secondary);
}

.topic-group.expanded .topic-toggle-icon {
  transform: rotate(90deg);
}

/* Chapters sublist */
.chapters-list {
  margin-top: var(--space-xs);
  padding-left: var(--space-md);
  display: none;
}

.topic-group.expanded .chapters-list {
  display: block;
}

.chapter-item {
  margin: var(--space-xs) 0;
}

.chapter-link {
  display: block;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
}

.chapter-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.chapter-item.active .chapter-link {
  color: var(--text-primary);
  font-weight: 500;
  border-left-color: var(--accent-blue);
  background: var(--bg-card-hover);
}

/* --- Main Content Area --- */
.learn-main {
  min-width: 0; /* Prevents overflow inside grid */
}

.content-header {
  margin-bottom: var(--space-xl);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.crumb-topic {
  color: var(--accent-blue);
}

#chapterTitle {
  font-size: 2.25rem;
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin-top: var(--space-xs);
}

/* --- Summary Pane Card --- */
.summary-card {
  padding: var(--space-2xl);
  border: 1px solid var(--bg-glass-border);
}

.summary-card h2, 
.summary-card h3 {
  color: var(--text-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  font-family: var(--font-heading);
}

.summary-card h2 {
  font-size: 1.5rem;
}

.summary-card p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.summary-card ul {
  list-style-type: disc;
  padding-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

.summary-card li {
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.summary-card blockquote {
  border-left: 4px solid var(--accent-blue);
  background: var(--bg-card);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.summary-card code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.9em;
  color: var(--accent-blue);
}

/* --- Empty state view --- */
.learn-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5xl) var(--space-2xl);
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.empty-title {
  font-size: 1.5rem;
  font-family: var(--font-heading);
  margin-bottom: var(--space-sm);
}

.empty-desc {
  color: var(--text-secondary);
  max-width: 400px;
}

/* --- Skeleton loaders --- */
.sidebar-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-sm);
}

.skeleton-line {
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
}

.skeleton-line.shadow {
  height: 20px;
  width: 70%;
  margin-bottom: var(--space-xs);
}

.skeleton-line.short {
  width: 50%;
}

/* --- Mobile Responsiveness --- */
.sidebar-toggle,
.mobile-toolbar {
  display: none;
}

@media (max-width: 900px) {
  .learn-layout {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  /* Sticky Mobile Toolbar (Topics + Language Badge) */
  .mobile-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: sticky;
    top: calc(var(--nav-height) + 12px);
    left: 0;
    z-index: 90;
    align-self: flex-start;
    margin-bottom: var(--space-md);
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
  }

  .sidebar-toggle.active {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px var(--accent-glow);
  }

  /* Mobile Language Badge */
  .mobile-lang-indicator {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
  }

  .mobile-lang-indicator:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    color: var(--text-primary);
  }

  .mobile-lang-indicator::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--accent-blue);
    border-radius: var(--radius-full);
  }

  /* Reverse rules to show the target language option inside the button */
  html[data-lang="en"] .mobile-lang-indicator .lang-en {
    display: none !important;
  }
  html[data-lang="en"] .mobile-lang-indicator .lang-ml {
    display: inline !important;
  }
  html[data-lang="ml"] .mobile-lang-indicator .lang-ml {
    display: none !important;
  }
  html[data-lang="ml"] .mobile-lang-indicator .lang-en {
    display: inline !important;
  }

  /* Slide-in Overlay Drawer */
  .learn-sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 290px;
    height: 100vh;
    max-height: 100vh;
    z-index: 99;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border: none;
    border-right: 1px solid var(--bg-glass-border);
    padding-top: calc(var(--nav-height) + var(--space-lg));
  }

  .learn-sidebar.open {
    left: 0;
  }
}

/* --- Mobile / Small Screen Adjustments --- */
@media (max-width: 600px) {
  .learn-container {
    padding-top: calc(var(--nav-height) + var(--space-sm));
    padding-bottom: var(--space-2xl);
  }

  #chapterTitle {
    font-size: 1.65rem;
  }

  .summary-card {
    padding: var(--space-md) !important;
    border-radius: var(--radius-md) !important;
  }

  .chapter-section-title {
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
  }

  /* Dialogue bubbles on mobile */
  .dialogue-container {
    gap: var(--space-sm) !important;
    margin: var(--space-md) 0 !important;
  }

  .bubble {
    padding: 10px 14px !important;
    font-size: 0.92rem;
    max-width: 95% !important;
    border-radius: var(--radius-md) !important;
  }

  /* Topic Cards & Grids on mobile */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-md) !important;
  }

  .topic-card {
    padding: var(--space-md) !important;
    border-radius: var(--radius-md) !important;
  }

  .topic-card-title {
    font-size: 1.1rem !important;
  }

  .topic-card-desc {
    margin-bottom: var(--space-md) !important;
    font-size: 0.85rem !important;
  }

  .search-container {
    margin-bottom: var(--space-lg) !important;
  }

  .category-section {
    margin-bottom: var(--space-xl) !important;
  }
}

/* --- Q&A Dialogue / Chat Bubble Styling --- */
.dialogue-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.bubble {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  max-width: 90%;
  line-height: 1.6;
  position: relative;
  animation: fadeIn 0.3s ease-in-out;
}

.bubble-believer {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  align-self: flex-start;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.bubble-priest {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.15);
  align-self: flex-end;
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.bubble-label {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

.bubble-believer .bubble-label {
  color: #3b82f6; /* Accent blue */
}

.bubble-priest .bubble-label {
  color: #10b981; /* Accent green/success */
}

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

/* --- Index / Table of Contents Card --- */
.index-card {
  padding: var(--space-xl);
  border: 1px solid var(--bg-glass-border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
}

.index-title {
  font-size: 1.15rem;
  font-family: var(--font-heading);
  margin-bottom: var(--space-md);
  color: var(--accent-blue);
  border-bottom: 1px solid var(--bg-glass-border);
  padding-bottom: var(--space-xs);
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-sm) var(--space-lg);
  list-style-type: none !important;
  padding-left: 0 !important;
}

.index-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  padding: var(--space-xs) 0;
  transition: color var(--transition-fast), transform var(--transition-fast);
  border-bottom: 1px dashed transparent;
}

.index-link:hover {
  color: var(--accent-blue);
  transform: translateX(4px);
}

.index-link.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-blue);
}

/* --- Chapter Sections (Stitched View) --- */
.chapter-section {
  margin-bottom: var(--space-3xl);
  scroll-margin-top: 100px; /* Offset for smooth scroll positioning */
}

.chapter-section:last-of-type {
  margin-bottom: 0;
}

.chapter-section-title {
  font-size: 1.5rem;
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  border-left: 4px solid var(--accent-blue);
  padding-left: var(--space-md);
}

/* --- Dashboard & Topic Card Grid Styling --- */
.dashboard-welcome {
  margin-bottom: var(--space-xl);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-xl);
}

.topic-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  border: 1px solid var(--bg-glass-border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-base);
  height: 100%;
}

.topic-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.topic-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.topic-card-icon {
  font-size: 2rem;
}

.topic-card-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topic-card-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  line-height: 1.4;
}

.topic-card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
  flex-grow: 1;
}

.topic-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-blue);
  border-top: 1px solid var(--bg-glass-border);
  padding-top: var(--space-md);
  margin-top: auto;
  transition: color var(--transition-fast);
}

.topic-card:hover .topic-card-footer {
  color: var(--text-primary);
}

.topic-card-footer svg {
  transition: transform var(--transition-fast);
}

.topic-card:hover .topic-card-footer svg {
  transform: translateX(4px);
}

/* --- Sidebar Active Topic view --- */
.back-to-topics-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: 1px solid var(--bg-glass-border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  margin-bottom: var(--space-lg);
  transition: all var(--transition-fast);
}

.back-to-topics-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

.sidebar-topic-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--bg-glass-border);
}

.chapters-list-active {
  list-style-type: none;
  padding-left: 0;
}

.sidebar-welcome-card {
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
}

.sidebar-welcome-card h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

/* --- Bilingual Display Rules --- */
html[data-lang="en"] .lang-ml {
  display: none !important;
}
html[data-lang="ml"] .lang-en {
  display: none !important;
}

/* Style active language dropdown items */
.theme-dropdown-menu button.active {
  color: var(--accent-blue) !important;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
}

/* --- Search Input Styling --- */
.search-container {
  position: relative;
  margin-bottom: var(--space-2xl);
  max-width: 500px;
  animation: fadeIn 0.3s ease-in-out;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--bg-glass-border);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--transition-base);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
  background: var(--bg-card-hover);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Sidebar Search */
.sidebar-search-container {
  margin-top: var(--space-md);
  margin-bottom: var(--space-lg);
  position: relative;
}

.sidebar-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-glass-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: var(--bg-card);
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* --- Copy Section Link Button --- */
.chapter-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.share-btn {
  background: none;
  border: 1px solid var(--bg-glass-border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.share-btn:hover,
.share-btn:active {
  background: var(--bg-card);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.share-btn.copied {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: #10b981;
}

.share-btn svg,
.share-btn span {
  pointer-events: none;
}

@media (max-width: 600px) {
  .chapter-section-title {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }
  .share-btn {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
}
