/* 
  ValuFinder - Premium Dark Theme CSS
*/

:root {
  /* Color Palette - Deep Dark Mode */
  --bg-base: #0a0a0c;
  --bg-surface: #121216;
  --bg-surface-elevated: #1a1a20;

  --text-primary: #f8f9fa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  /* Accents */
  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;
  --accent-success: #10b981;
  --accent-success-bg: rgba(16, 185, 129, 0.1);
  --accent-danger: #ef4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.1);
  --accent-wide-moat: #8b5cf6;
  --accent-wide-moat-bg: rgba(139, 92, 246, 0.15);

  /* Borders & Glass */
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.5);
  --glass-bg: rgba(18, 18, 22, 0.7);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
  background-image:
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
}

/* Layout Container */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  max-width: 1920px;
  margin: 0 auto;
}

/* Glass Panel Utility */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  z-index: 10;
}

.sidebar-header {
  padding: 24px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo-icon {
  font-size: 28px;
  color: var(--accent-primary);
}

.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.dot {
  color: var(--accent-primary);
}

.filter-section {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.filter-title {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 20px;
}

.mt-6 {
  margin-top: 32px;
}

.filter-group {
  margin-bottom: 24px;
}

.filter-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Custom Select Dropdown */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select select {
  appearance: none;
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.custom-select select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* Premium Range Slider */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.value-display {
  font-family: monospace;
  font-size: 14px;
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.premium-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-surface-elevated);
  border-radius: 3px;
  outline: none;
  margin: 10px 0;
}

.premium-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: 4px solid var(--bg-surface-elevated);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-fast);
}

.premium-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.sidebar-footer {
  padding: 24px 32px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Main Content Styling */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Navigation Bar */
.top-nav {
  height: 80px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  z-index: 5;
}

.search-bar {
  position: relative;
  width: 400px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 20px;
}

.search-bar input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 12px 16px 12px 48px;
  border-radius: 24px;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--bg-surface);
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sort-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.sort-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

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

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

/* Scroll Area & Grid */
.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

/* Loading State */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

/* Stock Card Styles (Dynamically injected) */
.stock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.stock-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.stock-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.12);
}

.stock-card:hover::before {
  opacity: 1;
}

/* --- New Moat Section Styles --- */
.moat-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface-elevated);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 8px;
}

.moat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.moat-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.moat-overall-badge {
  background-color: var(--accent-wide-moat-bg);
  color: var(--accent-wide-moat);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.moat-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.moat-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.moat-label {
  width: 95px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.moat-bar-container {
  flex-grow: 1;
  height: 6px;
  background-color: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.moat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-wide-moat));
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.moat-score {
  width: 26px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  font-family: monospace;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.stock-symbol {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stock-name {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.quality-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quality-badge.exceptional {
  background: var(--accent-success-bg);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.quality-badge.high {
  background: var(--accent-wide-moat-bg);
  color: var(--accent-wide-moat);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.quality-badge.standard {
  background: var(--bg-surface-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border-light);
}

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.metric-box {
  background: var(--bg-surface-elevated);
  padding: 12px;
  border-radius: 8px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 18px;
  font-weight: 600;
  font-family: monospace;
}

.pe-value {
  color: var(--accent-primary);
}

.pe-value.great-value {
  color: var(--accent-success);
}

.pe-value.expensive {
  color: var(--accent-danger);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
  margin-top: 16px;
  /* Added margin-top to separate from metrics or moat */
}

.price {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.change-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
}

.change-badge.positive {
  background: var(--accent-success-bg);
  color: var(--accent-success);
}

.change-badge.negative {
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
}

/* --- Extended Metrics --- */
.extended-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-light);
}

.ext-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ext-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ext-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: monospace;
}

.positive-text {
  color: var(--accent-success);
}

.negative-text {
  color: var(--accent-danger);
}