/* styles.css — MARVIS Design System */
/* Deep blue theme with glassmorphism */

/* ══════════════════════════════════════════
   CSS Custom Properties (Design Tokens)
   ══════════════════════════════════════════ */

:root {
  /* Colors — Deep Blue */
  --bg-primary: #0a0e27;
  --bg-secondary: #0f1338;
  --bg-gradient: linear-gradient(135deg, #0a0e27 0%, #1a1f4e 50%, #0f1338 100%);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --surface-active: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Accents */
  --accent-blue: #4a9eff;
  --accent-blue-glow: rgba(74, 158, 255, 0.3);
  --accent-purple: #7c3aed;
  --accent-purple-glow: rgba(124, 58, 237, 0.3);
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.4);
  --accent-green: #10b981;
  --accent-red: #ef4444;

  /* Text */
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #4a9eff;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Borders */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Effects */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(20px);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 20px rgba(74, 158, 255, 0.2);
  --shadow-glow-gold: 0 0 20px rgba(245, 158, 11, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --header-height: 56px;
  --input-bar-height: 110px;
}

/* ══════════════════════════════════════════
   Base Reset & Typography
   ══════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.6;
}

/* Global Form Controls & Dropdowns consistency */
select,
input,
textarea {
  color-scheme: dark;
}

select option {
  background-color: #0f1338;
  color: #e2e8f0;
}

select option:hover,
select option:focus,
select option:checked {
  background-color: #1a2260;
  color: #4a9eff;
}

/* ══════════════════════════════════════════
   Activation Overlay
   ══════════════════════════════════════════ */

.activation-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.activation-overlay.hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.activation-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
}

.activation-content h2 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.activation-content p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: pulse 2s ease-in-out infinite;
}

.activation-sphere {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--space-8);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent-blue), var(--accent-purple), #0a0e27);
  box-shadow:
    0 0 60px var(--accent-blue-glow),
    0 0 120px rgba(124, 58, 237, 0.15),
    inset 0 0 30px rgba(0, 0, 0, 0.3);
  animation: sphereFloat 4s ease-in-out infinite;
}

/* ══════════════════════════════════════════
   App Layout
   ══════════════════════════════════════════ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: opacity 0.4s ease;
}

.app.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ══════════════════════════════════════════
   Header
   ══════════════════════════════════════════ */

.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  -moz-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.logo {
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-primary);
}

.logo-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header-center {
  display: flex;
  align-items: center;
}

/* Status indicators */
.status-indicators {
  display: flex;
  gap: var(--space-4);
}

.status-dot {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.status-dot .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-base);
}

.status-dot .label {
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-dot.ok .dot {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.error .dot {
  background: var(--accent-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Clear Display button */
.clear-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.clear-btn:hover {
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.clear-icon {
  width: 14px;
  height: 14px;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: var(--space-1);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
}

.tab-btn {
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
}

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

.tab-btn.active {
  color: var(--text-primary);
  background: var(--accent-blue);
  box-shadow: var(--shadow-glow-blue);
}

/* ══════════════════════════════════════════
   Main Content & Responsive Layout
   ══════════════════════════════════════════ */

.main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.workspace-layer > * {
  pointer-events: auto;
}

/* Elevate workspace layer above spatial cards (z-index 100-300) when settings is active */
.workspace-layer.settings-active,
.workspace-layer:has(#panel-settings.active) {
  z-index: 950 !important;
  pointer-events: auto;
}

.footer-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-1) var(--space-3);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  opacity: 0.75;
  text-align: center;
}

.tab-panel {
  display: none !important;
}

.tab-panel.active {
  display: flex !important;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

#panel-settings.tab-panel.active {
  display: block !important;
  position: relative;
  z-index: 950;
  height: 100%;
  overflow-y: auto;
  padding: var(--space-6);
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  background: rgba(8, 12, 34, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(74, 158, 255, 0.28);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(74, 158, 255, 0.15);
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
  animation: settingsFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

@keyframes settingsFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pulse-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  background: rgba(74, 158, 255, 0.12);
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-blue);
  text-transform: uppercase;
}

.header-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.header-action-btn:hover {
  background: rgba(74, 158, 255, 0.12);
  border-color: rgba(74, 158, 255, 0.35);
  box-shadow: 0 0 10px rgba(74, 158, 255, 0.2);
  color: var(--accent-blue);
}

/* ══════════════════════════════════════════
   Spatial Floating Note Windows
   ══════════════════════════════════════════ */

.note-canvas {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none; /* children enable pointer events */
  overflow: hidden;
}

.note-window {
  position: absolute;
  width: 320px;
  max-width: 90vw;
  pointer-events: auto;
  border-radius: var(--radius-xl);
  background: rgba(15, 20, 56, 0.78);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(74, 158, 255, 0.12);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.note-window.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 30px rgba(74, 158, 255, 0.3);
  transform: scale(1.02);
}

.note-window.closing {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

.note-window.note-highlight {
  border-color: var(--accent-blue);
  box-shadow: 0 0 35px rgba(74, 158, 255, 0.6);
}

.note-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  cursor: grab;
}

.note-window-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow: hidden;
  flex: 1;
}

.note-window-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.note-window-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-win-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.note-win-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

.note-win-btn.btn-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: var(--accent-red);
}

.note-window-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  user-select: text;
}

.note-window-content {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.55;
  max-height: 260px;
  overflow-y: auto;
  word-break: break-word;
}

.note-window-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: var(--space-2);
}

.note-meta-source {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(74, 158, 255, 0.15);
  color: var(--accent-blue);
}

.note-window.minimized {
  width: 220px;
  border-radius: var(--radius-full);
}

.note-window.minimized .note-window-header {
  border-radius: var(--radius-full);
  border-bottom: none;
}

.note-window.minimized .note-window-body {
  display: none;
}

/* ══════════════════════════════════════════
   Notes Hub Drawer Modal
   ══════════════════════════════════════════ */

.notes-hub-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
}

.notes-hub-modal.open {
  display: flex;
}

.notes-hub-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 22, 0.7);
  backdrop-filter: blur(12px);
}

.notes-hub-content {
  position: relative;
  width: 580px;
  max-width: 92vw;
  max-height: 80vh;
  background: rgba(15, 20, 56, 0.9);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(74, 158, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.notes-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.notes-hub-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.notes-hub-title-group h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
}

.notes-hub-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.notes-hub-close:hover {
  color: var(--text-primary);
}

.notes-hub-search {
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.notes-hub-search input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  outline: none;
}

.notes-hub-search input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.notes-hub-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 450px;
}

.notes-hub-item {
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
}

.notes-hub-item:hover {
  background: rgba(74, 158, 255, 0.08);
  border-color: rgba(74, 158, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.notes-hub-item.is-open {
  border-color: rgba(74, 158, 255, 0.4);
  background: rgba(74, 158, 255, 0.06);
}

.hub-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}

.hub-item-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.hub-item-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.hub-item-preview {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: var(--space-1);
}

.hub-item-status {
  font-size: 10px;
  color: var(--accent-blue);
  font-weight: 500;
}

.hub-empty, .hub-loading {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ══════════════════════════════════════════
   Responsive Adjustments
   ══════════════════════════════════════════ */

@media (max-width: 899px) {
  .header {
    padding: 0 var(--space-3);
  }

  .btn-text {
    display: none;
  }

  .header-action-btn {
    padding: var(--space-2);
  }

  .status-indicators {
    gap: 6px;
  }

  .status-dot .label {
    display: none;
  }

  .clear-label {
    display: none;
  }

  .clear-btn {
    padding: var(--space-2);
  }
}

/* ══════════════════════════════════════════
   Toast Notifications
   ══════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-4);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-5);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  -moz-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.3);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.3);
}

/* ══════════════════════════════════════════
   Scrollbar
   ══════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-active);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ══════════════════════════════════════════
   Animations
   ══════════════════════════════════════════ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@keyframes sphereFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

@keyframes micGlow {

  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-blue-glow);
  }

  50% {
    box-shadow: 0 0 0 12px transparent;
  }
}

/* ══════════════════════════════════════════
   Utility
   ══════════════════════════════════════════ */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ══════════════════════════════════════════
   Mobile Header & Layout Adjustments (< 680px)
   ══════════════════════════════════════════ */

@media (max-width: 680px) {
  .app-header {
    padding: 8px 12px;
    min-height: 48px;
    height: auto;
  }

  .logo-title {
    font-size: 1rem;
  }

  .pulse-tag,
  .version-badge {
    display: none;
  }

  .header-right {
    gap: 6px;
  }

  .notes-hub-btn .btn-text,
  .clear-btn .clear-label {
    display: none;
  }

  .notes-hub-btn,
  .clear-btn {
    padding: 6px 8px;
    min-width: 32px;
    justify-content: center;
  }

  .tab-nav {
    padding: 2px;
  }

  .tab-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}