/* 
   KSNerdDex - Knife Steel Visualizer Styling
   Design System & Layout System
*/

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

/* CSS Variables for Themes */
:root {
  /* Dark Theme Default */
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at top right, #111827 0%, #030712 100%);
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-hover-border: rgba(255, 255, 255, 0.16);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #1f2937;
  
  --accent-cyan: #06b6d4;
  --accent-cyan-rgb: 6, 182, 212;
  --accent-emerald: #10b981;
  --accent-emerald-rgb: 16, 185, 129;
  --accent-orange: #f97316;
  --accent-orange-rgb: 249, 115, 22;
  
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glow-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
  
  /* Shared variables */
  --font-title: 'Outfit', 'Inter', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
body.light-theme {
  --bg-color: #f1f5f9;
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --panel-bg: rgba(255, 255, 255, 0.8);
  --panel-border: rgba(0, 0, 0, 0.06);
  --panel-hover-border: rgba(0, 0, 0, 0.12);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dark: #f1f5f9;
  
  --accent-cyan: #0891b2;
  --accent-cyan-rgb: 8, 145, 178;
  --accent-emerald: #059669;
  --accent-emerald-rgb: 5, 150, 105;
  --accent-orange: #ea580c;
  --accent-orange-rgb: 234, 88, 12;
  
  --card-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
  --glow-shadow: 0 0 20px rgba(8, 145, 178, 0.08);
}

/* Base resets & styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background var(--transition-normal), color var(--transition-normal);
}

/* App Layout Grid */
.app-container {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  width: 100vw;
  padding: 16px;
  gap: 16px;
}

/* Header styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  z-index: 10;
}

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

.brand-icon {
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand h1 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.axis-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  padding: 6px 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--panel-border);
}

.axis-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.axis-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

select {
  background: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border var(--transition-fast);
}

select:focus {
  border-color: var(--accent-cyan);
}

/* Theme & settings toggles */
.toggle-btn {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  width: 38px;
  height: 38px;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-cyan);
}

body.light-theme .toggle-btn:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* Dashboard Workspace Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 16px;
  overflow: hidden;
  height: 100%;
}

/* Sidebar panel standard style */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all var(--transition-normal);
}

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

.panel-header h2 {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.panel-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Left Filter Sidebar Details */
.search-container {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

body.light-theme .search-input {
  background: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-shadow);
}

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

/* Category Checkboxes */
.filter-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.category-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: var(--border-radius-sm);
  transition: background var(--transition-fast);
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.04);
}

body.light-theme .checkbox-label:hover {
  background: rgba(0, 0, 0, 0.02);
}

.checkbox-label input {
  display: none;
}

.custom-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.checkbox-label input:checked + .custom-checkbox {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.checkbox-label input:checked + .custom-checkbox::after {
  content: "✓";
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
}

.checkbox-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.indicator-stainless {
  background: var(--accent-cyan);
}
.indicator-high-alloy {
  background: var(--accent-emerald);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border-radius: 0;
  width: 11px;
  height: 10px;
}
.indicator-carbon {
  background: var(--accent-orange);
  border-radius: 2px;
}

/* Sliders */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.slider-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.slider-val {
  font-weight: bold;
  color: var(--accent-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

body.light-theme input[type="range"] {
  background: rgba(0, 0, 0, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  transition: transform var(--transition-fast);
  border: 2px solid var(--bg-color);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Custom Settings Switches */
.setting-switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 20px;
}

body.light-theme .slider-switch {
  background-color: rgba(0, 0, 0, 0.1);
}

.slider-switch:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider-switch {
  background-color: var(--accent-cyan);
}

input:checked + .slider-switch:before {
  transform: translateX(16px);
}

/* Preset Buttons */
.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

body.light-theme .btn {
  background: rgba(0, 0, 0, 0.02);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

body.light-theme .btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn.primary {
  background: var(--accent-cyan);
  color: white;
  border: none;
}

.btn.primary:hover {
  background: #0891b2;
}

.btn.full-width {
  grid-column: span 2;
}

/* Center Chart Panel */
.chart-panel {
  display: flex;
  flex-direction: column;
  position: relative;
}

.chart-wrapper {
  flex: 1;
  position: relative;
  padding: 10px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#mainChart {
  width: 100% !important;
  height: 100% !important;
}

/* Right Legend Sidebar Details */
.legend-panel {
  display: flex;
  flex-direction: column;
}

.legend-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.legend-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border);
}

body.light-theme .legend-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.legend-item.highlighted {
  background: rgba(6, 182, 212, 0.08) !important;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.05);
}

body.light-theme .legend-item.highlighted {
  background: rgba(8, 145, 178, 0.06) !important;
}

.legend-item-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-item-stats {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Detail Drawer (Slide-Out Side Panel) */
.detail-drawer {
  position: fixed;
  top: 16px;
  right: -420px; /* Hidden by default */
  width: 380px;
  height: calc(100vh - 32px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right var(--transition-normal);
  overflow: hidden;
}

.detail-drawer.open {
  right: 16px;
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-title-group h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.steel-type-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.badge-stainless {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-high-alloy {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-carbon {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent-orange);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.close-drawer {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.close-drawer:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Info Paragraph */
.drawer-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Info metadata grid */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.meta-card {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.light-theme .meta-card {
  background: rgba(255, 255, 255, 0.5);
}

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

.meta-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.price-stars {
  color: #fbbf24 !important;
}

/* Radar-like Attributes Gauge Bars */
.attr-gauges {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gauge-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gauge-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
}

.gauge-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

body.light-theme .gauge-bar-bg {
  background: rgba(0, 0, 0, 0.08);
}

.gauge-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}

.fill-toughness {
  background: linear-gradient(90deg, #f87171, #ef4444);
}
.fill-edge {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
}
.fill-corrosion {
  background: linear-gradient(90deg, #34d399, #10b981);
}

/* Composition Progress List */
.composition-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.comp-badge {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.light-theme .comp-badge {
  background: rgba(255, 255, 255, 0.5);
}

.comp-element {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.comp-value {
  font-size: 0.75rem;
  color: var(--text-main);
  margin-top: 2px;
}

.comp-name {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Variants Table */
.variants-section table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.8rem;
}

.variants-section th {
  text-align: left;
  padding: 6px 8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
}

.variants-section td {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

body.light-theme .variants-section td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.02);
}

.variants-section tr.active-variant {
  background: rgba(6, 182, 212, 0.06);
  font-weight: 600;
}

/* Empty states */
.empty-legend {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 3px;
}

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

/* Responsive Overrides */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr 200px;
  }
  .legend-panel {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .app-container {
    height: auto;
    overflow-y: auto;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 400px auto;
  }
  .legend-panel {
    grid-column: span 1;
  }
  header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .header-controls {
    flex-direction: column;
    gap: 10px;
  }
  .axis-controls {
    width: 100%;
    justify-content: space-between;
  }
}

/* About & Credits Modal Styling */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 460px;
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 24px;
}

.credit-card, .patreon-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.light-theme .credit-card, 
body.light-theme .patreon-card {
  background: rgba(0, 0, 0, 0.02);
}

.credit-card h4, .patreon-card h4 {
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.credit-card p, .patreon-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.credit-card a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
}
.credit-card a:hover {
  text-decoration: underline;
}

.patreon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  padding: 10px 16px !important;
  background: #ff424d !important; /* Patreon official coral red */
  color: white !important;
  border-radius: var(--border-radius-md);
  transition: opacity var(--transition-fast) !important;
  border: none !important;
}

.patreon-link:hover {
  opacity: 0.9;
}

