/* Slot Hunter — Mini App styles.
 *
 * Telegram theme variables drive the palette so the app blends with whatever
 * skin the user has (light/dark/system). Browser-only fallbacks are dark.
 */

:root {
  --bg: var(--tg-theme-bg-color, #1a1a1a);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #232323);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #888);
  --link: var(--tg-theme-link-color, #4ea1ff);
  --button: var(--tg-theme-button-color, #2d8cff);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --destructive: var(--tg-theme-destructive-text-color, #ff5b5b);
  --border: rgba(127, 127, 127, 0.25);
  --accent-soft: rgba(45, 140, 255, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px; /* room for sticky wizard footer */
}

/* ────────────────────── Header ────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 8px;
}

.header__title {
  font-size: 18px;
  margin: 0;
  flex: 1;
}

.header__btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
}

.header__btn-primary {
  border: 0;
  background: var(--button);
  color: var(--button-text);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
}

[hidden] {
  display: none !important;
}

/* ────────────────────── Progress bar ────────────────────── */
.progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress__fill {
  height: 100%;
  background: var(--button);
  width: 0;
  transition: width 0.25s ease;
}

/* ────────────────────── View switching ────────────────────── */
.view.hidden {
  display: none;
}

/* ────────────────────── Buttons ────────────────────── */
.btn-primary,
.btn-secondary {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--button);
  color: var(--button-text);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--secondary-bg);
  color: var(--text);
}

.btn-block {
  width: 100%;
  display: block;
  margin-top: 8px;
}

button:active:not(:disabled) {
  opacity: 0.8;
}

/* ────────────────────── Wizard footer (sticky) ────────────────────── */
.wizard-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 12px 16px env(safe-area-inset-bottom, 12px);
  background: var(--bg);
  border-top: 1px solid var(--border);
  max-width: 480px;
  margin: 0 auto;
}

.wizard-footer button {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  font-weight: 500;
  border: 0;
  cursor: pointer;
  font-size: 16px;
}

.wizard-footer .btn-primary {
  background: var(--button);
  color: var(--button-text);
}

.wizard-footer .btn-secondary {
  background: var(--secondary-bg);
  color: var(--text);
}

/* ────────────────────── Step ────────────────────── */
.step {
  animation: fade-in 0.18s ease;
}

.step.hidden {
  display: none;
}

.step__heading {
  font-size: 22px;
  margin: 4px 0 6px 0;
}

.step__hint {
  color: var(--hint);
  font-size: 14px;
  margin: 0 0 18px 0;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ────────────────────── Form bits ────────────────────── */
fieldset.form-row,
fieldset.autocomplete-block {
  border: 0;
  padding: 0;
  margin: 0 0 18px 0;
  position: relative;
}

legend {
  display: block;
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="date"],
input[type="number"] {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

input:focus {
  outline: 2px solid var(--button);
  outline-offset: -1px;
}

small {
  display: block;
  color: var(--hint);
  font-size: 13px;
  margin-top: 4px;
}

/* ────────────────────── Autocomplete suggestions ────────────────────── */
.suggestions {
  list-style: none;
  margin: 4px 0 0 0;
  padding: 0;
  background: var(--secondary-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  max-height: 220px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}

.suggestions:empty {
  display: none;
}

.suggestions li {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.suggestions li:last-child {
  border-bottom: 0;
}

.suggestions li:hover,
.suggestions li.active {
  background: rgba(127, 127, 127, 0.1);
}

/* ────────────────────── Service cards (step 1) ────────────────────── */
.card-grid {
  display: grid;
  gap: 12px;
}

.service-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--secondary-bg);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.service-card:hover,
.service-card.active {
  border-color: var(--button);
}

.service-card--soon {
  cursor: not-allowed;
  opacity: 0.5;
}

.service-card__icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.service-card__name {
  font-weight: 600;
  font-size: 17px;
}

.service-card__sub {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
}

/* ────────────────────── Chip row (date/cars/lower-mode) ────────────────────── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.chip:hover,
.chip:active {
  border-color: var(--button);
}

.chip.chip--active {
  background: var(--accent-soft);
  border-color: var(--button);
  color: var(--text);
}

/* ────────────────────── Train picker ────────────────────── */
.train-list {
  display: grid;
  gap: 10px;
}

.train-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--secondary-bg);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}

.train-card.active {
  border-color: var(--button);
  background: var(--accent-soft);
}

.train-card__check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: transparent;
}

.train-card.active .train-card__check {
  background: var(--button);
  border-color: var(--button);
  color: var(--button-text);
}

.train-card__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.train-card__title {
  font-weight: 600;
  font-size: 15px;
}

.train-card__sub {
  color: var(--hint);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.train-card__time {
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

.train-card__time-main {
  font-weight: 600;
}

.train-card__time-sub {
  color: var(--hint);
  font-size: 12px;
}

/* ────────────────────── Review (step 6) ────────────────────── */
.review {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 16px;
}

.review__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.review__row:last-child {
  border-bottom: 0;
}

.review__key {
  color: var(--hint);
  font-size: 13px;
  white-space: nowrap;
}

.review__value {
  font-size: 14px;
  text-align: right;
  word-break: break-word;
}

/* ────────────────────── Alert cards (list view) ────────────────────── */
.alert-card {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.alert-card .route {
  font-size: 16px;
  font-weight: 600;
}

.alert-card .meta {
  color: var(--hint);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.4;
}

.alert-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.alert-card .actions button {
  flex: 1;
  padding: 8px;
  font-size: 14px;
  border-radius: 8px;
  border: 0;
  background: rgba(127, 127, 127, 0.15);
  color: var(--text);
  cursor: pointer;
}

.alert-card .actions .btn-delete {
  color: var(--destructive);
}

.placeholder {
  color: var(--hint);
  text-align: center;
  padding: 32px 16px;
}

/* ────────────────────── Toast ────────────────────── */
.toast {
  position: fixed;
  bottom: 88px; /* above wizard footer */
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  font-size: 14px;
}

.toast.hidden {
  display: none;
}

.toast.error {
  border-color: var(--destructive);
  color: var(--destructive);
}
