/* ==========================================================================
   MindStream - Linear & Apple Notes Inspired Aesthetic (UI/UX Pro Max)
   Clean, Tactile, and Distraction-Free
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Dark Obsidian Theme (Default) */
  --bg-app: #090B10;
  --bg-sidebar: #0E1219;
  --bg-card: #141A24;
  --bg-card-hover: #19212E;
  --bg-surface: #18202D;
  --bg-surface-elevated: #202A3B;
  --bg-input: #0B0E14;

  --border-subtle: #1D2535;
  --border-medium: #2A364D;
  --border-focus: #3B82F6;
  --color-ring: #3B82F6;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #090B10;

  --accent-primary: #3B82F6;
  --accent-primary-hover: #2563EB;
  --accent-glow: rgba(59, 130, 246, 0.25);

  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.6);

  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-spring);
  --transition-normal: 250ms var(--ease-spring);
}

[data-theme="light"] {
  --bg-app: #F8FAFC;
  --bg-sidebar: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-surface: #F1F5F9;
  --bg-surface-elevated: #E2E8F0;
  --bg-input: #FFFFFF;

  --border-subtle: #E2E8F0;
  --border-medium: #CBD5E1;
  --border-focus: #2563EB;
  --color-ring: #2563EB;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;

  --accent-primary: #2563EB;
  --accent-primary-hover: #1D4ED8;
  --accent-glow: rgba(37, 99, 235, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.12);
}

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

html, body {
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  user-select: none;
}

:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

/* App Shell */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal), transform var(--transition-normal);
  z-index: 200;
}

.sidebar-header {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-box {
  width: 30px;
  height: 30px;
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-nav-section {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-counter {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Content Workspace */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* Top Glass Header */
.top-header {
  height: 56px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.sidebar-toggle-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

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

.model-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-badge-pill:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* Scrollable Workspace */
.workspace-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 100px;
}

.workspace-content {
  max-width: 860px;
  margin: 0 auto;
}

/* --- Hero Brain Dump Input Section --- */
.brain-dump-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.brain-dump-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-focus);
}

.brain-dump-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.brain-dump-title-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brain-dump-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 220px;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  font-family: inherit;
}

.brain-dump-textarea::placeholder {
  color: var(--text-muted);
}

.brain-dump-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.voice-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-voice:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
}

.btn-voice.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--color-danger);
  color: var(--color-danger);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.waveform-animation {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.waveform-animation span {
  width: 3px;
  height: 100%;
  background: var(--color-danger);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite alternate;
}

.waveform-animation span:nth-child(2) { animation-delay: 0.15s; }
.waveform-animation span:nth-child(3) { animation-delay: 0.3s; }
.waveform-animation span:nth-child(4) { animation-delay: 0.45s; }

@keyframes wave {
  0% { height: 4px; }
  100% { height: 16px; }
}

.dump-action-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary-action:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-primary-action:active {
  transform: translateY(0);
}

.btn-primary-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-subtle:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* --- Search & Control Bar --- */
.search-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.search-input-box {
  position: relative;
  flex: 1;
}

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

.search-field {
  width: 100%;
  padding: 9px 36px 9px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-field:focus {
  border-color: var(--border-focus);
}

.kbd-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Note Cards Stream Layout --- */
.feed-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Modern Linear-Style Note Card --- */
.note-sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  animation: noteSlideIn 0.3s var(--ease-spring);
}

@keyframes noteSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.note-sheet-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.note-sheet-card.pinned {
  border-left: 3px solid var(--accent-primary);
}

.card-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-space-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.card-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.note-sheet-card:hover .card-quick-actions {
  opacity: 1;
}

.card-tool-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.card-tool-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.card-tool-btn.active {
  color: var(--accent-primary);
}

.card-note-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
  outline: none;
}

.card-note-title[contenteditable="true"]:focus {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.card-note-summary {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Points List */
.card-points-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding-left: 2px;
}

.card-point-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
}

.point-checkbox {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  border-radius: 4px;
  border: 1.5px solid var(--border-medium);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
  transition: all var(--transition-fast);
}

.point-checkbox:hover {
  border-color: var(--accent-primary);
}

.point-checkbox.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.point-text {
  flex: 1;
  outline: none;
  transition: color var(--transition-fast);
}

.point-text.done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.point-delete-btn {
  opacity: 0;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 11px;
  transition: opacity var(--transition-fast);
}

.card-point-row:hover .point-delete-btn {
  opacity: 1;
}

.point-delete-btn:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* Tags & Footer */
.card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 8px;
}

.card-tags-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-tag-pill {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.card-timestamp-text {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Stream Details */
.stream-details-accordion {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.stream-details-accordion summary {
  cursor: pointer;
  outline: none;
  user-select: none;
}

.stream-details-accordion summary:hover {
  color: var(--text-secondary);
}

.stream-quote-box {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-left: 2px solid var(--border-medium);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-style: italic;
  white-space: pre-wrap;
}

/* --- Modals & Overlays --- */
.modal-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.75);
  backdrop-filter: blur(6px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  overflow-y: auto;
}

.modal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-field-group {
  margin-bottom: 20px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.field-description {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.field-input, .field-textarea, .field-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.field-input:focus, .field-textarea:focus, .field-select:focus {
  border-color: var(--border-focus);
}

.field-textarea {
  min-height: 70px;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Toast Notifications */
.toasts-outlet {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-slide 0.25s var(--ease-spring);
}

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

@keyframes toast-slide {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .workspace-scroll {
    padding: 16px 14px 80px;
  }
}
