/* ============================================
   Baseball FIP Calculator - CSS Styles
   Neobrutalism Design System
   ============================================ */

/* Global box-sizing */
.fip-calculator-container,
.fip-calculator-container *,
.fip-calculator-container *::before,
.fip-calculator-container *::after {
  box-sizing: border-box;
}

/* ============================================
   CSS Variables - Light Mode (Default)
   ============================================ */
.fip-calculator-container {
  /* Background colors */
  --bg-primary: #f5f5f0;
  --bg-secondary: #fff;
  --bg-section: #fff;
  
  /* Borders */
  --border-color: #333;
  
  /* Text colors */
  --text-primary: #222;
  --text-secondary: #555;
  --text-light: #666;
  
  /* Brand colors */
  --color-accent: #3498db;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-danger: #e74c3c;
  --color-purple: #9b59b6;
  --color-teal: #1abc9c;
  
  /* Grade colors */
  --grade-excellent: #3b82f6;
  --grade-great: #60a5fa;
  --grade-good: #34d399;
  --grade-average: #fbbf24;
  --grade-below: #f97316;
  --grade-poor: #ef4444;
  
  /* Shadows (neobrutalism) */
  --shadow-sm: 2px 2px 0 rgba(0,0,0,0.1);
  --shadow-md: 4px 4px 0 rgba(0,0,0,0.15);
  --shadow-lg: 8px 8px 0 rgba(0,0,0,0.15);
  
  /* Border radius */
  --radius-container: 8px;
  --radius-section: 6px;
  --radius-button: 4px;
  --radius-input: 4px;
  
  /* Input focus */
  --input-focus-bg: #fffacd;
  
  /* Header title */
  --title-color: #2c3e50;
  --title-shadow: 2px 2px 0 rgba(255,255,255,0.5);
  
  /* Button hover */
  --btn-hover-overlay: rgba(0,0,0,0.1);
  
  /* Copy button */
  --copy-btn-bg: #fff;
  --copy-btn-hover-bg: #f0f0f0;
}

/* ============================================
   Dark Mode - Manual Toggle
   ============================================ */
.fip-calculator-container.dark {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-section: #2d2d2d;
  --border-color: #e0e0e0;
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-light: #909090;
  --color-accent: #5dade2;
  --color-success: #52c77a;
  --color-warning: #f5b041;
  --color-danger: #ec7063;
  --color-purple: #af7ac5;
  --color-teal: #48d1cc;
  --grade-excellent: #5dade2;
  --grade-great: #85c1e9;
  --grade-good: #58d68d;
  --grade-average: #f7dc6f;
  --grade-below: #f8c471;
  --grade-poor: #ec7063;
  --shadow-sm: 2px 2px 0 rgba(255,255,255,0.08);
  --shadow-md: 4px 4px 0 rgba(255,255,255,0.12);
  --shadow-lg: 8px 8px 0 rgba(255,255,255,0.12);
  --input-focus-bg: #3a3a3a;
  --title-color: #7fb3d5;
  --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  --btn-hover-overlay: rgba(255,255,255,0.1);
  --copy-btn-bg: #3a3a3a;
  --copy-btn-hover-bg: #4a4a4a;
}

/* ============================================
   Dark Mode - System Auto Detection
   ============================================ */
@media (prefers-color-scheme: dark) {
  .fip-calculator-container:not(.dark):not(.light) {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-section: #2d2d2d;
    --border-color: #e0e0e0;
    --text-primary: #e8e8e8;
    --text-secondary: #b0b0b0;
    --text-light: #909090;
    --color-accent: #5dade2;
    --color-success: #52c77a;
    --color-warning: #f5b041;
    --color-danger: #ec7063;
    --color-purple: #af7ac5;
    --color-teal: #48d1cc;
    --grade-excellent: #5dade2;
    --grade-great: #85c1e9;
    --grade-good: #58d68d;
    --grade-average: #f7dc6f;
    --grade-below: #f8c471;
    --grade-poor: #ec7063;
    --shadow-sm: 2px 2px 0 rgba(255,255,255,0.08);
    --shadow-md: 4px 4px 0 rgba(255,255,255,0.12);
    --shadow-lg: 8px 8px 0 rgba(255,255,255,0.12);
    --input-focus-bg: #3a3a3a;
    --title-color: #7fb3d5;
    --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    --btn-hover-overlay: rgba(255,255,255,0.1);
    --copy-btn-bg: #3a3a3a;
    --copy-btn-hover-bg: #4a4a4a;
  }
}

/* ============================================
   Main Container
   ============================================ */
.fip-calculator-container {
  position: relative;
  max-width: 900px;
  width: 100%;
  margin: 8px auto;
  padding: 8px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-container);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  line-height: 1.5;
}

/* ============================================
   Dark Mode Toggle Button
   ============================================ */
.dark-mode-toggle {
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 10;
}

.dark-mode-toggle:hover {
  transform: translate(0.5px, 0.5px);
  box-shadow: 1.5px 1.5px 0 rgba(0,0,0,0.15);
}

.dark-mode-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* ============================================
   Header
   ============================================ */
.calculator-header {
  text-align: center;
  margin-bottom: 8px;
  padding: 10px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-sm);
}

.main-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--title-color);
  margin: 0 0 4px 0;
  text-shadow: var(--title-shadow);
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================
   2-Column Grid Layout
   ============================================ */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ============================================
   Section Styles
   ============================================ */
.input-section,
.result-section {
  background: var(--bg-section);
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-header svg {
  width: 18px;
  height: 18px;
  stroke: var(--color-accent);
}

/* ============================================
   Input Styles
   ============================================ */
.input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.input-row.three-col .input-group {
  flex: 1;
  min-width: 0;
}

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

.input-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.input-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.input-group input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.input-group input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  margin-left: 6px;
}

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

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

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

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

/* ============================================
   Button Styles
   ============================================ */
.calculate-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: var(--color-accent);
  color: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-button);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.calculate-btn:hover {
  filter: brightness(1.05);
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.calculate-btn:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.calculate-btn svg {
  stroke: #fff;
}

/* Secondary buttons */
.button-group {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.sample-btn,
.reset-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.sample-btn {
  background: var(--color-success);
  color: #fff;
}

.reset-btn {
  background: var(--color-warning);
  color: #fff;
}

.sample-btn:hover,
.reset-btn:hover {
  filter: brightness(1.05);
  transform: translate(0.5px, 0.5px);
  box-shadow: 1.5px 1.5px 0 rgba(0,0,0,0.2);
}

.sample-btn:active,
.reset-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.sample-btn svg,
.reset-btn svg {
  stroke: #fff;
}

/* ============================================
   Formula Box
   ============================================ */
.formula-box {
  margin-top: 10px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(52,152,219,0.1) 0%, rgba(155,89,182,0.1) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  text-align: center;
}

.formula-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.formula-content {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.5px;
}

/* ============================================
   Main Result Card
   ============================================ */
.main-result-card {
  text-align: center;
  padding: 16px 12px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-md);
}

.main-result-card .result-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.fip-value {
  font-size: 48px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--text-light);
  line-height: 1;
  margin: 8px 0;
  transition: color 0.3s;
}

.fip-grade {
  display: inline-block;
  padding: 6px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: #9ca3af;
  border-radius: var(--radius-button);
  margin-bottom: 8px;
  transition: background 0.3s;
}

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

/* FIP Grade Colors */
.fip-value.excellent { color: var(--grade-excellent); }
.fip-value.great { color: var(--grade-great); }
.fip-value.good { color: var(--grade-good); }
.fip-value.average { color: var(--grade-average); }
.fip-value.below-average { color: var(--grade-below); }
.fip-value.poor { color: var(--grade-poor); }

.fip-grade.excellent { background: var(--grade-excellent); }
.fip-grade.great { background: var(--grade-great); }
.fip-grade.good { background: var(--grade-good); }
.fip-grade.average { background: var(--grade-average); }
.fip-grade.below-average { background: var(--grade-below); }
.fip-grade.poor { background: var(--grade-poor); }

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.stat-card {
  text-align: center;
  padding: 10px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 18px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--color-accent);
  margin-bottom: 2px;
  transition: color 0.3s;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stat-desc {
  font-size: 11px;
  color: var(--text-light);
}

/* Stat value grade colors */
.stat-value.excellent { color: var(--grade-excellent); }
.stat-value.great { color: var(--grade-great); }
.stat-value.good { color: var(--grade-good); }
.stat-value.average { color: var(--grade-average); }
.stat-value.below-average { color: var(--grade-below); }
.stat-value.poor { color: var(--grade-poor); }

/* ============================================
   FIP Meter (Visual Gauge)
   ============================================ */
.fip-meter {
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-sm);
}

.meter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
}

.meter-bar {
  position: relative;
  height: 20px;
  background: linear-gradient(to right, 
    var(--grade-excellent) 0%, 
    var(--grade-great) 16.6%, 
    var(--grade-good) 33.3%, 
    var(--grade-average) 50%, 
    var(--grade-below) 66.6%, 
    var(--grade-poor) 83.3%,
    var(--grade-poor) 100%
  );
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: rgba(255,255,255,0.3);
  transition: width 0.5s ease-out;
}

.meter-pointer {
  position: absolute;
  top: -6px;
  left: 0;
  width: 4px;
  height: 32px;
  background: var(--border-color);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.5s ease-out;
  opacity: 0;
  box-shadow: var(--shadow-sm);
}

.meter-pointer.active {
  opacity: 1;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 4px;
}

.meter-labels span {
  font-size: 11px;
  font-weight: 600;
}

.label-excellent { color: var(--grade-excellent); }
.label-great { color: var(--grade-great); }
.label-good { color: var(--grade-good); }
.label-average { color: var(--grade-average); }
.label-below { color: var(--grade-below); }
.label-poor { color: var(--grade-poor); }

/* ============================================
   Grade Section
   ============================================ */
.grade-section {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-md);
}

.grade-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.grade-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  text-align: center;
  transition: transform 0.2s;
}

.grade-item:hover {
  transform: scale(1.02);
}

.grade-badge {
  display: inline-block;
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  border-radius: 50%;
  margin-bottom: 4px;
}

.grade-item.excellent .grade-badge { background: var(--grade-excellent); }
.grade-item.great .grade-badge { background: var(--grade-great); }
.grade-item.good .grade-badge { background: var(--grade-good); }
.grade-item.average .grade-badge { background: var(--grade-average); }
.grade-item.below-average .grade-badge { background: var(--grade-below); }
.grade-item.poor .grade-badge { background: var(--grade-poor); }

.grade-range {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.grade-item .grade-desc {
  font-size: 10px;
  color: var(--text-light);
}

/* ============================================
   Info Section
   ============================================ */
.info-section {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(26,188,156,0.1) 0%, rgba(52,152,219,0.1) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
}

.info-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.info-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.info-content strong {
  color: var(--text-primary);
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  z-index: 1000;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast svg {
  stroke: var(--color-success);
  flex-shrink: 0;
}

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

/* ============================================
   Responsive - Tablet (768px or less)
   ============================================ */
@media (max-width: 768px) {
  .fip-calculator-container {
    margin: 6px 5px;
    padding: 7px;
    width: calc(100% - 10px);
  }

  .main-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .main-title {
    font-size: 22px;
  }

  .subtitle {
    font-size: 13px;
  }

  .section-header {
    font-size: 15px;
  }

  .dark-mode-toggle {
    font-size: 14px;
    padding: 5px 8px;
  }

  .grade-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .input-row.three-col {
    flex-wrap: wrap;
  }

  .input-row.three-col .input-group {
    flex: 1 1 calc(50% - 3px);
    min-width: calc(50% - 3px);
  }

  .input-row.three-col .input-group.constant-group {
    flex: 1 1 100%;
  }
}

/* ============================================
   Responsive - Mobile (480px or less)
   ============================================ */
@media (max-width: 480px) {
  .fip-calculator-container {
    padding: 6px;
    border-width: 1px;
  }

  .input-section,
  .result-section,
  .grade-section {
    padding: 6px;
  }

  .main-title {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
  }

  .fip-value {
    font-size: 40px;
  }

  .calculate-btn {
    font-size: 15px;
    padding: 10px;
  }

  .sample-btn,
  .reset-btn {
    font-size: 12.5px;
  }

  .grade-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-value {
    font-size: 16px;
  }

  .meter-labels span {
    font-size: 10px;
  }

  .toast {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}