/* OER Frontend - Component Styles
 * Reusable UI components
 */

/* ============================================
   Page Header
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 24px;
}

.page-header-content {
  flex: 1;
  min-width: 0;
}

.page-header-content .text-muted {
  margin: 8px 0 0 44px;
  font-size: 14px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ============================================
   Search Box
   ============================================ */
.search-section {
  max-width: 800px;
  margin: 0 auto var(--spacing-2xl);
}

.search-form {
  background-color: var(--color-surface);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.search-type-toggle {
  display: flex;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.search-type-toggle label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}

.search-type-toggle input[type="radio"] {
  accent-color: var(--color-primary);
}

.search-input-group {
  display: flex;
  gap: var(--spacing-md);
}

.search-input-group .form-control {
  flex: 1;
}

/* ============================================
   School Cards
   ============================================ */
.school-card {
  background-color: var(--color-surface);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.school-card:hover {
  box-shadow: var(--shadow-md);
}

.school-card h3 {
  margin-bottom: var(--spacing-sm);
}

.school-card h3 a {
  color: var(--color-text);
}

.school-card h3 a:hover {
  color: var(--color-primary);
}

.school-card-code {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-family: monospace;
  margin-bottom: var(--spacing-sm);
}

.school-card-address {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.school-card-grade {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: var(--radius);
  margin-bottom: var(--spacing-md);
}

.school-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--spacing-lg);
}

/* ============================================
   Resource Search Form
   ============================================ */
.resource-search-form {
  background-color: var(--color-surface);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.resource-search-form .search-row {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-md);
}

.resource-search-form .search-row .form-group {
  min-width: 180px;
  margin-bottom: 0;
}

.resource-search-form .form-group.flex-grow {
  flex: 1;
  min-width: 250px;
}

.resource-search-form .search-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

/* ============================================
   Result Cards
   ============================================ */
.results-section {
  margin-top: var(--spacing-2xl);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.results-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.result-card {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-md);
  transition: box-shadow var(--transition);
}

.result-card:hover {
  box-shadow: var(--shadow-md);
}

.result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background-color: var(--color-background);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.result-icon .material-icons {
  font-size: 24px;
  color: var(--color-primary);
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-content h3 {
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-lg);
}

.result-content h3 a {
  color: var(--color-text);
}

.result-content h3 a:hover {
  color: var(--color-primary);
}

.result-path {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
  word-break: break-all;
}

.result-description {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.result-meta span {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.result-tags {
  margin-top: var(--spacing-sm);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  justify-content: center;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-xl);
  padding: var(--spacing-lg) 0;
}

.pagination .btn {
  min-width: 40px;
}

.pagination-ellipsis {
  padding: 0 var(--spacing-sm);
  color: var(--color-text-muted);
}

.pagination-info {
  margin-left: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ============================================
   Modal
   ============================================ */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition);
}

.modal-backdrop.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background-color: var(--color-background);
  color: var(--color-text);
}

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  background-color: var(--color-background);
}

.modal-lg {
  max-width: 700px;
}

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

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.hiding {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-icon {
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-xs);
}

.toast-message {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
}

.toast-close:hover {
  color: var(--color-text);
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-info .toast-icon { color: var(--color-primary); }

/* ============================================
   File List Table
   ============================================ */
.file-table-container {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.file-table {
  width: 100%;
}

.file-table th {
  background-color: var(--color-background);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}

.file-table td {
  vertical-align: middle;
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--color-background);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.file-icon .material-icons {
  font-size: 18px;
}

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

.file-name:hover {
  color: var(--color-primary);
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.file-table .actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
}

/* File type icon colors */
.file-icon-pdf { color: #dc2626; }
.file-icon-doc { color: #2563eb; }
.file-icon-xls { color: #16a34a; }
.file-icon-ppt { color: #ea580c; }
.file-icon-img { color: #9333ea; }
.file-icon-video { color: #0891b2; }
.file-icon-audio { color: #d97706; }
.file-icon-zip { color: #64748b; }
.file-icon-default { color: #64748b; }

/* ============================================
   Repo Layout
   ============================================ */
.repo-layout {
  display: flex;
  gap: 24px;
  margin-top: 24px;
}

.repo-sidebar {
  width: 600px !important;
  min-width: 600px !important;
  flex-shrink: 0;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.sidebar-header .btn-icon {
  color: #111827;
  background: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-header .btn-icon:hover {
  color: #2563eb;
  background: #dbeafe;
}

.sidebar-header .btn-icon:active {
  color: #1d4ed8;
  background: #bfdbfe;
  transform: scale(0.9);
}

#folder-tree {
  max-height: calc(100vh - 250px);
  overflow: auto;
}

#folder-tree .folder-tree {
  min-width: max-content;
}

.repo-content {
  flex: 1;
  min-width: 0;
}

/* ============================================
   File Detail Panel - Slide-in Overlay
   ============================================ */
.repo-detail {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex !important;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s ease, visibility 0.3s ease;
  visibility: visible;
}

.repo-detail.hidden {
  display: flex !important;
  transform: translateX(100%) !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* File Detail Panel Header */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  flex-shrink: 0;
}

.detail-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.detail-header .btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-header .btn-icon:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* File Detail Content */
#file-detail-content {
  padding: 32px 24px;
  overflow-y: auto;
  flex: 1;
}

/* File Icon - Large centered icon */
.detail-file-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.detail-file-icon .material-icons {
  font-size: 48px;
  color: #6b7280;
}

/* File icon color variants */
.detail-file-icon.icon-pdf {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}
.detail-file-icon.icon-pdf .material-icons {
  color: #dc2626;
}

.detail-file-icon.icon-doc,
.detail-file-icon.icon-docx {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}
.detail-file-icon.icon-doc .material-icons,
.detail-file-icon.icon-docx .material-icons {
  color: #2563eb;
}

.detail-file-icon.icon-xls,
.detail-file-icon.icon-xlsx {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}
.detail-file-icon.icon-xls .material-icons,
.detail-file-icon.icon-xlsx .material-icons {
  color: #16a34a;
}

.detail-file-icon.icon-ppt,
.detail-file-icon.icon-pptx {
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
}
.detail-file-icon.icon-ppt .material-icons,
.detail-file-icon.icon-pptx .material-icons {
  color: #ea580c;
}

.detail-file-icon.icon-image {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}
.detail-file-icon.icon-image .material-icons {
  color: #7c3aed;
}

.detail-file-icon.icon-video {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}
.detail-file-icon.icon-video .material-icons {
  color: #db2777;
}

.detail-file-icon.icon-audio {
  background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%);
}
.detail-file-icon.icon-audio .material-icons {
  color: #0d9488;
}

/* File Name */
.detail-file-name {
  margin: 0 0 32px 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
}

/* File Details List */
.detail-list {
  margin: 0 0 32px 0;
  padding: 0;
  list-style: none;
}

.detail-list dt {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-list dd {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #111827;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.detail-list dd:last-child {
  margin-bottom: 0;
}

/* Tags in detail panel */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tags .tag {
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
}

/* Action Buttons */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
  margin-top: auto;
}

.detail-actions .btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-actions .btn .material-icons {
  font-size: 20px;
}

.detail-actions .btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.detail-actions .btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-2px);
}

.detail-actions .btn-secondary {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
}

.detail-actions .btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

/* Backdrop overlay when panel is open */
.repo-detail-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 1;
  transition: opacity 0.3s ease;
  display: block !important;
}

.repo-detail-backdrop.hidden {
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Folder Header & Details */
.folder-header {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.folder-info {
  padding: 16px 20px;
  background: #f9fafb;
}

.folder-info h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
}

.folder-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.folder-tags .tag {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.folder-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.folder-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.folder-name-row h2 {
  margin: 0;
}

.folder-name-row .btn-icon {
  color: #111827;
  background: #fff;
  flex-shrink: 0;
  border: none;
}

.folder-name-row .btn-icon:hover {
  color: #2563eb;
  background: #dbeafe;
}

.folder-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
}

.folder-detail-item .material-icons {
  font-size: 16px;
  color: #9ca3af;
}

.folder-detail-item code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #6b7280;
}

.folder-detail-item.copyable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background-color 0.15s ease;
}

.folder-detail-item.copyable:hover {
  background-color: #f3f4f6;
}

.folder-detail-item .copy-hint {
  font-size: 14px;
  color: transparent;
  transition: color 0.15s ease;
  margin-left: auto;
}

.folder-detail-item.copyable:hover .copy-hint {
  color: #9ca3af;
}

.folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  align-items: center;
  min-height: 0;
}

.folder-actions:empty {
  display: none;
}

.folder-actions .btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.folder-actions .btn-icon:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.folder-actions .btn-icon.is-favourite {
  background: #fef3c7;
  border-color: #f59e0b;
}

.folder-actions .btn-icon.is-favourite .material-icons {
  color: #f59e0b;
}

.folder-actions .btn-icon.is-favourite:hover {
  background: #fde68a;
  border-color: #d97706;
}

.folder-actions .btn-icon .material-icons {
  font-size: 16px;
  color: #6b7280;
}

.folder-actions .btn.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  gap: 4px;
}

.folder-actions .btn.btn-sm .material-icons {
  font-size: 14px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header h3 {
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.sidebar-content {
  overflow-y: auto;
  padding: var(--spacing-sm);
  flex: 1;
}

.repo-main {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-height: 400px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.panel-header h2 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.folder-description {
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.panel-content {
  padding: var(--spacing-lg);
}

/* ============================================
   Grafts Section
   ============================================ */
.grafts-section {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-xl);
  border-top: 1px solid var(--color-border);
}

.grafts-section h3 {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-base);
  margin-bottom: var(--spacing-lg);
}

.graft-item {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.graft-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.graft-path {
  font-weight: 500;
}

.graft-school {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.graft-tree {
  max-height: 200px;
  overflow-y: auto;
  padding: var(--spacing-sm);
  background-color: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: var(--spacing-md);
}

/* ============================================
   Dashboard Cards
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-lg);
}

.dashboard-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.dashboard-card:hover {
  box-shadow: var(--shadow-md);
}

.dashboard-card-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.dashboard-card-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

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

.dashboard-card-body {
  padding: var(--spacing-lg);
}

.dashboard-card-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--color-background);
  border-top: 1px solid var(--color-border);
}

/* Stats in dashboard */
.stat-row {
  display: flex;
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--color-primary);
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* ============================================
   Profile Page
   ============================================ */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xl);
  padding: var(--spacing-xl);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-xl);
}

.profile-avatar {
  width: 100px;
  height: 100px;
  background-color: var(--color-primary-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-3xl);
  font-weight: 600;
  color: var(--color-primary);
}

.profile-info h1 {
  margin-bottom: var(--spacing-xs);
}

.profile-info p {
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* ============================================
   Favourites
   ============================================ */
.favourite-card {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-md);
}

.favourite-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background-color: var(--color-warning-light);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.favourite-icon .material-icons {
  color: var(--color-warning);
}

.favourite-content {
  flex: 1;
  min-width: 0;
}

.favourite-content h4 {
  margin-bottom: var(--spacing-xs);
}

.favourite-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

.favourite-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: flex-start;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0;
}

.tab {
  padding: 8px 18px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tab:hover {
  color: var(--color-text);
  background: var(--color-background);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ============================================
   Favourites Grid & Cards
   ============================================ */
.favourites-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.favourite-card {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  align-items: flex-start;
  transition: box-shadow var(--transition);
}

.favourite-card:hover {
  box-shadow: var(--shadow-md);
}

.favourite-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--color-background);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.favourite-card-icon .material-icons {
  font-size: 22px;
  color: var(--color-primary);
}

.favourite-card-content {
  flex: 1;
  min-width: 0;
}

.favourite-card-content h4 {
  margin: 0 0 4px 0;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.favourite-card-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0 0 4px 0;
}

.favourite-card-school {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin: 0 0 4px 0;
}

.favourite-card-date {
  margin: 0;
}

.favourite-card-actions {
  display: flex;
  gap: var(--spacing-xs);
  flex-shrink: 0;
  align-items: center;
}

/* ============================================
   Upload Progress
   ============================================ */
.upload-progress {
  margin-top: var(--spacing-lg);
}

.upload-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-sm);
}

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

.upload-percentage {
  color: var(--color-text-muted);
}

/* ============================================
   File Preview Modal
   ============================================ */
.preview-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-modal-backdrop.open {
  display: flex;
}

.preview-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.preview-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 16px;
  color: #111827;
  min-width: 0;
}

.preview-modal-title .material-icons {
  font-size: 24px;
  color: #6b7280;
  flex-shrink: 0;
}

.preview-modal-title span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.preview-modal-actions .btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.preview-modal-actions .btn-icon:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.preview-modal-actions .btn-icon .material-icons {
  font-size: 20px;
  color: #374151;
}

.preview-modal-content {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f2937;
  min-height: 400px;
}

/* Loading state */
.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #9ca3af;
}

.preview-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #374151;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Error state */
.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #ef4444;
  text-align: center;
  padding: 40px;
}

.preview-error .material-icons {
  font-size: 48px;
}

.preview-error p {
  color: #9ca3af;
}

/* Image preview */
.preview-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 20px;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Video preview */
.preview-video-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 20px;
}

.preview-video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 4px;
  background: #000;
}

/* Audio preview */
.preview-audio-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  width: 100%;
  padding: 60px 20px;
}

.preview-audio-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(59, 130, 246, 0.4);
}

.preview-audio-icon .material-icons {
  font-size: 56px;
  color: #fff;
}

.preview-audio {
  width: 100%;
  max-width: 500px;
}

/* PDF preview */
.preview-pdf-container {
  width: 100%;
  height: 100%;
}

.preview-pdf {
  width: 100%;
  height: 70vh;
  border: none;
  background: #fff;
}

/* Text/Code preview */
.preview-text-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #1e1e1e;
}

.preview-text {
  margin: 0;
  padding: 20px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-wrap: break-word;
  tab-size: 2;
}

.preview-text code {
  font-family: inherit;
}

/* Unsupported file type */
.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #9ca3af;
  text-align: center;
  padding: 60px 20px;
}

.preview-unsupported .material-icons {
  font-size: 64px;
  opacity: 0.5;
}

.preview-unsupported p {
  font-size: 16px;
}

/* ============================================
   Effective Permissions List
   ============================================ */
.permission-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.permission-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.permission-group-header .material-icons {
  font-size: 20px;
  color: #6b7280;
}

.permission-group-header .fiscal-code {
  font-weight: 400;
  font-size: 12px;
  color: #9ca3af;
  font-family: monospace;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: #374151;
}

.permission-item .material-icons {
  font-size: 16px;
  color: #9ca3af;
}

.permission-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 9999px;
  background: #f3f4f6;
  color: #6b7280;
  margin-left: auto;
  white-space: nowrap;
}

.permission-badge.inherited {
  background: #eff6ff;
  color: #2563eb;
}

.permission-badge.direct {
  background: #f0fdf4;
  color: #16a34a;
}

.permission-badge.admin {
  background: #fef3c7;
  color: #d97706;
  font-weight: 600;
}

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

.spin {
  animation: spin 1s linear infinite;
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  padding: 4px 0;
  font-size: 14px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  color: #374151;
  transition: background 0.12s ease;
}

.context-menu-item:hover {
  background: #f3f4f6;
}

.context-menu-item .material-icons {
  font-size: 18px;
  color: #6b7280;
}

.context-menu-item.disabled {
  color: #9ca3af;
  pointer-events: none;
}

.context-menu-item.disabled .material-icons {
  color: #d1d5db;
}

.context-menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .preview-modal-backdrop {
    padding: 0;
  }

  .preview-modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .preview-modal-header {
    padding: 12px 16px;
  }

  .preview-modal-title {
    font-size: 14px;
  }

  .preview-modal-actions .btn-icon {
    width: 36px;
    height: 36px;
  }

  .preview-image {
    max-height: 60vh;
  }

  .preview-video {
    max-height: 50vh;
  }

  .preview-pdf {
    height: 60vh;
  }

  .preview-audio-icon {
    width: 80px;
    height: 80px;
  }

  .preview-audio-icon .material-icons {
    font-size: 40px;
  }
}

/* ============================================================
   GDPR / Demo safeguards
   ============================================================ */

/* Top-of-page demo notice (normal flow, above the navbar) */
.demo-banner {
  background: linear-gradient(90deg, #b45309 0%, #d97706 100%);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.demo-banner-inner {
  max-width: var(--container-max-width, 1200px);
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.demo-banner .material-icons {
  font-size: 20px;
  flex-shrink: 0;
}

.demo-banner-text strong {
  margin-right: 6px;
}

.demo-banner a {
  color: #fff;
  text-decoration: underline;
  margin-left: 6px;
  white-space: nowrap;
}

/* GDPR links in the footer */
.gdpr-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

.gdpr-footer-links a {
  color: #475569;
  text-decoration: none;
}

.gdpr-footer-links a:hover {
  text-decoration: underline;
}

.gdpr-footer-links .gdpr-sep {
  color: #cbd5e1;
}

.gdpr-footer-note {
  color: #94a3b8;
}

/* Bottom cookie / privacy consent banner */
.gdpr-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}

.gdpr-consent-inner {
  max-width: var(--container-max-width, 1200px);
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.gdpr-consent-text {
  flex: 1 1 320px;
  min-width: 240px;
}

.gdpr-consent-text strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.gdpr-consent-text p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
}

.gdpr-consent-text a {
  color: #93c5fd;
  text-decoration: underline;
}

.gdpr-consent-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* GDPR warning box reused inside upload / edit modals and pages */
.gdpr-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.gdpr-warning .material-icons {
  font-size: 20px;
  flex-shrink: 0;
  color: #d97706;
}

@media (max-width: 640px) {
  .gdpr-consent-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .gdpr-consent-actions {
    justify-content: flex-end;
  }
}

/* Legal / informational pages (privacy, terms) */
.legal-page {
  max-width: 820px;
  margin: 32px auto 64px;
}

.legal-page h1 {
  margin-bottom: 8px;
}

.legal-updated {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 24px;
}

.legal-page h2 {
  margin-top: 32px;
  margin-bottom: 12px;
  font-size: 20px;
}

.legal-page p,
.legal-page li {
  line-height: 1.65;
  color: #334155;
}

.legal-page ul {
  padding-left: 22px;
  margin: 12px 0;
}

.legal-page .gdpr-warning {
  margin-top: 24px;
}

.legal-lead {
  font-size: 17px;
  color: #475569;
}
