/* ============================================
   Candela-Lux Converter - CSS Stylesheet
   Neobrutalism Design System
   ============================================ */

/* Global box-sizing */
.candela-lux-converter-container,
.candela-lux-converter-container *,
.candela-lux-converter-container *::before,
.candela-lux-converter-container *::after {
  box-sizing: border-box;
}

/* ============================================
   CSS Variables - Light Mode (Default)
   ============================================ */
.candela-lux-converter-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;
  
  /* 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;
  
  /* Light indicator */
  --ray-color: rgba(255, 200, 50, 0.6);
  --measurement-bg: #e8f4fc;
}

/* ============================================
   Dark Mode - Manual Toggle
   ============================================ */
.candela-lux-converter-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;
  --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;
  --ray-color: rgba(255, 220, 100, 0.4);
  --measurement-bg: #2a3a4a;
}

/* ============================================
   Dark Mode - System Preference Auto Detection
   ============================================ */
@media (prefers-color-scheme: dark) {
  .candela-lux-converter-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;
    --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;
    --ray-color: rgba(255, 220, 100, 0.4);
    --measurement-bg: #2a3a4a;
  }
}

/* ============================================
   Main Container
   ============================================ */
.candela-lux-converter-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: 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);
  margin: 0 0 6px 0;
  text-shadow: var(--title-shadow);
}

.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 {
  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 Group
   ============================================ */
.input-group {
  margin-bottom: 8px;
}

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

/* Mode Tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
}

.mode-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mode-tab .mode-icon {
  font-size: 16px;
}

.mode-tab:hover {
  background: var(--btn-hover-overlay);
}

.mode-tab.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Input with unit */
.input-with-unit {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-with-unit input {
  flex: 1;
  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: 'Courier New', monospace;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.input-with-unit 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);
}

.unit-badge {
  padding: 7px 12px;
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.unit-select {
  padding: 7px 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.unit-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

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

/* ============================================
   Buttons
   ============================================ */
.convert-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;
}

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

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

.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-card {
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.result-card.main-result {
  position: relative;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--measurement-bg) 100%);
}

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

.result-value-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.result-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-accent);
  font-family: 'Courier New', monospace;
}

.result-unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: var(--copy-btn-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.copy-btn:hover {
  background: var(--copy-btn-hover-bg);
  transform: scale(1.05);
}

.copy-btn:active {
  transform: scale(0.95);
}

.copy-btn svg {
  display: block;
}

/* ============================================
   Visual Light Indicator
   ============================================ */
.visual-section {
  margin-bottom: 8px;
}

.light-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-sm);
  min-height: 70px;
}

.light-source {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.light-bulb {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--ray-color));
  transition: all 0.3s;
}

.light-bulb.active {
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 8px var(--ray-color));
  }
  to {
    filter: drop-shadow(0 0 20px var(--ray-color));
  }
}

.light-rays {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ray-color), transparent);
  transition: width 0.5s ease-out;
}

.distance-line {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px;
  border-bottom: 2px dashed var(--text-light);
  position: relative;
}

.distance-label {
  position: absolute;
  bottom: 8px;
  background: var(--bg-section);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.measurement-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  background: var(--measurement-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
}

.lux-display {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-accent);
  font-family: 'Courier New', monospace;
}

/* ============================================
   Info Card
   ============================================ */
.info-card {
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

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

.formula {
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-button);
  margin-bottom: 6px;
  text-align: center;
}

.formula-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  font-family: 'Courier New', monospace;
}

.info-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-light);
}

/* ============================================
   Reference Card
   ============================================ */
.reference-card {
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-sm);
}

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

.reference-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ref-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  font-size: 12px;
}

.ref-icon {
  font-size: 14px;
}

.ref-name {
  flex: 1;
  color: var(--text-secondary);
}

.ref-value {
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

/* ============================================
   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) {
  .candela-lux-converter-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;
  }
  
  .result-value {
    font-size: 24px;
  }
  
  .reference-items {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Responsive - Mobile (480px or less)
   ============================================ */
@media (max-width: 480px) {
  .candela-lux-converter-container {
    padding: 6px;
    border-width: 1px;
  }
  
  .input-section,
  .result-section {
    padding: 6px;
  }
  
  .main-title {
    font-size: 22px;
  }
  
  .subtitle {
    font-size: 12.5px;
  }
  
  .mode-tab {
    font-size: 11px;
    padding: 6px 4px;
  }
  
  .mode-tab .mode-icon {
    font-size: 14px;
  }
  
  .result-value {
    font-size: 22px;
  }
  
  .light-indicator {
    padding: 10px 12px;
    min-height: 60px;
  }
  
  .light-bulb {
    font-size: 24px;
  }
  
  .lux-display {
    font-size: 12px;
  }
}