/**
 * OmniScribe Hybrid AI - Human-Crafted SaaS Stylesheet
 * Built on Bootstrap 5.3 with modern typography, refined spacing, and subtle micro-interactions.
 */

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

:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  /* Brand colors */
  --brand-primary: #4f46e5;
  --brand-primary-hover: #4338ca;
  --brand-secondary: #0ea5e9;
  --brand-emerald: #10b981;
  --brand-amber: #f59e0b;
  --brand-rose: #f43f5e;
  
  /* Surfaces */
  --surface-bg: #f8fafc;
  --surface-card: #ffffff;
  --surface-border: #e2e8f0;
  --surface-border-subtle: #f1f5f9;
  --surface-hover: #f8fafc;
  
  /* Dark telemetry surface */
  --telemetry-bg: #090d16;
  --telemetry-card: #111827;
  --telemetry-border: #1f2937;
  --telemetry-text-muted: #9ca3af;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.04), 0 1px 2px 0 rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

body {
  font-family: var(--font-main);
  background-color: var(--surface-bg);
  color: #0f172a;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   NAVBAR & HEADER
   ========================================== */
.navbar-clean {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
}

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

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
  transition: transform 0.2s ease;
}

.brand-wrapper:hover .brand-icon {
  transform: scale(1.05);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
  line-height: 1.1;
}

.brand-tagline {
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.02em;
}

/* Status indicator chips */
.status-indicator-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--surface-border);
  background: #ffffff;
  color: #475569;
  transition: all 0.2s ease;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--brand-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-dot.cloud {
  background-color: var(--brand-secondary);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.status-dot.warning {
  background-color: var(--brand-amber);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* ==========================================
   SEGMENTED CONTROL (INFERENCE MODES)
   ========================================== */
.segmented-mode-picker {
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  display: inline-flex;
  border: 1px solid #e2e8f0;
}

.segmented-mode-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.btn-check:checked + .segmented-mode-btn-auto {
  background: #ffffff;
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.btn-check:checked + .segmented-mode-btn-local {
  background: #ffffff;
  color: var(--brand-emerald);
  box-shadow: var(--shadow-sm);
}

.btn-check:checked + .segmented-mode-btn-cloud {
  background: #ffffff;
  color: var(--brand-secondary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================
   PRESET CHIPS (SCENARIOS)
   ========================================== */
.preset-chip {
  border: 1px solid var(--surface-border);
  background: #ffffff;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.preset-chip:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--brand-primary);
  transform: translateY(-1px);
}

/* ==========================================
   STUDIO WORKSPACE CARDS
   ========================================== */
.studio-card {
  background: #ffffff;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.studio-card:focus-within {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.document-title-input {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  border: none;
  background: transparent;
  padding: 4px 0;
  letter-spacing: -0.02em;
}

.document-title-input:focus {
  outline: none;
  box-shadow: none;
  border-bottom: 1px dashed var(--brand-primary);
}

.document-editor-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #1e293b;
  border: 1px solid #f1f5f9;
  background: #fafafa;
  border-radius: var(--radius-md);
  padding: 14px;
  resize: vertical;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.document-editor-textarea:focus {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

/* Action workflow buttons */
.btn-action-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
  transition: all 0.15s ease;
}

.btn-action-primary:hover {
  background-color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.25);
}

.btn-action-outline {
  background-color: #ffffff;
  border: 1px solid var(--surface-border);
  color: #334155;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-action-outline:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-1px);
}

/* ==========================================
   TELEMETRY STRIP (OBSERVABILITY)
   ========================================== */
.telemetry-strip-card {
  background: var(--telemetry-bg);
  border: 1px solid var(--telemetry-border);
  border-radius: var(--radius-lg);
  color: #f3f4f6;
  padding: 14px 16px;
  box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.2);
}

.telemetry-chip {
  background: rgba(31, 41, 55, 0.7);
  border: 1px solid rgba(55, 65, 81, 0.8);
  border-radius: 8px;
  padding: 6px 10px;
}

.telemetry-chip-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.telemetry-chip-value {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.telemetry-reason-box {
  background: rgba(17, 24, 39, 0.6);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: #d1d5db;
}

/* ==========================================
   STUDIO TABS & CHAT
   ========================================== */
.custom-studio-tabs .nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  border-radius: 8px;
  padding: 5px 10px;
  transition: all 0.15s ease;
}

.custom-studio-tabs .nav-link.active {
  background-color: #f1f5f9;
  color: #0f172a;
}

.studio-tab-content {
  min-height: 80px;
  max-height: 520px;
  overflow-y: auto;
}

.chat-thread-container {
  height: 280px;
  overflow-y: auto;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.chat-bubble-user {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-radius: 12px 12px 2px 12px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-left: auto;
  max-width: 85%;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.15);
}

.chat-bubble-assistant {
  background-color: #ffffff;
  color: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1.55;
  max-width: 90%;
  box-shadow: var(--shadow-xs);
}

/* Output Typography */
.formatted-output-body {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #1e293b;
}

.formatted-output-body h3, 
.formatted-output-body h4, 
.formatted-output-body h5 {
  color: #0f172a;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

.formatted-output-body pre {
  background-color: #0f172a;
  color: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.formatted-output-body blockquote {
  border-left: 3px solid var(--brand-primary);
  padding-left: 10px;
  color: #475569;
  font-style: italic;
  margin: 8px 0;
}

/* Empty state design - Compact & Non-bloated */
.empty-state-card {
  padding: 18px 14px;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed var(--surface-border);
  border-radius: var(--radius-md);
  margin: 4px 0;
}

.empty-state-icon {
  width: 38px;
  height: 38px;
  background: #ffffff;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: var(--brand-primary);
  box-shadow: var(--shadow-xs);
}

.quick-starter-pill {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.quick-starter-pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-1px);
}

/* Horizontal scroll strip for presets */
.preset-scroll-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.preset-scroll-container::-webkit-scrollbar {
  display: none;
}

/* Mobile responsive adjustments */
@media (max-width: 991.98px) {
  .document-editor-textarea {
    rows: 7;
    min-height: 140px;
    padding: 10px;
    font-size: 0.82rem;
  }

  .chat-thread-container {
    height: 220px;
  }

  .telemetry-strip-card {
    padding: 10px 12px;
  }

  .telemetry-chip {
    padding: 5px 8px;
  }

  .telemetry-chip-label {
    font-size: 0.62rem;
  }

  .telemetry-chip-value {
    font-size: 0.85rem;
  }

  .telemetry-reason-box {
    font-size: 0.72rem;
    padding: 4px 8px;
  }

  .status-indicator-chip {
    font-size: 0.7rem;
    padding: 2px 7px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .segmented-mode-picker {
    width: 100%;
  }

  .segmented-mode-btn {
    flex: 1;
    justify-content: center;
    font-size: 0.73rem;
    padding: 5px 4px;
  }

  .workflow-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .workflow-buttons-grid .btn-workflow-wide {
    grid-column: span 2;
  }

  .empty-state-card {
    padding: 14px 10px;
  }

  .quick-starter-pill {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
}

/* Pulse / Spin Animations */
.spin {
  animation: spin 1.2s linear infinite;
  display: inline-block;
}

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

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================
   DARK THEME SYSTEM ([data-bs-theme="dark"])
   ========================================== */
[data-bs-theme="dark"] {
  --surface-bg: #090d16;
  --surface-card: #111827;
  --surface-border: #1f2937;
  --surface-border-subtle: #1e293b;
  --surface-hover: #1e293b;
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.55);
}

[data-bs-theme="dark"] body {
  background-color: var(--surface-bg);
  color: #f1f5f9;
}

[data-bs-theme="dark"] .navbar-clean {
  background: rgba(17, 24, 39, 0.94);
  border-bottom: 1px solid var(--surface-border);
}

[data-bs-theme="dark"] .brand-name {
  color: #f8fafc;
}

[data-bs-theme="dark"] .brand-tagline {
  color: #94a3b8;
}

[data-bs-theme="dark"] .sub-header-container,
[data-bs-theme="dark"] .bg-white {
  background-color: #111827 !important;
  border-color: var(--surface-border) !important;
}

[data-bs-theme="dark"] .status-indicator-chip {
  background-color: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

[data-bs-theme="dark"] .preset-chip {
  background-color: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

[data-bs-theme="dark"] .preset-chip:hover {
  background-color: #334155;
  border-color: #475569;
  color: #f8fafc;
}

[data-bs-theme="dark"] .preset-chip.active {
  background-color: #312e81;
  border-color: var(--brand-primary);
  color: #c7d2fe;
}

[data-bs-theme="dark"] .editor-card,
[data-bs-theme="dark"] .studio-card {
  background-color: var(--surface-card);
  border-color: var(--surface-border);
}

[data-bs-theme="dark"] .document-editor-textarea {
  background-color: #0b0f19;
  border-color: #1f2937;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .document-editor-textarea:focus {
  background-color: #0d131f;
  border-color: var(--brand-primary);
  color: #ffffff;
}

[data-bs-theme="dark"] .segmented-mode-picker {
  background: #1e293b;
}

[data-bs-theme="dark"] .segmented-mode-btn {
  color: #94a3b8;
}

[data-bs-theme="dark"] .segmented-mode-btn:hover {
  color: #f8fafc;
}

[data-bs-theme="dark"] .btn-check:checked + .segmented-mode-btn {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .empty-state-card {
  background-color: #0b0f19;
  border-color: #1f2937;
}

[data-bs-theme="dark"] .empty-state-icon {
  background-color: #1e293b;
  color: #818cf8;
}

[data-bs-theme="dark"] .quick-starter-pill {
  background-color: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

[data-bs-theme="dark"] .quick-starter-pill:hover {
  background-color: #334155;
  border-color: #475569;
  color: #ffffff;
}

[data-bs-theme="dark"] .custom-studio-tabs .nav-link {
  color: #94a3b8;
}

[data-bs-theme="dark"] .custom-studio-tabs .nav-link.active {
  background-color: #1e293b;
  color: #f8fafc;
}

[data-bs-theme="dark"] .chat-thread-container {
  background-color: #0b0f19;
  border-color: var(--surface-border);
}

[data-bs-theme="dark"] .chat-bubble-assistant {
  background-color: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
}

[data-bs-theme="dark"] .formatted-output-body {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .formatted-output-body h3,
[data-bs-theme="dark"] .formatted-output-body h4,
[data-bs-theme="dark"] .formatted-output-body h5 {
  color: #f8fafc;
}

[data-bs-theme="dark"] .formatted-output-body blockquote {
  color: #94a3b8;
}

[data-bs-theme="dark"] .formatted-output-body pre {
  background-color: #030712;
  border: 1px solid #1f2937;
}

[data-bs-theme="dark"] .btn-action-outline {
  background-color: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .btn-action-outline:hover {
  background-color: #334155;
  border-color: #475569;
  color: #ffffff;
}

[data-bs-theme="dark"] .modal-content {
  background-color: #111827;
  color: #f1f5f9;
  border-color: #1f2937;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  background-color: #0b0f19 !important;
  border-color: #1f2937 !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: #0b0f19 !important;
}

[data-bs-theme="dark"] .list-group-item {
  background-color: #111827;
  color: #f1f5f9;
  border-color: #1f2937;
}

[data-bs-theme="dark"] .list-group-item:hover {
  background-color: #1e293b;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #0b0f19;
  border-color: #334155;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #0d131f;
  border-color: var(--brand-primary);
  color: #ffffff;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Theme toggle button micro-animation */
#btnThemeToggle {
  transition: transform 0.2s ease, background-color 0.2s ease;
}
#btnThemeToggle:hover {
  transform: rotate(15deg) scale(1.08);
}
