/* Базовое оформление Mini App.
   Цвета берутся из темы Telegram, поэтому форма выглядит родной
   и в светлой, и в тёмной теме. */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #f0f0f4);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0d0d12);
  --muted: var(--tg-theme-hint-color, #8a8a93);
  --accent: var(--tg-theme-button-color, #2f80ed);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e5484d;

  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --field-bg: color-mix(in srgb, var(--muted) 10%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);

  --radius: 14px;
  --radius-sm: 10px;
  --gap: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Экраны состояний ── */

.screen {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}
.screen p { margin: 0; color: var(--muted); max-width: 30ch; }

.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.big-icon { font-size: 40px; line-height: 1; }
#done h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }

/* ── Каркас формы ── */

main { padding: 10px 14px 0; }

/* заголовок в колонку: в строку «Нова рекламація» переносится и рвёт вёрстку */
.head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 4px 14px;
}
.head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 660;
  letter-spacing: -.02em;
}
.muted { color: var(--muted); margin: 0; font-size: 12px; }

/* Заголовок секции стоит над карточкой — так видно границы блоков */
.section-title {
  margin: 18px 4px 7px;
  font-size: 11px;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px 14px;
  margin-bottom: 2px;
}
.card.accent {
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--accent-soft);
}

/* ── Поля ── */

.field { padding: 13px 0; }
.field + .field { box-shadow: inset 0 1px 0 var(--line); }

label.lbl {
  display: block;
  font-size: 13px;
  font-weight: 560;
  margin-bottom: 7px;
  letter-spacing: -.005em;
}
.req { color: var(--danger); font-weight: 700; }

input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--field-bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  transition: border-color .15s, background .15s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.4; }
select { padding-right: 34px; }

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--card);
}

.invalid input, .invalid select, .invalid textarea { border-color: var(--danger); }

.hint { color: var(--muted); font-size: 12px; margin: 7px 0 0; line-height: 1.35; }
.field-error { color: var(--danger); font-size: 12px; margin: 7px 0 0; font-weight: 550; }

.custom-input { margin-top: 8px; }

/* Переключатели: варианты видны сразу */
.radio-row { display: flex; flex-wrap: wrap; gap: 7px; }
.radio-row label { flex: 1 1 auto; cursor: pointer; }
.radio-row input { display: none; }
.radio-row span {
  display: block;
  text-align: center;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  font-size: 14px;
  font-weight: 520;
  transition: background .15s, color .15s;
}
.radio-row input:checked + span {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 580;
}

/* ── Медиа ── */

.media-card .slot-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 0 0;
}
.slot-title { font-size: 13px; font-weight: 560; line-height: 1.35; }
.slot-count {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  font-weight: 620;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--field-bg);
  color: var(--muted);
}
.slot-count.filled { background: var(--accent-soft); color: var(--accent); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px;
  margin: 12px 0 0;
}
.media-grid:empty { display: none; }

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--field-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb .bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px; background: rgba(0, 0, 0, .18);
}
.thumb .bar i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width .2s;
}
.thumb.failed { box-shadow: inset 0 0 0 2px var(--danger); }
.thumb .kill {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 15px; line-height: 22px; padding: 0;
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.thumb .tag {
  position: absolute; left: 4px; bottom: 6px;
  font-size: 10px; padding: 1px 5px; border-radius: 5px;
  background: rgba(0, 0, 0, .55); color: #fff;
}

.add-row { display: flex; gap: 7px; padding: 12px 0 14px; }
.add-btn {
  flex: 1;
  text-align: center;
  padding: 11px;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s;
}
.add-btn:active { background: var(--accent-soft); }

/* Пустой обязательный слот подсвечиваем — его легко пропустить */
.media-card.empty-required .slot-count { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

.bottom-space { height: 28px; }
