/* ═══════════════════════════════════════════════════════
   报告管理中心 — Developer Minimalist Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #09090b;      /* Zinc 950 */
  --bg-secondary: #18181b;    /* Zinc 900 */
  --bg-tertiary: #27272a;     /* Zinc 800 */
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --bg-elevated: #18181b;

  --border: #27272a;          /* Zinc 800 */
  --border-hover: #3f3f46;    /* Zinc 700 */
  --border-accent: #52525b;   /* Zinc 600 */

  --accent: #fafafa;          /* Pure white text/high contrast */
  --accent-light: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.05);
  --accent-2: #e4e4e7;        /* Zinc 200 */
  --accent-gradient: none;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);

  --text-primary: #fafafa;    /* Zinc 50 */
  --text-secondary: #a1a1aa;  /* Zinc 400 */
  --text-dim: #71717a;        /* Zinc 500 */
  --text-accent: #ffffff;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;

  --transition: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-bounce: 0.15s cubic-bezier(0.16, 1, 0.3, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html { 
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Background gradient mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ═══ Navbar ═══ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-left { display: flex; align-items: center; gap: 12px; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon { font-size: 20px; }

.logo-text {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.navbar-right { display: flex; align-items: center; gap: 12px; }

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: default;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.status-dot.synced { background: var(--success); }
.status-dot.unsynced { background: var(--warning); animation: pulse 2s infinite; }
.status-dot.error { background: var(--danger); }

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-sm { padding: 4px 8px; font-size: 12px; }

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-refresh {
  width: 32px; height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.btn-refresh:hover svg { transform: rotate(180deg); }
.btn-refresh svg { transition: transform 0.5s ease; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ═══ Stats Bar ═══ */
.stats-bar {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 16, 23, 0.6);
}

.stats-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.stat-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

/* ═══ Main Content ═══ */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

/* ═══ Upload Zone ═══ */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.01);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.02);
}

.upload-zone.dragover { border-style: solid; }

.upload-icon {
  color: var(--text-dim);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.upload-zone:hover .upload-icon { color: var(--text-secondary); }

.upload-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-dim);
}

/* ═══ Workspace Layout (Dual Pane) ═══ */
.workspace {
  display: flex;
  height: calc(100vh - 56px - 41px); /* viewport minus navbar (56px) and stats (41px) */
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 340px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.btn-upload-trigger {
  width: 100%;
  justify-content: center;
  padding: 8px;
}

.upload-zone.compact {
  margin: 12px 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.01);
  transition: all var(--transition);
  cursor: pointer;
  user-select: none;
}
.upload-zone.compact svg {
  color: var(--text-secondary);
}
.upload-zone.compact:hover, .upload-zone.compact.dragover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.02);
}

.search-box {
  padding: 0 16px 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

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

.search-box input {
  width: 100%;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 30px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all var(--transition);
}

.search-box input:focus {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}

/* Report List */
.report-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

/* List Item */
.report-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}

.report-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.report-item:hover {
  background: rgba(255,255,255,0.02);
  border-color: var(--border);
}

.report-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.report-item.active::before {
  opacity: 1;
}

.report-item-icon {
  font-size: 20px;
  margin-top: 2px;
}

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

.report-item-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text-secondary);
}

.report-item-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-item-meta-row svg {
  color: var(--text-dim);
}

.report-item-dates {
  margin-top: 4px;
  border-top: 1px dashed rgba(255,255,255,0.03);
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  color: var(--text-dim);
}

/* Empty Lists & Skeletons */
.empty-list-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-dim);
  text-align: center;
  gap: 8px;
}
.empty-list-state p {
  font-size: 12px;
}

.skeleton-item {
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: rgba(255,255,255,0.01);
  border: 1px solid var(--border);
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}
.skeleton-line:last-child {
  margin-bottom: 0;
}
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w50 { width: 50%; }

/* Main Panel */
.main-panel {
  flex: 1;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Empty Workspace State */
.empty-workspace-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
  gap: 12px;
}

.empty-workspace-state .empty-icon {
  font-size: 64px;
}

.empty-workspace-state h3 {
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 500;
}

.empty-workspace-state p {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 320px;
}

/* Workspace Details */
.workspace-details {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.workspace-header {
  height: 48px;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 9, 11, 0.4);
  flex-shrink: 0;
}

.workspace-title-info {
  flex: 1;
  min-width: 0;
  margin-right: 12px;
}

.workspace-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-right: 12px;
}

.tab-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 1px);
  cursor: pointer;
  transition: all var(--transition);
}

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

.tab-btn.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Save Button */
.btn-save:not(:disabled) {
  border-color: var(--text-primary);
}

.mobile-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  margin-right: 12px;
}
.mobile-back-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

/* Workspace Body */
.workspace-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.pane-content {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow: hidden;
}

.pane-content.active {
  opacity: 1;
  pointer-events: auto;
}

/* Preview Frame */
#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* Edit Pane & CodeMirror */
#editPane {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.CodeMirror {
  width: 100%;
  height: 100% !important;
  font-family: var(--font-mono) !important;
  font-size: 13.5px !important;
  background: #0f111a !important; /* Dracula theme background */
}

.CodeMirror-gutters {
  background: #0f111a !important;
  border-right: 1px solid rgba(255,255,255,0.05) !important;
}

.hidden {
  display: none !important;
}

/* ═══ Modals ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

.modal-container {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: slideUp 0.3s var(--transition);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.modal-rename, .modal-delete {
  width: 100%;
  max-width: 440px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body { padding: 20px; flex: 1; overflow: hidden; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Input Field */
.input-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: all var(--transition);
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Delete Warning */
.delete-warning {
  text-align: center;
  padding: 10px 0;
}

.delete-warning svg { color: var(--warning); margin-bottom: 12px; }
.delete-warning p { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.delete-warning strong { color: var(--text-primary); word-break: break-all; }
.delete-hint { font-size: 12px !important; color: var(--text-dim) !important; margin-top: 8px !important; }

/* ═══ Toast ═══ */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.35s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(20px);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-message { flex: 1; }

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

/* ═══ Loading Overlay ═══ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(7, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.loading-overlay.active { display: flex; }

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text { font-size: 14px; color: var(--text-secondary); }

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

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

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

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

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

/* ═══ Responsive (Mobile) ═══ */
@media (max-width: 768px) {
  .navbar-inner {
    padding: 0 16px;
  }
  
  .stats-inner {
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .workspace {
    height: calc(100vh - 64px - 70px); /* adjusted height for wrapped stats */
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    transition: transform 0.3s ease;
  }

  .main-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Slide in active main-panel */
  .workspace.panel-active .sidebar {
    transform: translateX(-30%);
  }

  .workspace.panel-active .main-panel {
    transform: translateX(0);
  }

  .mobile-back-btn {
    display: inline-flex;
  }

  .workspace-header {
    padding: 0 16px;
  }
  
  .workspace-actions {
    gap: 4px;
  }
  
  .workspace-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .workspace-actions .btn span,
  .workspace-actions .btn-ghost,
  .workspace-actions .btn-rename-action svg,
  .workspace-actions .btn-delete-action svg {
    display: none; /* Hide icons/labels to save space */
  }
  
  .workspace-actions .btn-rename-action::after {
    content: '重命名';
  }
  
  .workspace-actions .btn-delete-action::after {
    content: '删除';
  }

  .workspace-tabs {
    margin-right: 8px;
  }
  
  .tab-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .logo-text { font-size: 15px; }
  .status-badge .status-text { display: none; }
  .stat-item:last-child { display: none; }
  .workspace {
    height: calc(100vh - 64px - 45px); /* if stats wrap nicely */
  }
}
