/* ReefLight Calc — в стиле golos.rureef.ru / tools.rureef.ru */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #4a6fa5;
  --primary-light: #6b8cbe;
  --accent: #7eb8da;
  --aqua: #5ba3b0;
  --bg: #f4f5f6;
  --card: #fafbfc;
  --text: #374151;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --success: #4caf50;
  --warning: #d97706;
  --danger: #dc2626;
  --coral: #e07a7a;
  --bubble: rgba(74, 111, 165, 0.08);
  --transition: all 0.3s ease;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --touch-min: 44px;
}

[data-theme="dark"] {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --border: #334155;
  --bubble: rgba(30, 58, 138, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --coral: #f87171;
}

html { scroll-behavior: smooth; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  font-size: 15px;
}

.bubbles { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.bubble {
  position: absolute;
  bottom: -100px;
  border-radius: 50%;
  background: var(--bubble);
  box-shadow: 0 0 8px var(--aqua);
  animation: rise 15s infinite ease-in;
}
@keyframes rise {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-100vh) scale(1.2); opacity: 0; }
}
.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 40px;
  background: radial-gradient(circle at 10% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 30% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 50% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 70% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 90% 50%, transparent 45%, var(--aqua) 50%);
  background-size: 20% 100%;
  animation: wave 8s linear infinite;
  opacity: 0.12;
}
[data-theme="dark"] .wave { opacity: 0.2; }
@keyframes wave {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  z-index: 1000;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 16px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 24px;
  flex: 1 1 auto;
  min-height: 0;
}

/* Шапка: название сервиса и кнопки (перевод, тема) на одном уровне */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: calc(12px + var(--safe-top));
  padding-bottom: 14px;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Переключатель языков RU/EN (Яндекс.Переводчик) */
.lang-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lang-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0.5;
}
.lang-btn:hover {
  opacity: 0.85;
  border-color: var(--primary);
  background: rgba(74, 111, 165, 0.08);
}
.lang-btn-active {
  opacity: 1;
  border: 2px solid var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.35), inset 0 0 0 1px rgba(74, 111, 165, 0.15);
}
[data-theme="dark"] .lang-btn {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .lang-btn:hover {
  border-color: var(--aqua);
  background: rgba(91, 163, 176, 0.15);
}
[data-theme="dark"] .lang-btn-active {
  border: 2px solid var(--aqua);
  background: rgba(91, 163, 176, 0.25);
  box-shadow: 0 0 0 3px rgba(91, 163, 176, 0.4), inset 0 0 0 1px rgba(91, 163, 176, 0.2);
}

.theme-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.theme-icon { font-size: 1rem; color: var(--text-light); pointer-events: none; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: inline-block; color: var(--aqua); }

.theme-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  width: 52px;
  height: 26px;
  border-radius: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: var(--transition);
  flex-shrink: 0;
}
.toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.3s;
}
[data-theme="dark"] .toggle-thumb {
  transform: translateX(26px);
  background: #94a3b8;
}

.header-row header {
  text-align: left;
  padding: 0;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.logo { font-size: 1.85rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
[data-theme="dark"] .logo { color: var(--aqua); }
.subtitle { font-size: 1rem; color: var(--text-light); max-width: 560px; margin: 0; line-height: 1.35; }
.protection-badge {
  display: inline-block;
  background: var(--accent);
  color: #2c5282;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 6px;
}
[data-theme="dark"] .protection-badge { color: #e3f2fd; }

/* Сетка: форма слева, результаты справа */
.main-grid {
  display: grid;
  gap: 20px;
  align-items: start;
}
@media (min-width: 900px) {
  .main-grid { grid-template-columns: 380px 1fr; }
}

/* Секции в стиле golos: section-header + section-icon */
.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-icon {
  width: 40px;
  height: 40px;
  margin-right: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
[data-theme="dark"] .section-icon { background: var(--aqua); color: #0f172a; }
.section-header h2, .section-title {
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 700;
  margin: 0;
}
[data-theme="dark"] .section-header h2, [data-theme="dark"] .section-title { color: var(--aqua); }
.section-title { display: flex; align-items: center; gap: 8px; padding-bottom: 0; border-bottom: none; margin-bottom: 12px; }
.section-title .icon { opacity: 0.9; }

/* Пресеты */
.presets-row { margin-bottom: 14px; }
.presets-label { font-size: 0.875rem; color: var(--text-light); margin-bottom: 8px; display: block; }
.btn-preset {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px 14px;
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
}
.btn-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(74, 111, 165, 0.06);
}
[data-theme="dark"] .btn-preset:hover { border-color: var(--aqua); color: var(--aqua); background: rgba(30, 58, 138, 0.15); }

/* Аккордеон в стиле карточек golos */
.accordion {
  width: 100%;
  padding: 14px 16px;
  min-height: var(--touch-min);
  text-align: left;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.accordion:hover { border-color: var(--primary); }
[data-theme="dark"] .accordion:hover { border-color: var(--aqua); }
.accordion::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-light);
  transition: transform 0.2s;
}
.accordion[aria-expanded="true"]::after { transform: rotate(180deg); }
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.accordion-content.show { max-height: 800px; }
.accordion-content .grid { padding: 12px 0 4px; }

/* Подсказка PAR */
.par-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  padding: 12px 14px;
  background: rgba(74, 111, 165, 0.06);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--coral);
  margin-top: 10px;
}
[data-theme="dark"] .par-hint { background: rgba(30, 58, 138, 0.1); }
.par-hint strong { color: var(--text); }

/* Поля ввода */
label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  transition: var(--transition);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}
[data-theme="dark"] input:focus, [data-theme="dark"] select:focus { border-color: var(--aqua); }
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-thumb { background: var(--aqua); }

/* Карточки (как в golos) */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.card:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06); }
[data-theme="dark"] .card:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .card h3 { color: var(--aqua); }
.card p, .card ul { font-size: 0.9rem; color: var(--text-light); margin-bottom: 6px; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card strong { color: var(--text); font-weight: 600; }

/* Кнопка «Рассчитать» — как submitBtn в golos */
button.btn-accent {
  width: 100%;
  padding: 14px 32px;
  min-height: var(--touch-min);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
button.btn-accent:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
}
[data-theme="dark"] button.btn-accent { background: var(--aqua); color: #0f172a; }
[data-theme="dark"] button.btn-accent:hover { background: #7eb8da; }
button.btn-accent:active { transform: translateY(0); }

.btn-secondary {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .btn-secondary:hover { border-color: var(--aqua); color: var(--aqua); }
.action-buttons { margin-bottom: 14px; }

/* Индикатор PAR */
.traffic-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}
.light-green { background: var(--success); }
.light-blue { background: var(--primary); }
.light-red { background: var(--danger); }

/* Прогресс-бар */
.progress-container {
  height: 8px;
  background: var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 10px 0;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--coral), var(--primary));
  transition: width 0.4s ease;
}
[data-theme="dark"] .progress-bar { background: linear-gradient(90deg, var(--coral), var(--aqua)); }

/* Ганта */
.gantt {
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 10px;
  display: flex;
}
.gantt-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: rgba(0,0,0,0.7);
  font-weight: 600;
}
.sunrise { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.day { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.sunset { background: linear-gradient(90deg, #f59e0b, #d97706); }
.moon { background: linear-gradient(90deg, #94a3b8, #64748b); }

/* Сохранённый сценарий */
.saved-scenario-card { border-left: 4px solid var(--coral); }
.saved-scenario-card h3 { border-bottom-color: var(--coral); }
#saved-scenario-body p { font-size: 0.85rem; }

.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }
.grid { display: grid; gap: 14px; }
.grid-cols-1 { grid-template-columns: 1fr; }

.card.flex.justify-between.items-center {
  padding: 14px 16px;
  min-height: var(--touch-min);
}
.card.flex .lamp-count {
  width: 64px;
  min-width: 56px;
  padding: 10px 12px;
  text-align: center;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}

/* Иконки (минимальные) */
.icon::before {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  content: '';
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Печать */
@media print {
  body::before, .bubbles, .wave, .header-actions, .theme-toggle-wrap, .lang-buttons,
  .accordion, .btn-accent, .btn-preset, .btn-secondary, .action-buttons,
  .presets-row, footer, .no-print, .mobile-calc-bar { display: none !important; }
  .container { max-width: 100%; }
  .main-grid { grid-template-columns: 1fr; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
.print-only { display: none; }

/* Футер в стиле golos */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 16px;
  padding-bottom: calc(14px + var(--safe-bottom));
  font-size: 0.85rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
  line-height: 1.5;
}
footer a, .footer-link { color: var(--primary); font-weight: 600; text-decoration: none; }
footer a:hover, .footer-link:hover { text-decoration: underline; }
[data-theme="dark"] footer a, [data-theme="dark"] .footer-link { color: var(--aqua); }
.footer-line { margin: 0; line-height: 1.6; }
.footer-line .fab.fa-telegram { margin-right: 4px; }

/* Мобильная версия */
.mobile-calc-bar { display: none; }

@media (max-width: 768px) {
  .container { padding: 0 14px 100px; }
  .header-row { padding-top: calc(8px + var(--safe-top)); padding-bottom: 10px; gap: 12px; }
  .header-row header { text-align: center; }
  .subtitle { margin-left: auto; margin-right: auto; max-width: 100%; }
  .logo { font-size: 1.5rem; }
  .subtitle { font-size: 0.9rem; }
  .header-actions { order: -1; width: 100%; justify-content: flex-end; }
  .main-grid { gap: 16px; }
  .section-title { font-size: 1.1rem; }
  .btn-preset { padding: 12px 16px; }
  .accordion { padding: 14px 18px; min-height: 48px; }
  input[type="text"], input[type="number"], select {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
  }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; }
  input[type="radio"], input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin-right: 8px;
    vertical-align: middle;
    accent-color: var(--coral);
  }
  label:has(input[type="radio"]), label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 0;
    margin-bottom: 4px;
  }
  .card { padding: 14px 12px; }
  .card.flex.justify-between.items-center { min-height: 52px; padding: 14px 18px; }
  .card.flex .lamp-count { min-height: 44px; }
  button.btn-accent { min-height: 52px; padding: 16px 20px; }
  .btn-secondary { min-height: 44px; padding: 12px 16px; }
  .mobile-calc-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 12px 16px;
    padding-bottom: max(12px, var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  }
  [data-theme="dark"] .mobile-calc-bar { box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25); }
  .mobile-calc-bar .btn-accent-full {
    width: 100%;
    min-height: 52px;
    margin: 0;
  }
  .main-grid > div:first-child .btn-accent#calculate-btn { display: none; }
  footer { padding: 12px 14px; padding-bottom: max(14px, var(--safe-bottom)); font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .logo { font-size: 1.35rem; }
  .btn-preset { width: 100%; }
  .action-buttons .btn-secondary { flex: 1 1 100%; }
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
[data-theme="dark"] a:focus-visible, [data-theme="dark"] button:focus-visible {
  outline-color: var(--aqua);
}
