/* Resource calculator styles (loaded by source/_static/calc/autoexec.html). */

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 16px;
  background: #fff;
  color: #222;
}

.container {
  max-width: 860px;
  margin: auto;
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 0 10px #ccc;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 4px;
}

.calc-header h2 {
  margin: 0;
}

.subtitle {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── Сетка параметров ── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
}

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

.field label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.field input[type="number"],
.field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
}

.field input[type="number"]:focus,
.field select:focus {
  outline: none;
  border-color: #017bce;
}

/* ── Ползунок capacity_adjustment ── */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-wrap input[type="range"] {
  flex: 1;
  accent-color: #017bce;
}

.slider-val {
  min-width: 32px;
  text-align: right;
  font-size: 14px;
  font-weight: bold;
  color: #017bce;
}

/* ── Расширенные параметры ── */
.advanced-toggle {
  margin: 18px 0 0;
  font-size: 19px;
  font-weight: 600;
  color: #017bce;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  border: none;
  background: none;
  padding: 0;
}

.advanced-toggle:hover {
  text-decoration: underline;
}

.advanced-section {
  margin-top: 12px;
  padding: 14px;
  background: #f4f8fb;
  border-radius: 8px;
  border: 1px solid #d0e6f5;
}

.advanced-section .subheader {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin: 6px 0 2px;
}

.advanced-section .subheader:first-child {
  margin-top: 0;
}

/* ── Блок плоскости (control / execution) ── */
.plane {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid #d0e6f5;
  background: #fbfdff;
}

.plane.exec {
  border-color: #cfe5cf;
  background: #fafff5;
}

.plane-title {
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #017bce;
  margin: 0 0 12px;
}

.plane.exec .plane-title {
  color: #2e7d32;
}

.plane-divider {
  border: none;
  border-top: 1px dashed #cdd9e3;
  margin: 14px 0;
}

.plane.exec .plane-divider {
  border-top-color: #cfe5cf;
}

.plane-results-title {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin: 0 0 8px;
}

/* ── Итого узлов (бейдж сверху) ── */
.summary-badge {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, #017bce 0%, #2e7d32 100%);
  color: #fff;
  text-align: center;
}

.summary-badge .summary-main {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 0.02em;
}

.summary-badge .summary-sub {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
}

/* ── Секция результатов ── */
.results {
  margin-top: 24px;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.result-card {
  background: #e6f3fa;
  border-radius: 8px;
  padding: 14px 16px;
}

.result-card.db {
  background: #eef6ee;
}

.result-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #017bce;
}

.result-card.db h3 {
  color: #2e7d32;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.result-row:last-child {
  border-bottom: none;
}

.result-row .label {
  color: #555;
}

.result-row .value {
  font-weight: bold;
  color: #111;
}

.result-row .value.highlight {
  color: #017bce;
  font-size: 15px;
}

.result-card.db .result-row .value.highlight {
  color: #2e7d32;
}

/* ── Предупреждение max_connections ── */
.result-card.db.alert {
  background: #fdecec;
  border: 1px solid #f5c2c2;
}

.db-warning {
  margin-top: 8px;
  padding: 8px 10px;
  background: #d32f2f;
  color: #fff;
  font-weight: bold;
  font-size: 13px;
  border-radius: 6px;
  text-align: center;
}

.heuristic-note {
  margin: 8px 0 0;
  font-size: 11px;
  font-style: italic;
  line-height: 1.35;
  color: #6b7280;
}

/* ── Предупреждение: недостаточно RAM узла ── */
.capacity-warning {
  margin-top: 18px;
  padding: 12px 16px;
  background: #d32f2f;
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  border-radius: 8px;
  text-align: center;
}

.capacity-warning small {
  display: block;
  font-weight: normal;
  font-size: 12px;
  opacity: 0.9;
  margin-top: 4px;
}

/* ── Разделитель секций ── */
.section-label {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin: 20px 0 10px;
}

/* ── HA-бейдж ── */
.ha-note {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
}

/* ── Кнопка сброса ── */
.btn-reset {
  position: absolute;
  right: 0;
  font-size: 12px;
  color: #888;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
}

.btn-reset:hover {
  border-color: #017bce;
  color: #017bce;
}

/* ── Tooltip ── */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #017bce;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  cursor: default;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}

.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-line;
  width: 240px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.tip:hover::after {
  opacity: 1;
}
