/* ===== Masark History Sidebar ===== */

/* Overlay backdrop */
.masark-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 44;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.masark-sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Sidebar panel */
.masark-sidebar {
  position: fixed;
  top: 85px;
  left: 0;
  width: 340px;
  height: calc(100% - 85px);
  background: #ffffff;
  z-index: 45;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  font-family: 'Inter', sans-serif;
}

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

/* Header */
.masark-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.masark-sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.masark-sidebar-header h2 {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
}

.masark-sidebar-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s;
}

.masark-sidebar-close:hover {
  background: #e5e7eb;
  color: #1f2937;
}

/* Search */
.masark-sidebar-search {
  width: 100%;
  padding: 12px 14px 12px 38px;
  background: #ffffff;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.masark-sidebar-search:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.masark-sidebar-search::placeholder {
  color: #9ca3af;
}

.masark-sidebar-search-wrap {
  position: relative;
}

.masark-sidebar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9ca3af;
  pointer-events: none;
}

/* Scrollable list */
.masark-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.masark-sidebar-list::-webkit-scrollbar {
  width: 6px;
}

.masark-sidebar-list::-webkit-scrollbar-track {
  background: transparent;
}

.masark-sidebar-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* Group label */
.masark-sidebar-group-label {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
}

/* Item */
.masark-sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f3f4f6;
}

.masark-sidebar-item:hover {
  background: #f9fafb;
}

.masark-sidebar-item:last-child {
  border-bottom: none;
}

.masark-sidebar-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.masark-sidebar-item-icon.homework {
  background: linear-gradient(135deg, #22d3ee, #34d399);
}

.masark-sidebar-item-body {
  flex: 1;
  min-width: 0;
}

.masark-sidebar-item-title {
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 4px;
}

.masark-sidebar-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #9ca3af;
}

/* Status badge */
.masark-sidebar-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.masark-sidebar-badge.completed,
.masark-sidebar-badge.published {
  background: #ecfdf5;
  color: #059669;
}

.masark-sidebar-badge.processing,
.masark-sidebar-badge.generating {
  background: #eff6ff;
  color: #2563eb;
}

.masark-sidebar-badge.draft {
  background: #f3f4f6;
  color: #6b7280;
}

.masark-sidebar-badge.error,
.masark-sidebar-badge.failed {
  background: #fef2f2;
  color: #dc2626;
}

/* Empty state */
.masark-sidebar-empty {
  text-align: center;
  padding: 48px 24px;
  color: #9ca3af;
}

.masark-sidebar-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: #d1d5db;
}

.masark-sidebar-empty p {
  margin: 0;
  font-size: 14px;
}

/* Loading state */
.masark-sidebar-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.masark-sidebar-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: masark-spin 0.6s linear infinite;
}

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

/* Toggle button */
.masark-sidebar-toggle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 43;
  width: 36px;
  height: 72px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: 0 12px 12px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 12px rgba(99, 102, 241, 0.3);
  transition: all 0.2s;
  color: #ffffff;
}

.masark-sidebar-toggle:hover {
  width: 42px;
  box-shadow: 3px 0 16px rgba(99, 102, 241, 0.4);
}

.masark-sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

/* Responsive: full width on mobile */
@media (max-width: 768px) {
  .masark-sidebar {
    width: 100%;
  }
}
