/* ============================================
   Biorhythm Calculator - CSS Styles
   Neobrutalism Design System
   ============================================ */

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

/* ============================================
   CSS Variables - Light Mode (Default)
   ============================================ */
.biorhythm-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;
  
  /* Biorhythm specific colors */
  --color-physical: #e74c3c;
  --color-emotional: #27ae60;
  --color-intellectual: #3498db;
  
  /* 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 background */
  --btn-hover-overlay: rgba(0,0,0,0.1);
  
  /* Copy button background */
  --copy-btn-bg: #fff;
  --copy-btn-hover-bg: #f0f0f0;
  
  /* Chart grid */
  --chart-grid-color: rgba(0,0,0,0.1);
  --chart-zero-line: rgba(0,0,0,0.3);
}

/* ============================================
   Manual Dark Mode (.dark class)
   ============================================ */
.biorhythm-calculator-container.dark {
  /* Background colors */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-section: #2d2d2d;
  
  /* Borders */
  --border-color: #e0e0e0;
  
  /* Text colors */
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-light: #909090;
  
  /* Brand colors - brighter for dark bg */
  --color-accent: #5dade2;
  --color-success: #52c77a;
  --color-warning: #f5b041;
  --color-danger: #ec7063;
  --color-purple: #af7ac5;
  --color-teal: #48d1cc;
  
  /* Biorhythm specific colors - brighter */
  --color-physical: #ec7063;
  --color-emotional: #52c77a;
  --color-intellectual: #5dade2;
  
  /* Shadows */
  --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 */
  --input-focus-bg: #3a3a3a;
  
  /* Header title */
  --title-color: #7fb3d5;
  --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  
  /* Button hover background */
  --btn-hover-overlay: rgba(255,255,255,0.1);
  
  /* Copy button background */
  --copy-btn-bg: #3a3a3a;
  --copy-btn-hover-bg: #4a4a4a;
  
  /* Chart grid */
  --chart-grid-color: rgba(255,255,255,0.1);
  --chart-zero-line: rgba(255,255,255,0.3);
}

/* ============================================
   System Dark Mode Auto Detection
   ============================================ */
@media (prefers-color-scheme: dark) {
  .biorhythm-calculator-container:not(.dark):not(.light) {
    /* Background colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-section: #2d2d2d;
    
    /* Borders */
    --border-color: #e0e0e0;
    
    /* Text colors */
    --text-primary: #e8e8e8;
    --text-secondary: #b0b0b0;
    --text-light: #909090;
    
    /* Brand colors */
    --color-accent: #5dade2;
    --color-success: #52c77a;
    --color-warning: #f5b041;
    --color-danger: #ec7063;
    --color-purple: #af7ac5;
    --color-teal: #48d1cc;
    
    /* Biorhythm specific colors */
    --color-physical: #ec7063;
    --color-emotional: #52c77a;
    --color-intellectual: #5dade2;
    
    /* Shadows */
    --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 */
    --input-focus-bg: #3a3a3a;
    
    /* Header title */
    --title-color: #7fb3d5;
    --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    
    /* Button hover background */
    --btn-hover-overlay: rgba(255,255,255,0.1);
    
    /* Copy button background */
    --copy-btn-bg: #3a3a3a;
    --copy-btn-hover-bg: #4a4a4a;
    
    /* Chart grid */
    --chart-grid-color: rgba(255,255,255,0.1);
    --chart-zero-line: rgba(255,255,255,0.3);
  }
}

/* ============================================
   Main Container
   ============================================ */
.biorhythm-calculator-container {
  position: relative;
  max-width: 1000px;
  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: 8px;
  right: 8px;
  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: 8px 0;
}

.main-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--title-color);
  text-shadow: var(--title-shadow);
  margin: 0 0 6px 0;
}

.subtitle {
  font-size: 13.5px;
  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,
.chart-section,
.advice-section,
.info-section {
  background: var(--bg-section);
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-md);
}

.chart-section,
.advice-section,
.info-section {
  margin-top: 8px;
}

.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);
  flex-shrink: 0;
}

/* ============================================
   Input Styles
   ============================================ */
.input-group {
  margin-bottom: 8px;
}

.input-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.input-group input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.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.1);
}

.input-description {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-light);
}

/* ============================================
   Button Styles (Neobrutalism)
   ============================================ */
.calculate-btn {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: var(--color-accent);
  color: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-button);
  font-size: 15px;
  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: 6px;
}

.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 {
  width: 18px;
  height: 18px;
}

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

.sample-btn,
.reset-btn {
  flex: 1;
  padding: 6px 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: 4px;
}

.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;
}

/* ============================================
   Result Section
   ============================================ */
.result-content {
  min-height: 200px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
  color: var(--text-light);
}

.result-placeholder svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

.result-placeholder p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

/* Rhythm cards */
.rhythm-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rhythm-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
}

.rhythm-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
}

.rhythm-info {
  flex: 1;
}

.rhythm-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.rhythm-value {
  font-size: 20px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.rhythm-value.physical {
  color: var(--color-physical);
}

.rhythm-value.emotional {
  color: var(--color-emotional);
}

.rhythm-value.intellectual {
  color: var(--color-intellectual);
}

.rhythm-bar {
  height: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin-top: 4px;
  overflow: hidden;
}

.rhythm-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.rhythm-bar-fill.physical {
  background: var(--color-physical);
}

.rhythm-bar-fill.emotional {
  background: var(--color-emotional);
}

.rhythm-bar-fill.intellectual {
  background: var(--color-intellectual);
}

/* Days lived badge */
.days-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  margin-top: 8px;
}

.days-badge-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.days-badge-label {
  font-size: 13px;
  opacity: 0.9;
}

/* ============================================
   Chart Section
   ============================================ */
.chart-wrapper {
  width: 100%;
  height: 280px;
  position: relative;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

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

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
}

.legend-item.physical .legend-dot {
  background: var(--color-physical);
}

.legend-item.emotional .legend-dot {
  background: var(--color-emotional);
}

.legend-item.intellectual .legend-dot {
  background: var(--color-intellectual);
}

/* ============================================
   Advice Section
   ============================================ */
.advice-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.advice-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
}

.advice-icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  flex-shrink: 0;
}

.advice-text {
  flex: 1;
}

.advice-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.advice-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* Advice types */
.advice-item.positive {
  border-left: 3px solid var(--color-success);
}

.advice-item.caution {
  border-left: 3px solid var(--color-warning);
}

.advice-item.critical {
  border-left: 3px solid var(--color-danger);
}

/* ============================================
   Info Section
   ============================================ */
.info-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.info-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
}

.info-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.info-text strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.info-text p {
  font-size: 12px;
  color: var(--text-light);
  margin: 0;
  line-height: 1.4;
}

.physical-info {
  border-top: 3px solid var(--color-physical);
}

.emotional-info {
  border-top: 3px solid var(--color-emotional);
}

.intellectual-info {
  border-top: 3px solid var(--color-intellectual);
}

/* ============================================
   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: 10px 15px;
  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: 300px;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

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

.toast-title {
  font-size: 13.5px;
  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) {
  .biorhythm-calculator-container {
    margin: 6px 5px;
    padding: 7px;
    width: calc(100% - 10px);
  }

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

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

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

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

  .info-content {
    grid-template-columns: 1fr;
  }

  .chart-legend {
    flex-wrap: wrap;
    gap: 12px;
  }
}

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

  .input-section,
  .result-section,
  .chart-section,
  .advice-section,
  .info-section {
    padding: 6px;
  }

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

  .subtitle {
    font-size: 12.5px;
  }

  .rhythm-value {
    font-size: 18px;
  }

  .days-badge-value {
    font-size: 18px;
  }

  .chart-wrapper {
    height: 220px;
  }
}