/* static/css/style.css */

:root {
  /* --- Palette: Cosmic Glass --- */
  --bg-app: #09090b;
  /* Main background (Pitch black/slate) */
  --bg-panel: #121214;
  /* Secondary panels */
  --bg-card: #1c1c1f;
  /* Cards */

  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-surface: rgba(255, 255, 255, 0.03);
  --glass-highlight: rgba(255, 255, 255, 0.05);

  --accent-primary: #8b5cf6;
  /* Violet */
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-secondary: #ec4899;
  /* Pink */

  --text-main: #ededed;
  --text-muted: #a1a1aa;
  --text-dim: #52525b;

  --status-active: #10b981;
  --status-dot: #22c55e;

  /* --- Dimensions --- */
  --header-height: 48px;
  --tab-height: 36px;

  /* --- Fonts --- */
  --font-sans: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  /* App shell handles scrolling */
  -webkit-font-smoothing: antialiased;
}

/* === App Shell === */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-header {
  height: var(--header-height);
  background: var(--bg-app);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
}

/* --- Logo --- */
.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

/* --- Tab Strip --- */
.tab-strip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  /* Hide scrollbar */
  padding-right: 16px;
}

.tab-strip::-webkit-scrollbar {
  display: none;
}

.tab {
  height: var(--tab-height);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  max-width: 280px;
  min-width: 200px;
  position: relative;
  user-select: none;
}

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

.tab.active {
  background: var(--glass-highlight);
  color: var(--text-main);
  border-color: var(--glass-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Dashboard/Home Tab - Distinctive Styling */
.tab-home {
  min-width: auto;
  border-left: 2px solid var(--accent-primary);
  font-weight: 600;
}

.tab-home .tab-icon {
  color: var(--accent-primary);
  opacity: 1;
}

.tab-home .tab-title {
  font-weight: 600;
}

.tab-home.active {
  background: rgba(139, 92, 246, 0.1);
  border-left-color: var(--accent-primary);
}

.tab-icon {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.tab-icon svg {
  width: 100%;
  height: 100%;
}

.tab-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.tab-close {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.tab-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tab:hover .tab-close,
.tab.active .tab-close {
  opacity: 0.6;
}

.tab-close:hover {
  opacity: 1 !important;
}

/* Inactive tabs fade out slightly */
.tab:not(.active) {
  opacity: 0.7;
}

.tab:not(.active):hover {
  opacity: 1;
}


/* --- Window Controls / Status --- */
.window-controls {
  margin-left: auto;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--bg-card);
  /* Connecting/Offline */
  border: 1px solid var(--text-dim);
  transition: all 0.3s;
}

.status-dot.connected {
  background-color: var(--status-dot);
  border-color: transparent;
  box-shadow: 0 0 8px var(--status-dot);
}

.status-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  transition: color 0.3s;
}

.status-label.connected {
  color: var(--status-dot);
}


/* === Main Content === */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-pane {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  background: #141417;
  /* More visible elevation from #09090b */
}

.tab-pane.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}


/* === Dashboard View === */
.dashboard-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px;
}

.dashboard-header {
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.dashboard-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Compact List Style */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.2s;
  border: 1px solid transparent;
}

.doc-item:hover {
  background: var(--glass-surface);
  border-color: var(--glass-border);
}

.doc-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  cursor: pointer;
  padding: 4px 0;
}

.doc-main:hover .doc-title {
  color: var(--text-main);
}

.doc-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.doc-item:hover .doc-actions {
  opacity: 1;
}

.action-btn {
  width: 28px;
  height: 28px;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--glass-highlight);
  color: var(--text-main);
}

.action-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.action-btn svg {
  width: 100%;
  height: 100%;
}

/* Dashboard Actions */
.dashboard-actions {
  display: flex;
  gap: 12px;
}

.btn-text {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-text:hover {
  background: var(--glass-highlight);
  color: var(--text-main);
  border-color: var(--text-dim);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Two-step confirm pattern */
.btn-danger.confirming {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  animation: pulse-warning 0.6s ease-in-out infinite alternate;
}

@keyframes pulse-warning {
  from {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
  }

  to {
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
  }
}

/* Inline Edit Input */
.inline-edit-input {
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  color: var(--text-main);
  font-size: inherit;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
  width: 100%;
  max-width: 300px;
  outline: none;
}

.inline-edit-input:focus {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.doc-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.doc-status.active {
  background: var(--status-active);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

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

.doc-title {
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.doc-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
}


/* === Document View (Markdown) === */
.doc-view-container {
  max-width: 800px;
  /* Container is slightly wider than text column */
  margin: 0 auto;
  padding: 60px 24px;
  padding-bottom: 120px;
}

.doc-header {
  margin-bottom: 48px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 32px;
  max-width: 700px;
  /* Align with text */
  margin-left: auto;
  margin-right: auto;
}

.doc-header h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1.1;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fff 30%, #a1a1aa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.doc-badges {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  letter-spacing: 0.02em;
}

/* === Markdown Body (Deep Overhaul) === */
.markdown-body {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  /* 17px - sweet spot */
  line-height: 1.7;
  color: #d4d4d8;
  /* Zinc-300 - softer, easier on eyes */
  max-width: 720px;
  margin: 0 auto;
  letter-spacing: -0.01em;
}

/* Headings */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--font-display);
  margin-top: 2em;
  margin-bottom: 0.75em;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.markdown-body h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  border-bottom: 1px solid #27272a;
  padding-bottom: 0.4em;
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #f4f4f5;
  /* Zinc-100 */
  border-bottom: 1px solid #1f1f23;
  padding-bottom: 0.3em;
}

.markdown-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #e4e4e7;
  /* Zinc-200 */
}

.markdown-body h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #a1a1aa;
  /* Zinc-400 */
  margin-top: 1.75em;
}

/* Paragraphs & Text */
.markdown-body p {
  margin-bottom: 1.6em;
}

.markdown-body strong {
  font-weight: 700;
  color: #ffffff;
}

.markdown-body em {
  color: #e4e4e7;
}

/* Links */
.markdown-body a {
  color: #a78bfa;
  /* Violet-400 - softer than primary */
  text-decoration: none;
  border-bottom: 1px solid rgba(167, 139, 250, 0.3);
  transition: all 0.15s;
}

.markdown-body a:hover {
  color: #c4b5fd;
  border-bottom-color: currentColor;
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1.5em;
  padding-left: 1.75em;
}

.markdown-body li {
  margin-bottom: 0.4em;
}

.markdown-body li::marker {
  color: #71717a;
  /* Zinc-500 - muted, not distracting */
}

/* Nested lists - tighter */
.markdown-body li>ul,
.markdown-body li>ol {
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}

/* Blockquotes */
.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 1em 1.25em;
  border-left: 3px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.06);
  border-radius: 0 6px 6px 0;
  color: #a1a1aa;
  font-style: italic;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

/* Code Blocks - GitHub Dark style */
.markdown-body pre {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 1.5em 0;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #21262d;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: #e6edf3;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9em;
  line-height: 1.55;
  color: #e6edf3;
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75em 0;
  font-size: 0.95rem;
}

.markdown-body th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #30363d;
  color: #e4e4e7;
  font-weight: 600;
  background: #161b22;
}

.markdown-body td {
  padding: 10px 14px;
  border-bottom: 1px solid #21262d;
  color: #a1a1aa;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

/* Horizontal Rule */
.markdown-body hr {
  border: 0;
  height: 1px;
  background: #27272a;
  margin: 3em 0;
}

/* Images */
.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5em 0;
}


/* Utility */
.loading {
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
  font-style: italic;
  font-family: var(--font-mono);
  opacity: 0.7;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--glass-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  margin-top: 40px;
}