
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700;800&family=Nunito+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --muted: #666;
  --card: #f3f3f3;
  --line: #d9d9d9;
  --accent: #000;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #fcfdfd;
  border-right: 1px solid #dfe1e4;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: width 0.3s ease, margin-left 0.3s ease;
  position: relative;
}

.sidebar.collapsed {
  width: 0;
  margin-left: -240px;
  overflow: hidden;
  padding: 0;
}
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 800; position: relative; color: #041628; }
.logo { font-size: 1.5rem; }
.logo-svg { height: 50px; width: 155px; object-fit: contain; }
.brand-text { line-height: 1.1; flex: 1; }

/* Sidebar Toggle Button (inside sidebar) */
.sidebar-toggle-btn {
  background: none;
  border: 1px solid #dfe1e4;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
  color: #041628;
  margin-left: auto;
}

.sidebar-toggle-btn:hover {
  background: #dfe1e4;
  border-color: #041628;
}

/* Floating Toggle Button (when sidebar is collapsed) */
.floating-sidebar-toggle {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1000;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.floating-sidebar-toggle:hover {
  background: var(--line);
  border-color: var(--text);
}
.nav-item {
  display: block;
  padding: .6rem .8rem;
  margin: .1rem 0;
  text-decoration: none;
  color: #041628;
  border-radius: .6rem;
  border: 1px solid transparent;
}
.nav-item:hover, .nav-item.active {
  background: #dfe1e4;
  border-color: #041628;
}

.nav-icon {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

.spacer { flex: 1; }

.actions-header {
  text-align: right;
}

.all-courses-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 32px;
  line-height: 32px;
  color: #041628;
  margin: 0;
}

/* Figma-style content section */
.figma-content-section {
}

.figma-input-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.add-course-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.figma-add-course-label {
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 300;
  font-size: 12px;
  line-height: 16px;
  color: #041628;
  margin: 0;
  text-align: left;
}

/* Figma-style input controls */
.input-controls {
  display: flex;
  gap: 2rem;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.add-course-form {
  margin: 0;
  flex: 0 0 auto;
}

.search-form {
  margin: 0;
  flex: 0 0 auto;
  margin-left: auto;
}

.input-with-icon {
  position: relative;
  display: inline-block;
}

.figma-input {
  background: #fcfdfd;
  border: 1px solid #0c747b;
  border-radius: 4px;
  padding: 8px 40px 8px 16px;
  width: 300px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: #45464a;
  outline: none;
}

.search-input {
  width: 250px;
}

/* Remove browser default search input clear button */
.figma-input[type="search"]::-webkit-search-cancel-button,
.figma-input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.figma-input::placeholder {
  color: #45464a;
}

.plus-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #0c747b;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  color: #ffffff !important;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: #45464a;
  pointer-events: none;
  display: block;
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: #45464a;
  text-decoration: none;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.search-clear:hover {
  background-color: rgba(69, 70, 74, 0.1);
}

.content {
  padding: 2rem;
  position: relative;
  transition: margin-left 0.3s ease;
  background: #ffffff;
}

.content.sidebar-collapsed {
  margin-left: -240px;
}

.main-sidebar-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.main-sidebar-toggle:hover {
  background: #333;
  transform: scale(1.05);
}

.main-sidebar-toggle.sidebar-visible {
  left: 250px;
}
.page-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 40px;
  line-height: 48px;
  color: #041628;
  margin: 0 0 1rem;
}

.card {
  background: var(--bg);
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.card-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
}
.toolbar { display: flex; gap: .5rem; align-items: center; }
.add-course { display: flex; gap: .5rem; margin-top: .5rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  border: 1.5px solid var(--text);
  background: #fff;
  color: var(--text);
  padding: .6rem .7rem;
  border-radius: .6rem;
  outline: none;
}
input:focus { box-shadow: 0 0 0 3px #00000022; }
.input { width: 18rem; }
.search { width: 16rem; }
.btn {
  border: 2px solid var(--text);
  background: var(--text);
  color: #fff;
  padding: .6rem .9rem;
  border-radius: .6rem;
  cursor: pointer;
  font-weight: 700;
}
.btn:hover { filter: brightness(0.9); }
.btn.secondary { background: #fff; color: var(--text); }

.table { margin-top: 1rem; }
.row {
  display: grid;
  grid-template-columns: 2fr 0.5fr 0.5fr 0.5fr 0.8fr 1fr;
  gap: .5rem;
  padding: 12px 8px;
  border: 1px solid #d6d7db;
  background: #fcfdfd;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 500;
  font-size: 18px;
  line-height: 22px;
  color: #041628;
}

.row:not(.head) {
  border-top: none;
}
.row.head {
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 22px;
  color: #041628;
  background: #dfe1e4;
  border-top: none;
  border-bottom: 1px solid #001a2b;
  border-radius: 4px 4px 0 0;
  padding: 12px 8px;
}
.course { display: grid; grid-template-columns: 36px 1fr; gap: .7rem; align-items: center; }
.book { font-size: 1.2rem; }
.course-title { font-weight: 700; }
.course-sub { font-size: .85rem; color: var(--muted); }

.auth-card {
  max-width: 420px;
  margin: 4rem auto;
  padding: 1.5rem;
  border: 1.5px solid var(--text);
  border-radius: 1rem;
}
.form { display: grid; gap: .8rem; }
.muted { color: var(--muted); }

.flash-region { margin-bottom: 1rem; }
.flash { padding: .6rem .8rem; border-radius: .6rem; border: 1px solid var(--text); }
.flash.ok { background: #e8ffe8; }
.flash.error { background: #ffe8e8; }

/* Course Detail Page */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--line);
}
.tab {
  display: block;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 600;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.tab:hover {
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  margin: -0.5rem 0 2rem;
  font-size: 1.1rem;
}

/* Chatbot Form */
.chatbot-form, .kb-form {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1.5rem;
  margin: 1rem 0 2rem 0;
  background: var(--card);
  position: relative;
  z-index: 10;
}

.form-row {
  margin-bottom: 1rem;
}

.creativity-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.creativity-options {
  display: flex;
  gap: 1rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  margin: 0;
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
}

.toggle-label {
  font-weight: 600;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--line);
  border-radius: 24px;
  transition: .4s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}

input:checked + .toggle-slider {
  background-color: var(--text);
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

.toggle-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

.select {
  border: 1.5px solid var(--text);
  background: #fff;
  color: var(--text);
  padding: .6rem .7rem;
  border-radius: .6rem;
  outline: none;
  width: 100%;
  max-width: 300px;
}

.file-input {
  border: 1.5px solid var(--text);
  background: #fff;
  color: var(--text);
  padding: .6rem .7rem;
  border-radius: .6rem;
  outline: none;
  width: 100%;
  max-width: 400px;
}

.file-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.3rem 0 0;
}

/* Chatbot Cards */
.chatbots-list, .knowledge-bases-list {
  margin-top: 1.5rem;
}

.chatbot-card, .kb-card {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: white;
}

.chatbot-info, .kb-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chatbot-info h3, .kb-info h3 {
  margin: 0;
  color: var(--text);
}

.chatbot-details {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
}

.badge.reasoning {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.badge.standard {
  background: var(--card);
  color: var(--muted);
}

.badge.creativity-deterministic {
  background: #fff3e0;
  color: #ef6c00;
  border-color: #ffcc02;
}

.badge.creativity-balanced {
  background: #f3e5f5;
  color: #7b1fa2;
  border-color: #ce93d8;
}

.badge.creativity-creative {
  background: #e8f5e8;
  color: #2e7d32;
  border-color: #a5d6a7;
}

.badge.kb {
  background: #fff8e1;
  color: #f57f17;
  border-color: #fff176;
}

.badge.creator {
  background: #e8eaf6;
  color: #3f51b5;
  border-color: #9fa8da;
}

.badge.archived {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #d1d5db;
}

.archived-card {
  opacity: 0.75;
  background: #fafafa;
  border-color: #e5e7eb;
}

.archived-card:hover {
  opacity: 0.9;
}

.btn-icon-card.restore {
  background: #10b981;
  color: white;
}

.btn-icon-card.restore:hover {
  background: #059669;
}

.back-link {
  margin-top: 2rem;
}

/* Document Cards */
.documents-list {
  margin-top: 1.5rem;
}

.document-card {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: white;
}

.document-info h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.document-preview {
  background: var(--card);
  padding: 1rem;
  border-radius: 0.5rem;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: hidden;
}

.document-actions {
  margin-top: 1rem;
}

.document-full-text {
  margin-top: 1rem;
  background: var(--card);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}

.document-full-text pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Course title link styling */
.course-title-link {
  text-decoration: none;
  color: inherit;
}

.course-title-link:hover .course-title {
  color: var(--accent);
  text-decoration: underline;
}

/* Chatbot Actions */
.chatbot-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.chatbot-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.btn.small {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.btn.danger {
  background: #dc3545;
  border-color: #dc3545;
  color: white;
}

.btn.danger:hover {
  background: #c82333;
  border-color: #bd2130;
}

/* Edit Form Styling */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Danger Zone */
.danger-zone {
  border-color: #dc3545;
  margin-top: 2rem;
}

.danger-zone .card-header h2 {
  color: #dc3545;
}

.danger-content {
  padding: 1rem;
  background: #fff5f5;
  border-radius: 0.5rem;
  margin-top: 1rem;
}

.danger-content p {
  margin: 0 0 1rem;
  color: #666;
}

/* Knowledge Base Actions */
.kb-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.kb-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.kb-actions .btn {
  margin: 0;
}

/* Knowledge Base Manager Layout */
.kb-manager {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 140px);
  min-height: 500px;
  max-height: calc(100vh - 140px);
}

.kb-sidebar {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.kb-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.kb-create {
  padding: 0.8rem;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
  flex-shrink: 0;
}

.kb-create h3 {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.compact-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.input.small, .file-input.small {
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  width: 100%;
}

.btn.small {
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  width: 100%;
}

.btn.tiny {
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.file-input.tiny {
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
}

.file-explorer {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}

.kb-folder {
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem 0.7rem 1rem;
  font-weight: 600;
  background: white;
  font-size: 0.9rem;
  position: relative;
}

.folder-header:hover {
  background: #f8f8f8;
}

.kb-folder.expanded .folder-header {
  background: #f0f0f0;
}

.kb-header-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.folder-header:hover .kb-header-actions {
  opacity: 1;
}

.folder-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  cursor: pointer;
}

.folder-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.folder-name {
  flex: 1;
}

.doc-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: normal;
  margin-left: 0.5rem;
}

.folder-content {
  background: #fafafa;
  border-left: 3px solid var(--line);
  margin-left: 1rem;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  min-height: 40px;
}

.file-item.selected {
  background: #e3f2fd;
  border-left: 3px solid #1976d2;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  flex: 1;
}

.file-link:hover {
  color: #1976d2;
}

.file-icon {
  font-size: 0.9rem;
}

.file-name {
  font-size: 0.9rem;
}

.file-delete {
  margin-left: auto;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.9rem;
}

.btn-icon.edit {
  color: #1976d2;
}

.btn-icon.edit:hover {
  background: #e3f2fd;
}

.btn-icon.delete {
  color: #dc3545;
}

.btn-icon.delete:hover {
  background: #fff5f5;
}

.btn-icon.danger {
  color: #dc3545;
}

.btn-icon.danger:hover {
  background: #fff5f5;
}

.add-files {
  padding: 0.6rem 1rem;
  border-top: 1px solid #e0e0e0;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kb-actions-mini {
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 1rem 0.7rem;
  background: white;
  border-bottom: 1px solid #f0f0f0;
}

.no-kbs {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* Main Editor Pane */
.kb-main {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#document-save-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.header-left h3 {
  margin: 0;
  font-size: 1.1rem;
}

.header-right {
  display: flex;
  align-items: center;
}

.file-info {
  color: var(--muted);
  font-size: 0.85rem;
}

.document-viewer {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

.document-viewer pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
}

.document-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.text-editor {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 1rem;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  min-height: 0;
  width: 100%;
  background: white;
}

.text-editor:focus {
  box-shadow: 0 0 0 3px #00000022;
}

.editor-form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.8rem;
  flex-shrink: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.save-hint {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.empty-selection {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 3rem;
}

.empty-selection h3 {
  margin: 0 0 1rem;
  color: var(--text);
}

.empty-selection p {
  margin: 0.5rem 0;
  max-width: 400px;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Knowledge Base Selector */
.kb-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.kb-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 1rem;
  background: #fafafa;
}

.kb-available, .kb-selected {
  display: flex;
  flex-direction: column;
}

.kb-available h4, .kb-selected h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.kb-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
}

.kb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  font-size: 0.9rem;
}

.kb-item.selected {
  background: #e3f2fd;
  border-color: #1976d2;
}

.kb-name {
  flex: 1;
  margin-right: 0.5rem;
}

.btn-add, .btn-remove {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
}

.btn-add {
  color: #2e7d32;
  border-color: #2e7d32;
}

.btn-add:hover {
  background: #e8f5e8;
}

.btn-remove {
  color: #d32f2f;
  border-color: #d32f2f;
}

.btn-remove:hover {
  background: #ffebee;
}

.no-kbs-msg, .no-selection {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
  margin: 0;
}

/* Course Actions */
.course-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: flex-end;
}

.btn-icon.edit {
  color: #1976d2;
}

.btn-icon.edit:hover {
  background: #e3f2fd;
}

.btn-icon.duplicate {
  color: #9c27b0;
}

.btn-icon.duplicate:hover {
  background: #f3e5f5;
}

/* Edit Course Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: white;
  margin: 15% auto;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  width: 400px;
  max-width: 90%;
}

.modal-header {
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* Add Chatbot Card */
.add-chatbot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--line);
  border-radius: 0.8rem;
  margin: 1rem 0;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.2s ease;
}

.add-chatbot-card:hover {
  border-color: var(--text);
  background: #f0f0f0;
}

.add-icon {
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.add-text {
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
}

.add-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  text-align: center;
  line-height: 1.3;
}

/* Form Actions for Chatbot Form */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Add Knowledge Base Card */
.add-kb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--line);
  border-radius: 0.8rem;
  margin: 1rem 0;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.2s ease;
}

.add-kb-card:hover {
  border-color: var(--text);
  background: #f0f0f0;
}

/* Chatbot Simple Cards */
.chatbots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.chatbot-simple-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1.2rem;
  transition: all 0.2s ease;
}

.chatbot-simple-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-color: #ccc;
}

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.chatbot-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.chatbot-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
  color: var(--text);
}

.chatbot-card-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.btn-icon-card {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  transition: background 0.2s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-card.edit {
  color: #1976d2;
}

.btn-icon-card.edit:hover {
  background: #e3f2fd;
}

.btn-icon-card.danger {
  color: #d32f2f;
}

.btn-icon-card.danger:hover {
  background: #ffebee;
}

.chatbot-properties {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.property-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.property-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
  min-width: 70px;
}

.kb-badges {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.chatbot-meta {
  border-top: 1px solid #f0f0f0;
  padding-top: 0.8rem;
  margin-top: auto;
}

.created-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.no-chatbots {
  text-align: center;
  padding: 3rem;
  grid-column: 1 / -1;
}

/* ---- Enrollment Manager Styles ---- */

.add-student-card,
.bulk-enrollment-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px dashed var(--line);
  border-radius: 0.8rem;
  margin: 1rem 0;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.2s ease;
}

.add-student-card:hover,
.bulk-enrollment-card:hover {
  border-color: var(--text);
  background: #f0f0f0;
}

.bulk-enrollment-card .add-icon {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.student-form,
.bulk-form {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1.5rem;
  margin: 1rem 0;
}

.students-section {
  margin-top: 2rem;
}

.students-header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.students-header h3 {
  margin: 0;
  color: var(--text);
}

.students-table {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
}

.table-header {
  display: grid;
  grid-template-columns: 120px 1fr 120px 120px;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.student-row {
  display: grid;
  grid-template-columns: 120px 1fr 120px 120px;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.student-row:last-child {
  border-bottom: none;
}

.student-row:hover {
  background: #f8f9fa;
}

.col-username,
.col-email,
.col-password,
.col-enrolled,
.col-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.student-username {
  font-weight: 600;
  color: var(--text);
  background: #e3f2fd;
  padding: 0.3rem 0.6rem;
  border-radius: 0.3rem;
  font-size: 0.9rem;
}

.student-email {
  color: var(--text);
  font-size: 0.9rem;
}

.password-display {
  font-family: 'Courier New', monospace;
  background: #f5f5f5;
  padding: 0.3rem 0.6rem;
  border-radius: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.date-display {
  font-size: 0.85rem;
  color: var(--muted);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edit-form-row {
  display: flex;
  align-items: center;
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

.edit-form .input.small {
  flex: 1;
  min-width: 200px;
}

.edit-form .btn.small {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.col-actions {
  justify-content: flex-end;
}

.no-students {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

.no-students h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* Form styling for enrollment */
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 100px;
}

.textarea:focus {
  outline: none;
  border-color: var(--text);
}

.file-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: white;
  font-size: 0.9rem;
}

.file-input:focus {
  outline: none;
  border-color: var(--text);
}

/* ---- Chat Interface Styles ---- */

.chat-container {
  display: flex;
  height: calc(100vh - 2rem);
  max-height: 800px;
  background: white;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  overflow: hidden;
}

.chat-sidebar {
  width: 300px;
  background: #f8f9fa;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, margin-left 0.3s ease;
}


.chat-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: white;
}

.course-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.course-icon {
  font-size: 1.5rem;
}

.course-details h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.course-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.new-chat-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chatbot-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  background: white;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-new-chat:hover:not(:disabled) {
  background: #333;
}

.btn-new-chat:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-history-header h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-item-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

.chat-item {
  display: block;
  flex: 1;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.chat-item:hover {
  background: #f0f0f0;
  border-color: var(--text);
}

.chat-item.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.chat-delete-form {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.chat-delete-btn {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  opacity: 1;
  transition: all 0.2s ease;
  color: #d32f2f;
}

.chat-delete-btn:hover {
  background: rgba(211, 47, 47, 0.1);
  transform: scale(1.1);
}

.chat-item.active ~ .chat-delete-form .chat-delete-btn {
  color: white;
  opacity: 0.7;
}

.chat-item.active ~ .chat-delete-form .chat-delete-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

.chat-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  opacity: 0.7;
}

.no-chats {
  text-align: center;
  padding: 2rem 1rem;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: white;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  position: relative;
}


.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.compact-chat-header {
  padding: 0.5rem 1rem 0.5rem 3.5rem;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.chatbot-model-select {
  width: 100%;
  max-width: 400px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  font-size: 0.9rem;
  background: white;
  color: var(--text);
}

.chatbot-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar {
  font-size: 2rem;
}

.chatbot-details h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.chatbot-description {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.chat-messages {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: white;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  border-bottom: 1px solid #f0f0f0;
  background: white;
}

.message:hover .message-copy-btn {
  opacity: 1;
}

/* User messages on the right side of center */
.message.user {
  background: white;
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.message.user .message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message.user .message-text {
  text-align: right;
}

.message.user .message-time {
  text-align: right;
}

/* Assistant messages on the left side of center */
.message.assistant {
  justify-content: flex-start;
}

.message.assistant .message-content {
  flex: 1;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: transparent;
  margin-top: 2px;
}

.user-avatar {
  color: #6b7280;
}

.bot-avatar {
  color: #0c747b;
}

.message-content {
  flex: 1;
  max-width: 900px;
  position: relative;
}

.message-text {
  padding: 0;
  border-radius: 0;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  color: #1f2937;
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: transparent;
}

.message.user .message-text {
  background: transparent;
  color: #1f2937;
}

.message.assistant .message-text {
  background: transparent;
  color: #1f2937;
}

/* Message Copy Button - Under message next to timestamp */
.message-copy-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Nunito Sans', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  margin-left: 8px;
}

.message-copy-btn:hover {
  background: #f3f4f6;
  color: #6b7280;
}

.message-copy-btn:active {
  transform: scale(0.95);
}

.message-copy-btn.copied {
  color: #059669;
}

.message-copy-btn .copy-icon {
  font-size: 12px;
}

.message-copy-btn .copy-text {
  font-size: 12px;
}

.message-footer {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
  gap: 4px;
}

.message.user .message-footer {
  justify-content: flex-end;
}

.message.assistant .message-footer {
  justify-content: flex-start;
}

.message-time {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 400;
}

.message-text.loading {
  font-style: italic;
  color: var(--muted);
}

.loading-dots {
  display: inline-block;
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60% {
    content: '...';
  }
  80%, 100% {
    content: '.';
  }
}

/* Alternative approach using CSS content animation */
.loading-dots::after {
  content: '';
  animation: loadingDotsContent 1.5s infinite;
}

@keyframes loadingDotsContent {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 80% {
    content: '...';
  }
  100% {
    content: '';
  }
}

.welcome-message {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  justify-content: center;
}

.welcome-avatar {
  font-size: 3rem;
}

.welcome-content h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.welcome-content p {
  margin: 0;
  color: var(--muted);
}

.chat-input-container {
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: #f8f9fa;
}

.chat-input-form {
  max-width: 100%;
}

.input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.75rem;
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 120px;
  min-height: 20px;
}

.send-button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--text);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-button:hover {
  background: #333;
  transform: scale(1.05);
}

.send-icon {
  font-size: 1rem;
}

.chat-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.welcome-content h2 {
  margin: 0 0 1rem 0;
  color: var(--text);
}

.welcome-text {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.available-chatbots h3 {
  margin: 0 0 1rem 0;
  color: var(--text);
  font-size: 1.1rem;
}

.chatbot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.chatbot-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #f8f9fa;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.chatbot-card .chatbot-icon {
  font-size: 1.5rem;
}

.chatbot-card h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.chatbot-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Chat Courses Grid ---- */

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
}

.course-chat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1.5rem;
  transition: all 0.2s ease;
}

.course-chat-card:hover {
  border-color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.course-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.course-chat-card .course-icon {
  font-size: 1.5rem;
}

.course-name {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.chatbots-preview {
  margin-bottom: 1.5rem;
}

.chatbot-count {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.chatbot-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chatbot-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 0.5rem;
}

.chatbot-preview .chatbot-icon {
  font-size: 1rem;
}

.chatbot-name {
  font-size: 0.9rem;
  color: var(--text);
}

.chatbot-preview.more {
  justify-content: center;
  font-style: italic;
  color: var(--muted);
}

.card-actions {
  margin-top: auto;
}

.btn.full-width {
  width: 100%;
  text-align: center;
}

.btn.primary {
  background: var(--text);
  color: white;
}

.btn.primary:hover {
  background: #333;
}

.no-courses {
  padding: 3rem;
}

.empty-state {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  margin: 0 0 1rem 0;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 2rem;
  color: var(--muted);
}

/* Markdown Content Styling */
.message-text h1, .message-text h2, .message-text h3, .message-text h4, .message-text h5, .message-text h6 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
}

.message-text h1 { font-size: 1.5rem; }
.message-text h2 { font-size: 1.3rem; }
.message-text h3 { font-size: 1.1rem; }
.message-text h4, .message-text h5, .message-text h6 { font-size: 1rem; }

.message-text p {
  margin: 0.75em 0;
  line-height: 1.6;
}

.message-text p:first-child {
  margin-top: 0;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text ul, .message-text ol {
  margin: 0.75em 0;
  padding-left: 1.5rem;
}

.message-text li {
  margin: 0.25rem 0;
  line-height: 1.6;
}

.message-text blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--line);
  background: var(--card);
  font-style: italic;
}

.message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.message-text th, .message-text td {
  border: 1px solid var(--line);
  padding: 0.5rem;
  text-align: left;
}

.message-text th {
  background: var(--card);
  font-weight: 600;
}

.message-text hr {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--line);
}

/* Inline code styling */
.message-text code {
  background: var(--card);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  border: 1px solid var(--line);
}

/* Code block styling */
.message-text pre {
  background: #1e1e1e;
  color: #f8f8f2;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--line);
  position: relative;
}

.message-text pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Syntax highlighting styles */
.highlight {
  background: #1e1e1e;
  border-radius: 0.5rem;
  overflow-x: auto;
}

.highlight pre {
  background: none;
  margin: 0;
  padding: 1rem;
}

/* Copy button for code blocks */
.message-text pre:hover::after {
  content: "📋";
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.message-text pre:hover::after:hover {
  opacity: 1;
}

/* LaTeX Math Styling */
.message-text .katex-display {
  margin: 1rem 0;
  text-align: center;
}

.message-text .katex {
  font-size: 1.1em;
}

.message-text .katex-display .katex {
  font-size: 1.2em;
}

/* Ensure LaTeX doesn't break layout */
.message-text .katex-html {
  overflow-x: auto;
  overflow-y: hidden;
}

/* Error styling for LaTeX */
.message-text .katex-error {
  color: #cc0000;
  background: rgba(204, 0, 0, 0.1);
  padding: 0.2em 0.4em;
  border-radius: 0.25em;
  font-family: monospace;
  font-size: 0.9em;
}

/* Streaming cursor animation */
.streaming-cursor {
  animation: blink 1s infinite;
  font-weight: bold;
  color: var(--text);
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* Enhanced streaming and UI components */
.chat-notification {
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  display: none;
  border-left: 4px solid;
}

.chat-notification.info {
  background: #e3f2fd;
  color: #1565c0;
  border-left-color: #2196f3;
}

.chat-notification.warning {
  background: #fff3e0;
  color: #ef6c00;
  border-left-color: #ff9800;
}

.chat-notification.error {
  background: #ffebee;
  color: #d32f2f;
  border-left-color: #f44336;
}

/* Error chip styling */
.error-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #ffebee;
  border: 1px solid #f44336;
  border-radius: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.error-chip .error-icon {
  font-size: 1rem;
}

.error-chip .retry-button {
  background: #f44336;
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.error-chip .retry-button:hover {
  background: #d32f2f;
}

/* Reasoning content styling */
.reasoning-content {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.reasoning-header {
  margin-bottom: 0.5rem;
}

.reasoning-toggle {
  background: none;
  border: 1px solid var(--line);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.reasoning-toggle:hover {
  background: var(--card);
  color: var(--text);
}

.reasoning-text {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.reasoning-text.hidden {
  display: none !important;
}

.reasoning-content .reasoning-text:not(.hidden) {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Code block enhancements */
.code-block-container {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  background: white;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.code-language {
  color: var(--muted);
  font-weight: 500;
}

.copy-button {
  background: none;
  border: 1px solid var(--line);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s;
}

.copy-button:hover {
  background: var(--card);
  border-color: var(--text);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.copy-button.copied {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.copy-button:active {
  transform: translateY(0);
}

.code-block-container pre {
  margin: 0;
  padding: 1rem !important;
  background: #2d2d2d !important;
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  border-radius: 0 0 0.5rem 0.5rem;
}

.code-block-container code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  font-size: inherit;
}
}

/* Message Search Styles */
.message-search-container {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.message-search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  background: #f8f9fa;
  transition: all 0.2s ease;
}

.message-search-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-search-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.clear-search-btn:hover {
  background: var(--line);
  color: var(--text);
}

.search-results-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.search-nav-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  margin-left: 0.25rem;
  transition: all 0.2s ease;
}

.search-nav-btn:hover:not(:disabled) {
  background: var(--card);
}

.search-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Accessibility - Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip Links */
.skip-links {
  position: absolute;
  top: -40px;
  left: 6px;
  z-index: 1000;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  color: white;
  background: #000;
  padding: 0.5rem 1rem;
  text-decoration: none;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  z-index: 1001;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 6px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .search-highlight {
    border: 2px solid currentColor;
  }
  
  .search-highlight.active {
    border: 3px solid #000;
  }
  
  .copy-button:focus,
  .search-nav-btn:focus,
  .message-search-input:focus {
    outline: 3px solid #000;
    outline-offset: 2px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .copy-button,
  .search-nav-btn,
  .message-search-input,
  .search-highlight {
    transition: none;
  }
  
  .search-highlight.active {
    animation: none;
  }
}

/* Focus Management */
.chat-messages:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.message:focus-within {
  background-color: rgba(37, 99, 235, 0.05);
}

/* Improved focus indicators */
.copy-button:focus-visible,
.search-nav-btn:focus-visible,
.clear-search-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Search highlight styles */
.search-highlight {
  background: #fff3cd;
  color: #856404;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-weight: 500;
}

.search-highlight.active {
  background: #ffeaa7;
  color: #2d3436;
  box-shadow: 0 0 0 2px #fdcb6e;
}

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
  /* Chat Layout */
  .chat-container {
    flex-direction: column;
    height: 100vh;
  }
  
  .chat-sidebar {
    max-width: 100%;
    height: auto;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--line);
  }
  
  .chat-main {
    flex: 1;
    order: 1;
    min-height: 0;
  }
  
  /* Search Container */
  .message-search-container {
    padding: 0.5rem;
  }
  
  .search-input-wrapper {
    gap: 0.25rem;
  }
  
  .message-search-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }
  
  .search-results-info {
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }
  
  .search-nav-btn {
    padding: 0.5rem;
    min-width: 44px; /* Touch target size */
    min-height: 44px;
  }
  
  /* Messages */
  .chat-messages {
    padding: 0.5rem;
  }
  
  .message {
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  
  .message-avatar {
    align-self: flex-start;
    margin-bottom: 0.5rem;
  }
  
  .message-content {
    margin-left: 0;
  }
  
  /* Code blocks */
  .code-block-container {
    margin: 0.75rem 0;
  }
  
  .code-block-header {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .copy-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  .code-block-container pre {
    padding: 0.75rem !important;
    font-size: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Message Input */
  .chat-input-container {
    padding: 0.75rem;
  }
  
  .message-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 1rem;
    min-height: 44px;
  }
  
  .send-button {
    min-width: 52px;
    min-height: 52px;
    padding: 0;
  }
  
  /* Reasoning Content */
  .reasoning-content {
    margin-top: 0.5rem;
    padding: 0.5rem;
  }
  
  .reasoning-toggle {
    padding: 0.5rem 0.75rem;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.9rem;
  }
  
  .reasoning-text {
    font-size: 0.8rem;
    max-height: 150px;
  }
  
  /* Message Actions */
  .message-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }
  
  .retry-button,
  .continue-button {
    padding: 0.5rem 1rem;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.9rem;
  }
  
  /* Floating Button */
  .new-response-button {
    bottom: 90px; /* Above mobile input area */
    right: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Stop Button */
  .stop-streaming-button {
    padding: 0.5rem 1rem;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.9rem;
  }
}

/* Save Status Indicators */
.save-status-container {
  margin: 1rem 0;
  animation: slideInDown 0.3s ease-out;
}

.save-status-card {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.save-status-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.save-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.save-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.save-status-info {
  flex: 1;
  min-width: 0;
}

.save-status-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.save-status-filename {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-status-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 120px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s ease-in-out infinite;
}

.progress-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  min-width: 35px;
  text-align: right;
}

.save-status-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.3s ease;
  opacity: 0.5;
}

.step-item.active {
  opacity: 1;
  background: rgba(37, 99, 235, 0.1);
  transform: translateX(4px);
}

.step-item.completed {
  opacity: 0.7;
  background: rgba(16, 185, 129, 0.1);
}

.step-item.completed .step-icon {
  filter: grayscale(1);
}

.step-icon {
  font-size: 1.1rem;
  min-width: 20px;
  text-align: center;
}

.step-text {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

/* Enhanced Flash Messages */
.flash-enhanced {
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.flash-enhanced::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: currentColor;
}

.flash-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.1rem 0;
}

.flash-icon {
  font-size: 1.2rem;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flash-text {
  flex: 1;
  line-height: 1.5;
}

.flash-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flash-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.flash-success {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #15803d;
  border-color: #16a34a;
}

.flash-error {
  background: linear-gradient(135deg, #fef2f2, #fecaca);
  color: #dc2626;
  border-color: #ef4444;
}

.flash-warning {
  background: linear-gradient(135deg, #fffbeb, #fed7aa);
  color: #d97706;
  border-color: #f59e0b;
}

.flash-info {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #2563eb;
  border-color: #3b82f6;
}

/* Button States */
.btn-saving,
.btn-uploading {
  background: var(--muted) !important;
  color: white !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

.btn-saving::after,
.btn-uploading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
  border-top: 1px solid transparent;
  border-radius: 50%;
  margin-left: 0.5rem;
  animation: spin 1s linear infinite;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes slideInDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* Mobile Responsive for Save Status */
@media (max-width: 768px) {
  .save-status-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .save-status-progress {
    justify-content: space-between;
    min-width: auto;
  }
  
  .save-status-filename {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
  
  .step-item {
    padding: 0.375rem 0.5rem;
  }
  
  .step-text {
    font-size: 0.8rem;
  }
}

/* Tablet Responsive (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .chat-sidebar {
    max-width: 280px;
  }
  
  .message-search-input {
    font-size: 15px;
  }
  
  .message-input {
    font-size: 15px;
  }
  
  .code-block-container pre {
    font-size: 0.85rem;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .copy-button,
  .search-nav-btn,
  .clear-search-btn,
  .reasoning-toggle,
  .retry-button,
  .continue-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }
  
  /* Remove hover effects on touch devices */
  .copy-button:hover,
  .search-nav-btn:hover,
  .clear-search-btn:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Better focus indicators for touch */
  .copy-button:focus,
  .search-nav-btn:focus,
  .clear-search-btn:focus {
    background: rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
  }
}

/* Landscape phone orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-container {
    flex-direction: row;
  }
  
  .chat-sidebar {
    max-width: 280px;
    height: 100vh;
    order: 1;
    border-right: 1px solid var(--line);
    border-top: none;
  }
  
  .chat-main {
    order: 2;
  }
  
  .message-search-container {
    padding: 0.5rem 0.75rem;
  }
  
  .chat-messages {
    padding: 0.5rem 0.75rem;
  }
}

/* Small mobile devices (320px - 480px) */
@media (max-width: 480px) {
  .message-search-input::placeholder {
    font-size: 14px;
  }
  
  .search-results-info {
    font-size: 0.75rem;
  }
  
  .code-language {
    font-size: 0.75rem;
  }
  
  .message-time {
    font-size: 0.75rem;
  }
  
  .reasoning-text {
    font-size: 0.75rem;
  }
  
  /* Compact message layout */
  .message {
    margin-bottom: 0.75rem;
  }
  
  .message-content {
    padding: 0.5rem;
  }
}

/* Streaming state indicators */
body.streaming .send-button {
  background: #dc3545;
  transform: scale(0.95);
}

body.streaming .send-button:hover {
  background: #c82333;
}

.streaming-indicator {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
  padding: 4px 8px;
  display: inline-block;
}

/* Enhanced loading animation */
.message-text.loading .loading-dots {
  animation: loadingDotsContent 1.5s infinite;
}

@keyframes loadingDotsContent {
  0%, 20% {
    opacity: 0.4;
  }
  40% {
    opacity: 0.8;
  }
  60%, 80% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

/* Improved message spacing */
.message + .message {
  margin-top: 1.5rem;
}

/* Auto-scroll improvements */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--card);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Mobile responsiveness for streaming UI */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 1rem);
  }
  
  .chat-sidebar {
    width: 280px;
  }
  
  .error-chip {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  
  .reasoning-content {
    padding: 0.5rem;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .streaming-cursor,
  .loading-dots,
  .send-button {
    animation: none;
  }
  
  .send-button {
    transition: none;
  }
}

/* Focus management for screen readers */
.message:focus-within {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
  border-radius: 0.5rem;
}

/* Screen reader support */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Auto-scroll and floating buttons */
/* New response button hidden - using scroll controls instead */
.new-response-button {
  display: none !important;
}

/* Stop/Cancel button styles */
/* Stop streaming button hidden - using scroll controls instead */
.stop-streaming-button {
  display: none !important;
}

/* Retry/Continue buttons */
.message-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: 8px;
}

.retry-button, .continue-button {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: #9ca3af;
  transition: all 0.2s ease;
}

.retry-button:hover, .continue-button:hover {
  background: #f3f4f6;
  color: #6b7280;
}

.retry-button:hover {
  background: #ffebee;
  border-color: #f44336;
  color: #f44336;
}

/* Knowledge Indicator Styles - Floating Overlay */
.knowledge-indicator {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  max-width: 400px;
  min-width: 180px;
  pointer-events: none;
}

.knowledge-indicator.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.knowledge-indicator.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.knowledge-indicator-content {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.2;
}

.knowledge-indicator .icon,
.knowledge-indicator .spinner {
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
}

.knowledge-indicator .spinner {
  animation: pulse 1.5s ease-in-out infinite;
}

.knowledge-indicator .message {
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status-specific styling - Subtle colors */
.knowledge-indicator.searching {
  border-color: #93c5fd;
  background: #eff6ff;
}

.knowledge-indicator.searching .message {
  color: #2563eb;
}

.knowledge-indicator.found {
  border-color: #86efac;
  background: #f0fdf4;
}

.knowledge-indicator.found .message {
  color: #16a34a;
}

.knowledge-indicator.empty {
  border-color: #fcd34d;
  background: #fefce8;
}

.knowledge-indicator.empty .message {
  color: #ca8a04;
}

.knowledge-indicator.error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.knowledge-indicator.error .message {
  color: #dc2626;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Message Sources Styles */
.message-sources {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--card);
  font-size: 0.8rem;
}

.sources-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-weight: 500;
}

.sources-icon {
  font-size: 0.9rem;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.source-chip {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--accent);
  color: white;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: default;
  transition: background-color 0.2s ease;
}

.source-chip:hover {
  background: #333;
}

/* Dark theme adjustments for sources */
@media (prefers-color-scheme: dark) {
  .message-sources {
    background: #1a1a1a;
    border-color: #333;
  }
  
  .sources-header {
    color: #ccc;
  }
  
  .source-chip {
    background: #444;
    color: #fff;
  }
  
  .source-chip:hover {
    background: #555;
  }
}

/* File Upload Progress Indicators */
.upload-progress {
  margin-top: 1rem;
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  animation: fadeIn 0.3s ease-in;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.progress-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
}

.progress-stats {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #45a049);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.current-file {
  font-size: 0.9rem;
  color: var(--text);
}

.current-file strong {
  color: var(--text);
}

.processing-status {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 4px;
  font-size: 0.85rem;
  color: #2e7d32;
  display: flex;
  align-items: center;
}

.processing-status::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid #4CAF50;
  border-top: 2px solid transparent;
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* Dark theme adjustments for progress indicators */
@media (prefers-color-scheme: dark) {
  .upload-progress {
    background: #1a1a1a;
    border-color: #333;
  }
  
  .progress-header h3 {
    color: #fff;
  }
  
  .progress-stats {
    color: #ccc;
  }
  
  .progress-bar-container {
    background: #333;
  }
  
  .current-file {
    color: #fff;
  }
  
  .current-file strong {
    color: #fff;
  }
  
  .processing-status {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.4);
    color: #81c784;
  }
}

/* Mini progress indicators for knowledge base manager */
.upload-progress-mini {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: rgba(76, 175, 80, 0.05);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 6px;
  font-size: 0.8rem;
}

.progress-header-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.processing-file {
  color: var(--text);
  font-weight: 500;
}

.progress-count {
  color: var(--muted);
  font-size: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  .upload-progress-mini {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
  }
  
  .processing-file {
    color: #fff;
  }
}

/* Simple Upload Progress */
.simple-upload-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: fadeIn 0.3s ease-in;
}

.upload-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.upload-message {
  color: var(--text);
  font-weight: 500;
}

.upload-steps {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.step {
  padding: 0.25rem 0;
  transition: opacity 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  .simple-upload-progress {
    background: #1a1a1a;
    border-color: #333;
  }
  
  .upload-message {
    color: #fff;
  }
  
  .upload-steps {
    color: #ccc;
  }
}


/* Course Access Link Section */
/* Compact Course Link */
.course-link-compact {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.course-link-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.link-icon {
  font-size: 1rem;
}

.course-link-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.course-link-input-small {
  font-family: monospace;
  background: white;
  border: 1px solid #d1d5db;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  width: 280px;
  color: #6b7280;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.2s;
}

@media (max-width: 768px) {
  .course-link-compact {
    flex-direction: column;
    align-items: stretch;
  }

  .course-link-label {
    justify-content: center;
  }

  .course-link-input-group {
    flex-direction: column;
  }

  .course-link-input-small {
    width: 100%;
  }
}

/* Role indicator */
.role-indicator {
  text-align: center;
  margin: 1rem 0;
}

.role-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-badge.role-owner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.role-badge.role-instructor {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

/* Disabled tabs */
.tab-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: var(--muted) !important;
  pointer-events: none;
  background: transparent !important;
}

.tab-disabled:hover {
  background: transparent !important;
  transform: none !important;
}


/* Published/Unpublished Badge Styles */
.badge.published {
  background: #10b981;
  color: white;
}

.badge.unpublished {
  background: #6b7280;
  color: white;
}

/* Published/Unpublished Button Styles */
.btn-icon-card.published {
  background: #10b981;
  color: white;
  border: 1px solid #10b981;
}

.btn-icon-card.published:hover {
  background: #059669;
  border-color: #059669;
}

.btn-icon-card.unpublished {
  background: #6b7280;
  color: white;
  border: 1px solid #6b7280;
}

.btn-icon-card.unpublished:hover {
  background: #4b5563;
  border-color: #4b5563;
}

