/* CSS Design System & Layout - Premium Bike Tools Suite */

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

:root {
  /* Default: Dark Theme Variables (System by default, or fallback) */
  --bg-deep: #07090e;
  --bg-card: rgba(16, 20, 30, 0.5);
  --bg-card-hover: rgba(22, 28, 42, 0.65);
  --border-default: rgba(255, 255, 255, 0.07);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --bg-slider: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(0, 0, 0, 0.2);
  --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  
  /* Modern Pastel Accents */
  --lime: #82e2c2; /* Pastel Mint Green */
  --lime-glow: rgba(130, 226, 194, 0.3);
  --teal: #b5b2ff; /* Pastel Periwinkle Blue */
  --teal-glow: rgba(181, 178, 255, 0.35);
  --border-glow: rgba(130, 226, 194, 0.15);
  
  --coral: #ff7675;
  --purple: #c5a3ff;
  --warning: #fab1a0;
  
  /* Font Families */
  --font-header: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  /* Shadows & Blurs */
  --blur-glass: blur(16px);
  --shadow-glow-lime: 0 0 15px var(--lime-glow);
  --shadow-glow-teal: 0 0 15px var(--teal-glow);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* System Light Theme fallback (when no explicit theme override is set) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-deep: #f4f6fa;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --border-default: rgba(0, 0, 0, 0.08);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --bg-slider: rgba(0, 0, 0, 0.06);
    --bg-input: rgba(255, 255, 255, 0.8);
    --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.05);
    
    /* Slightly darker pastel contrast for light mode */
    --lime: #40bfa0;
    --teal: #7874f6;
    --lime-glow: rgba(64, 191, 160, 0.2);
    --teal-glow: rgba(120, 116, 246, 0.2);
    --border-glow: rgba(120, 116, 246, 0.1);
  }
}

/* Explicit Light Theme Override */
:root[data-theme="light"] {
  --bg-deep: #f4f6fa;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --border-default: rgba(0, 0, 0, 0.08);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --bg-slider: rgba(0, 0, 0, 0.06);
  --bg-input: rgba(255, 255, 255, 0.8);
  --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.05);
  
  --lime: #40bfa0;
  --teal: #7874f6;
  --lime-glow: rgba(64, 191, 160, 0.2);
  --teal-glow: rgba(120, 116, 246, 0.2);
  --border-glow: rgba(120, 116, 246, 0.1);
}

/* Explicit Dark Theme Override */
:root[data-theme="dark"] {
  --bg-deep: #07090e;
  --bg-card: rgba(16, 20, 30, 0.5);
  --bg-card-hover: rgba(22, 28, 42, 0.65);
  --border-default: rgba(255, 255, 255, 0.07);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --bg-slider: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(0, 0, 0, 0.2);
  --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  
  --lime: #82e2c2;
  --lime-glow: rgba(130, 226, 194, 0.3);
  --teal: #b5b2ff;
  --teal-glow: rgba(181, 178, 255, 0.35);
  --border-glow: rgba(130, 226, 194, 0.15);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
  background-color: var(--bg-deep);
  background-image: 
    radial-gradient(circle at 10% 20%, var(--teal-glow) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, var(--lime-glow) 0%, transparent 45%);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  padding-bottom: 4rem;
  transition: background-color 0.4s ease, color 0.4s ease, background-image 0.4s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Header & Container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 1.5rem;
  position: relative;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-group svg {
  fill: none;
  stroke: var(--lime);
  stroke-width: 2;
  filter: drop-shadow(0 0 4px var(--lime-glow));
}

h1 {
  font-family: var(--font-header);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, var(--lime) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Settings Controls (Metric/Imperial) */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.unit-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.25rem;
  border-radius: 30px;
  border: 1px solid var(--border-default);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.toggle-btn.active {
  background: var(--lime);
  color: #000000;
  box-shadow: 0 0 10px var(--lime-glow);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-default);
}

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.tab-btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--lime-glow) 0%, transparent 100%);
  border-color: var(--lime);
  color: var(--lime);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.02);
}

.tab-btn.active svg {
  stroke: var(--lime);
  filter: drop-shadow(0 0 3px var(--lime-glow));
}

/* Theme Toggle Controls */
.theme-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.25rem;
  border-radius: 30px;
  border: 1px solid var(--border-default);
}

:root[data-theme="light"] .theme-toggle,
:root[data-theme="light"] .unit-toggle {
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="light"] .logo-group svg {
  stroke: var(--lime);
  filter: drop-shadow(0 0 2px rgba(64, 191, 160, 0.2));
}

:root[data-theme="light"] h1 {
  background: linear-gradient(135deg, #1e293b 40%, var(--lime) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Content Layout (Grid) */
.tool-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.tool-section.active {
  display: block;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 2rem;
}

@media (max-width: 900px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphic Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow-glass);
  transition: var(--transition-smooth);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.card-title {
  font-family: var(--font-header);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
}

.card-title svg {
  stroke: var(--teal);
}

/* Custom Interactive Sliders & Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

@media (max-width: 600px) {
  .form-group.full-width {
    grid-column: span 1;
  }
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

/* Dropdown styling */
select, input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  outline: none;
  transition: var(--transition-smooth);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

select:focus, input[type="number"]:focus, input[type="text"]:focus {
  border-color: var(--teal);
  box-shadow: 0 0 10px var(--teal-glow);
  background: var(--bg-card-hover);
}

/* Futuristic Sliders */
.slider-group {
  margin-top: 0.5rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.slider-val {
  font-family: var(--font-header);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--lime);
}

.slider-val span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 0.15rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-slider);
  border-radius: 5px;
  outline: none;
  margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lime);
  cursor: pointer;
  box-shadow: 0 0 8px var(--lime-glow);
  transition: transform 0.1s;
}

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

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--lime);
  cursor: pointer;
  box-shadow: 0 0 8px var(--lime-glow);
  transition: transform 0.1s;
}

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

/* Radio Cards (Select buttons) */
.radio-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.radio-card {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.radio-card input {
  display: none;
}

.radio-card span {
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.radio-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-card-hover);
}

.radio-card.selected {
  background: var(--lime-glow);
  border-color: var(--lime);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.02);
}

.radio-card.selected span {
  color: var(--lime);
}

/* Results Display Panel */
.results-card {
  background: radial-gradient(circle at top right, var(--teal-glow) 0%, var(--bg-card) 55%);
  border-color: rgba(0, 240, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  justify-content: space-between;
}

.results-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1rem;
}

.results-heading {
  font-family: var(--font-header);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.results-heading svg {
  stroke: var(--lime);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.result-block {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.result-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--text-muted);
  transition: var(--transition-smooth);
}

.result-block.front::before {
  background: var(--teal);
}

.result-block.rear::before {
  background: var(--lime);
}

.result-block.front:hover {
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.25);
  transform: translateY(-2px);
}

.result-block.rear:hover {
  box-shadow: 0 4px 20px rgba(204, 255, 0, 0.1);
  border-color: rgba(204, 255, 0, 0.25);
  transform: translateY(-2px);
}

.result-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.result-val {
  font-family: var(--font-header);
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.result-block.front .result-val {
  color: var(--teal);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.result-block.rear .result-val {
  color: var(--lime);
  text-shadow: 0 0 10px rgba(204, 255, 0, 0.2);
}

.result-val span {
  font-size: 1rem;
  font-weight: 500;
  margin-left: 0.15rem;
}

.result-sub {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Dynamic Interactive SVG Bicycle Diagram */
.bike-visualization {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
  height: 180px;
}

.bike-svg {
  width: 240px;
  height: auto;
  transition: var(--transition-smooth);
}

.bike-svg path {
  transition: var(--transition-smooth);
}

.bike-svg .wheel {
  stroke: #475569;
  stroke-width: 4px;
}

.bike-svg .tire-air {
  stroke-dasharray: 2, 2;
}

.bike-svg.active-front .front-tire {
  stroke: var(--teal);
  filter: drop-shadow(0 0 6px var(--teal-glow));
  stroke-width: 6px;
}

.bike-svg.active-rear .rear-tire {
  stroke: var(--lime);
  filter: drop-shadow(0 0 6px var(--lime-glow));
  stroke-width: 6px;
}

/* Warnings and Notices */
.warning-block {
  background: rgba(255, 170, 0, 0.05);
  border: 1px solid rgba(255, 170, 0, 0.2);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.8rem;
  color: #ffd27f;
  display: none; /* Controlled by JS */
  animation: pulseGlow 2s infinite ease-in-out;
}

.warning-block svg {
  stroke: var(--warning);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* Generic List & Table outputs */
.output-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.output-item {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-default);
  padding: 0.9rem 1.25rem;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.output-item-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.output-item-value {
  font-family: var(--font-header);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--lime);
}

.output-item-value span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.15rem;
}

/* Interactive Table Styling */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: rgba(0, 0, 0, 0.15);
  margin-top: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

th {
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-header);
  font-weight: 600;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  background: rgba(204, 255, 0, 0.1);
  color: var(--lime);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Action Buttons */
.btn {
  width: 100%;
  background: linear-gradient(135deg, var(--teal) 0%, rgba(0, 240, 255, 0.7) 100%);
  border: none;
  padding: 0.9rem;
  border-radius: 12px;
  color: #000000;
  font-family: var(--font-header);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.35);
  opacity: 0.95;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(255, 170, 0, 0.1);
    border-color: rgba(255, 170, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.25);
    border-color: rgba(255, 170, 0, 0.4);
  }
}

/* Info Tooltips */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  margin-left: 0.25rem;
}

.help-icon:hover {
  background: rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
}

/* Explanatory Cards */
.info-card {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 1.25rem;
}

.info-card h4 {
  font-family: var(--font-header);
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
