/* blendR Web Application Stylesheet */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-obs: #10b981;
  --accent-ext: #3b82f6;
  --accent-blend: #a855f7;
  --accent-blend-gradient: linear-gradient(135deg, #a855f7, #ec4899);
  
  --sidebar-width: 360px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
}

body {
  display: flex;
  flex-direction: column;
}

/* Header Navbar */
.navbar {
  height: 56px;
  min-height: 56px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  flex-shrink: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.navbar-logo {
  height: 32px;
  width: 32px;
  border-radius: 6px;
  object-fit: contain;
}

.navbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.navbar-subtitle {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.webr-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  font-size: 0.725rem;
  font-weight: 500;
  color: var(--text-muted);
}

.webr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.825rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--text-main);
}

/* App Container */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Left Sidebar Panel */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
  flex-shrink: 0;
  height: 100%;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.panel-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title svg {
  color: var(--accent-primary);
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--text-muted);
}

.value-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-family: var(--font-mono);
  font-size: 0.725rem;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-weight: 600;
}

.select-input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  outline: none;
}

.select-input:focus {
  border-color: var(--accent-primary);
}

/* Custom Range Slider */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #334155;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-blend);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

/* Preset Buttons */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-preset {
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.btn-preset:hover, .btn-preset.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: #fff;
}

/* Right Main Content Panel (Fit Screen) */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 16px 20px;
  gap: 14px;
  background: var(--bg-primary);
}

/* Stat Cards Bar */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.obs::before { background: var(--accent-obs); }
.stat-card.ext::before { background: var(--accent-ext); }
.stat-card.blend::before { background: var(--accent-blend); }
.stat-card.window::before { background: #f59e0b; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.stat-subtext {
  font-size: 0.675rem;
  color: var(--text-dim);
}

/* Tab Navigation */
.tabs-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  flex-shrink: 0;
}

.tab-buttons {
  display: flex;
  gap: 6px;
}

.tab-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: #fff;
  background: var(--accent-primary);
}

.action-btn {
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.action-btn:hover {
  background: var(--bg-card-hover);
}

/* Chart Canvas Wrapper - Fits Screen */
.chart-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  flex: 1;
  min-height: 0;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

canvas#main-chart {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Code Output Tab */
.code-wrapper {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  flex: 1;
  min-height: 0;
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e2e8f0;
  overflow-y: auto;
  line-height: 1.5;
}

.copy-code-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* Legend Overlay */
.legend-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-color {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

/* Responsiveness for smaller windows */
@media (max-width: 900px) {
  html, body {
    height: auto;
    overflow-y: auto;
  }
  .app-container {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
  }
  .main-content {
    height: 550px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
