/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== CSS Custom Properties ===== */
:root,
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #1a1a2e;
  --text-secondary: #495057;
  --text-muted: #868e96;
  --border-color: #dee2e6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --accent: #e63946;
  --accent-hover: #c62828;
  --accent-light: rgba(230,57,70,0.1);
  --gold: #f4a261;
  --gold-light: rgba(244,162,97,0.1);
  --success: #2a9d8f;
  --danger: #e63946;
  --danger-hover: #c62828;
  --sidebar-bg: #f8f9fa;
  --sidebar-hover: #e9ecef;
  --sidebar-active: rgba(230,57,70,0.1);
  --card-bg: #ffffff;
  --modal-bg: #ffffff;
  --overlay-bg: rgba(0,0,0,0.4);
  --input-bg: #ffffff;
  --input-border: #ced4da;
  --toast-bg: #1a1a2e;
  --toast-text: #ffffff;
}

[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252540;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border-color: #2d2d44;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --accent: #e63946;
  --accent-hover: #ff5252;
  --accent-light: rgba(230,57,70,0.15);
  --gold: #f4a261;
  --gold-light: rgba(244,162,97,0.15);
  --success: #2a9d8f;
  --danger: #e63946;
  --danger-hover: #ff5252;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #252540;
  --sidebar-active: rgba(230,57,70,0.15);
  --card-bg: #1a1a2e;
  --modal-bg: #1a1a2e;
  --overlay-bg: rgba(0,0,0,0.6);
  --input-bg: #252540;
  --input-border: #2d2d44;
  --toast-bg: #e2e8f0;
  --toast-text: #1a1a2e;
}

/* ===== Base Styles ===== */
html {
  font-size: 14px;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

/* ===== Utilities ===== */
.hidden {
  display: none !important;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.header-icon {
  font-size: 1.4rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.2s;
}
.sidebar-toggle:hover {
  background: var(--bg-tertiary);
}

.header-center {
  flex: 1;
  max-width: 480px;
  margin: 0 1.5rem;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 2.25rem 0.5rem 2.5rem;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem;
  border-radius: 50%;
  line-height: 1;
  transition: color 0.2s;
}
.search-clear:hover {
  color: var(--text-primary);
}

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

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}
.theme-toggle:hover {
  background: var(--sidebar-hover);
}

.theme-toggle-icon {
  position: absolute;
  font-size: 1.2rem;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

[data-theme="light"] .theme-toggle-icon.sun {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}
[data-theme="light"] .theme-toggle-icon.moon {
  transform: translateY(40px) rotate(90deg);
  opacity: 0;
}
[data-theme="dark"] .theme-toggle-icon.sun {
  transform: translateY(-40px) rotate(-90deg);
  opacity: 0;
}
[data-theme="dark"] .theme-toggle-icon.moon {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}

/* ===== Layout ===== */
.layout {
  display: flex;
  height: calc(100vh - 60px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  min-width: 0;
  width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-nav {
  padding: 0.75rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

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

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-add-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.sidebar-add-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

/* ===== Sidebar Folders (Collapsible) ===== */
.sidebar-folder {
  margin-bottom: 0.15rem;
}

.sidebar-folder-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.sidebar-folder-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}
.sidebar-folder-btn.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-folder-chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sidebar-folder-chevron.open {
  transform: rotate(90deg);
}

.sidebar-folder-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.sidebar-folder-topics {
  padding-left: 1.25rem;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.sidebar-folder-topics.open {
  max-height: 500px;
}

.sidebar-topic {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.825rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.sidebar-topic:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}
.sidebar-topic.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-topic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-topic-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-topic-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.breadcrumb-item {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  transition: all 0.2s;
  font-family: inherit;
}
.breadcrumb-item:hover {
  color: var(--accent);
  background: var(--accent-light);
}
.breadcrumb-item.current {
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}
.breadcrumb-item.current:hover {
  background: none;
  color: var(--text-primary);
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.75rem;
  user-select: none;
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg-primary);
  transition: background 0.3s ease;
}

/* ===== Dashboard ===== */
.dashboard-header {
  margin-bottom: 1.5rem;
}

.dashboard-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.dashboard-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* ===== Topic Card (reused for folders and topics) ===== */
.topic-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.topic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-color);
}
.topic-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.topic-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.topic-card-name {
  font-size: 1.1rem;
  font-weight: 600;
  word-break: break-word;
}

.topic-card-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.topic-card:hover .topic-card-actions {
  opacity: 1;
}

.topic-card-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.topic-card-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.topic-card-btn.danger:hover {
  color: var(--danger);
}

.topic-card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.topic-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ===== Add Card (dashed border) ===== */
.add-topic-card {
  background: var(--bg-secondary);
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  gap: 0.5rem;
  color: var(--text-muted);
}
.add-topic-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.add-topic-card svg {
  transition: transform 0.2s;
}
.add-topic-card:hover svg {
  transform: scale(1.1);
}

.add-topic-label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== View Detail Header ===== */
.topic-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topic-detail-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topic-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.topic-detail-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topic-detail-right {
  display: flex;
  gap: 0.5rem;
}

/* ===== Stundenplan / Sequence Table ===== */
.sequence-table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.sequence-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.sequence-table thead th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.sequence-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
.sequence-table tbody tr:hover {
  background: var(--sidebar-hover);
}
.sequence-table tbody tr:nth-child(even) {
  background: var(--bg-secondary);
}
.sequence-table tbody tr:nth-child(even):hover {
  background: var(--sidebar-hover);
}

.sequence-table tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.sequence-table .col-num {
  width: 40px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
}

.sequence-table .col-title {
  font-weight: 500;
}

.sequence-table .col-date {
  white-space: nowrap;
  color: var(--text-secondary);
}

.sequence-table .col-files {
  white-space: nowrap;
  color: var(--text-muted);
}

.sequence-table .col-actions {
  width: 80px;
  text-align: right;
}

.table-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
}
.table-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.table-action-btn.danger:hover {
  color: var(--danger);
}

/* ===== Lesson Detail Info ===== */
.lesson-info {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.lesson-info-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.lesson-info-row:last-child {
  margin-bottom: 0;
}

.lesson-info-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 90px;
}

.lesson-info-value {
  color: var(--text-primary);
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

.drop-zone-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.drop-zone-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.drop-zone-input {
  display: none;
}

/* ===== File List ===== */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  transition: all 0.2s;
  cursor: pointer;
}
.file-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  font-weight: 700;
}
.file-icon.pdf {
  background: rgba(230,57,70,0.12);
  color: #e63946;
}
.file-icon.word {
  background: rgba(9,132,227,0.12);
  color: #0984e3;
}

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

.file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.file-item:hover .file-actions {
  opacity: 1;
}

.file-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.file-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.file-action-btn.danger:hover {
  color: var(--danger);
}

/* ===== Links Section ===== */
.links-section {
  margin-top: 1.5rem;
}

.links-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.links-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.link-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  transition: all 0.2s;
}
.link-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}

.link-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(9, 132, 227, 0.12);
  color: #0984e3;
}

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

.link-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.link-item:hover .link-actions {
  opacity: 1;
}

.link-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: all 0.2s;
}
.link-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.link-action-btn.danger:hover {
  color: var(--danger);
}

/* ===== File Preview ===== */
.file-preview {
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}

.file-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.file-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.file-preview-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.file-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.file-preview-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.file-preview-body {
  height: 70vh;
  min-height: 400px;
}

.file-preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-sm {
  max-width: 380px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0.75rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 6px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 0.75rem 1.5rem 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1.5rem 1.25rem;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

/* ===== Color Picker ===== */
.color-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 340px;
}

.toast.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.empty-state-text {
  font-size: 0.9rem;
  max-width: 320px;
  margin: 0 auto;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-title {
    font-size: 1rem;
  }

  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
  }
  .sidebar:not(.collapsed) {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .header-center {
    margin: 0 0.5rem;
  }

  .main {
    padding: 1rem;
  }

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

  .file-preview-body {
    height: 50vh;
    min-height: 300px;
  }

  .topic-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .sequence-table {
    font-size: 0.825rem;
  }

  .sequence-table thead th,
  .sequence-table tbody td {
    padding: 0.5rem 0.6rem;
  }
}

@media (max-width: 480px) {
  .header-title span:not(.header-icon) {
    display: none;
  }

  .header-center {
    margin: 0 0.25rem;
  }

  .search-input {
    font-size: 0.85rem;
  }
}
