/* components.css — буттони, картки, чіпи, інпути, прогрес */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 0; cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.04));
  color: var(--tg-theme-text-color);
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled],
.btn.is-loading {
  cursor: not-allowed;
  opacity: .65;
  pointer-events: none;  /* disables press transform on loading */
}
.btn.is-loading::after {
  content: "";
  width: 16px; height: 16px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
  display: inline-block;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn--primary {
  background: var(--tg-theme-button-color, #2EA6FF);
  color: var(--tg-theme-button-text-color, #fff);
  /* зовнішня тінь у спокої */
  box-shadow:
    0 6px 18px rgba(46,166,255,.36),
    0 2px 6px rgba(46,166,255,.22);
}
.btn--primary:hover:not([disabled]):not(.is-loading) {
  box-shadow:
    0 8px 22px rgba(46,166,255,.44),
    0 3px 8px rgba(46,166,255,.28);
}
.btn--primary:active:not([disabled]):not(.is-loading) {
  /* "натиснуто" — внутрішня тінь, нема зовнішньої */
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,.22),
    inset 0 1px 2px rgba(0,0,0,.18),
    0 0 0 rgba(46,166,255,0);
  transform: scale(.97) translateY(1px);
}
.btn--primary[disabled],
.btn--primary.is-loading {
  /* dim + плоско — без зовнішньої тіні */
  box-shadow: none;
}
.btn--ghost {
  background: transparent;
  border: 1px solid var(--tg-theme-section-separator-color, rgba(0,0,0,.1));
  font-weight: 500;
}
.btn--danger {
  background: transparent;
  color: var(--tg-theme-destructive-text-color, #FF5A5F);
  border: 1px solid currentColor;
}
.btn--block { display: flex; width: 100%; }
.btn--sm { padding: 8px 12px; min-height: 36px; font-size: 13.5px; border-radius: 10px; }

/* CARDS — м'якший стиль, заокруглення 22px, soft shadow (як на референс-скріні) */
.card {
  background: var(--tg-theme-section-bg-color);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.03);
  margin-bottom: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card--accent { outline: 1px solid var(--tg-theme-accent-text-color); }
.card--clickable { cursor: pointer; }
.card--clickable:active { transform: scale(.985); }
.card__title { font-weight: 600; font-size: 15px; margin-bottom: 6px; letter-spacing: -0.01em; }
.card__text { color: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color)); line-height: 1.5; }

/* TILES — для дашбордних швидких дій. Більший заокруглений варіант. */
.tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  background: var(--tg-theme-section-bg-color);
  border: 0; border-radius: 18px;
  padding: 16px;
  min-height: 96px;
  text-align: left;
  cursor: pointer;
  color: var(--tg-theme-text-color);
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  transition: transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile__icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--tg-theme-button-color, #2EA6FF), #FFD500 140%);
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
}
.tile__label { font-weight: 500; font-size: 14px; }

/* CHIPS — pill-style, м'який пастельний фон, чіткіша active-state */
.chip {
  display: inline-flex; align-items: center;
  padding: 8px 14px;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.04));
  border: 0;
  border-radius: 999px;
  color: var(--tg-theme-text-color);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: scale(.95); }
.chip.is-active {
  background: var(--tg-theme-button-color, #2EA6FF);
  color: var(--tg-theme-button-text-color, #fff);
  box-shadow: 0 4px 12px rgba(46,166,255,.35);
}
/* Tag-варіант (для відображення інтересів — без cursor) */
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.04));
  border-radius: 999px;
  font-size: 12.5px; color: var(--tg-theme-hint-color, #708);
  margin-right: 4px;
}

.filter-bar {
  display: flex; gap: var(--space-xs);
  overflow-x: auto;
  margin-bottom: var(--space-md);
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }

.input, textarea, select {
  width: 100%;
  padding: 12px;
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  border: 1px solid var(--tg-theme-section-separator-color);
  border-radius: var(--radius-md);
  font: inherit;
}
.input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--tg-theme-button-color);
  outline-offset: 2px;
}

.progress {
  height: 6px;
  background: var(--tg-theme-section-separator-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: var(--space-sm);
}
.progress span {
  display: block; height: 100%;
  background: var(--tg-theme-accent-text-color);
}

.hello__title { font-size: var(--font-size-2xl); font-weight: 600; }
.hello__sub { font-size: var(--font-size-md); }

.ai-chat { display: flex; flex-direction: column; height: calc(var(--tg-vh-stable) - 240px); }
.ai-chat__messages { flex: 1; overflow-y: auto; padding: var(--space-sm) 0; display: flex; flex-direction: column; gap: 8px; }
.ai-chat__input { display: flex; gap: var(--space-xs); padding-top: var(--space-sm); border-top: 1px solid var(--tg-theme-section-separator-color); }
.ai-chat__input input { flex: 1; }

.ai-msg { display: flex; }
.ai-msg--user { justify-content: flex-end; }
.ai-msg--assistant { justify-content: flex-start; }
.ai-msg--system { justify-content: center; }
.ai-msg__bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  background: var(--tg-theme-section-bg-color);
  color: var(--tg-theme-text-color);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ai-msg--user .ai-msg__bubble {
  background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color);
  border-bottom-right-radius: 4px;
}
.ai-msg--assistant .ai-msg__bubble { border-bottom-left-radius: 4px; }
.ai-msg--system .ai-msg__bubble { background: transparent; color: var(--tg-theme-hint-color); font-size: var(--font-size-sm); }
.ai-msg__note { font-size: var(--font-size-xs); color: var(--tg-theme-accent-text-color); margin-top: 4px; }
.ai-msg--typing .ai-msg__bubble { display: flex; gap: 3px; padding: 14px 16px; }
.ai-msg--typing span { width: 6px; height: 6px; background: var(--tg-theme-hint-color); border-radius: 50%; animation: typing 1.2s infinite; }
.ai-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

.ai__progress { margin-top: var(--space-sm); }

/* Profile */
.profile__hero { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-sm); }
.profile__avatar { position: relative; width: 80px; height: 80px; }
.profile__avatar img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.profile__avatar-edit {
  position: absolute; right: -4px; bottom: -4px;
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--tg-theme-bg-color);
  background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color);
  cursor: pointer; font-size: 14px;
}
.profile__name { font-size: var(--font-size-xl); font-weight: 700; }
.profile__progress { margin-top: var(--space-sm); }
.profile__actions { display: flex; gap: var(--space-sm); margin-top: var(--space-md); }
.profile__actions .btn { flex: 1; }
.input--sm { padding: 6px 8px; min-height: 32px; max-width: 140px; }

/* iOS Safari зумить input при focus коли font-size < 16px.
   Форсуємо 16px (а не --font-size-md, що може бути менше) лише на TG WebView. */
input[type="text"], input[type="email"], input[type="number"],
input[type="search"], input[type="tel"], input[type="password"],
input[type="url"], input[type="datetime-local"], input[type="date"],
input[type="time"], input[type="month"],
textarea, select, .input {
  font-size: 16px;
}

.flex-wrap { flex-wrap: wrap; }

/* EMPTY STATES — для пустих секцій (no events, no matches) */
.empty-state {
  text-align: center;
  padding: 24px 18px;
  border: 1px dashed var(--tg-theme-section-separator-color, rgba(0,0,0,.1));
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.02));
  box-shadow: none;
}
.empty-state__icon {
  font-size: 36px;
  margin-bottom: 8px;
  opacity: .7;
}
.empty-state__title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  line-height: 1.4;
}
.empty-state .row { justify-content: center; }

/* PLAN — стрічка подій (joined/hosted/past) */
.plan-section { margin-top: 18px; }
.plan-section .section-title {
  font-size: 14px; font-weight: 600;
  margin-bottom: 8px;
  color: var(--tg-theme-text-color);
  letter-spacing: -0.01em;
}
.plan-card {
  /* успадковує .card стилі */
  cursor: pointer;
}
.plan-card__icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.04));
  display: grid; place-items: center;
  font-size: 22px;
}
.plan-card__title {
  font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.01em;
}
.plan-card__meta { margin-top: 2px; }
.plan-card__row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.plan-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.04));
  color: var(--tg-theme-hint-color, #708);
}
.plan-badge--ok      { background: rgba(52,199,89,.15);  color: #34C759; }
.plan-badge--pending { background: rgba(255,213,0,.18);  color: #B8860B; }
.plan-badge--host    { background: rgba(46,166,255,.15); color: #2EA6FF; }
.plan-badge--bad     { background: rgba(255,90,95,.15);  color: #FF5A5F; }
.plan-badge--warn    { background: rgba(255,149,0,.15);  color: #FF9500; }
.plan-badge--soft    { /* default */ }

/* NOTIFICATIONS — стрічка карток */
.nf-item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; text-align: left;
  padding: 14px 16px;
  background: var(--tg-theme-section-bg-color);
  border: 0; border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  cursor: pointer;
  color: var(--tg-theme-text-color);
  transition: transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.nf-item:active { transform: scale(.985); }
.nf-item.is-unread {
  background: linear-gradient(0deg, var(--tg-theme-section-bg-color, #fff), var(--tg-theme-section-bg-color, #fff)),
              linear-gradient(135deg, rgba(46,166,255,.08), rgba(255,213,0,.06));
  background-blend-mode: normal;
  border: 1px solid rgba(46,166,255,.18);
}
.nf-item__icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
}
.nf-item__body { flex: 1; min-width: 0; }
.nf-item__title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.nf-item__sub   { margin-top: 2px; line-height: 1.4; }
.nf-item__time  { margin-top: 4px; font-size: 11.5px; }
.nf-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--tg-theme-button-color, #2EA6FF);
  border-radius: 50%;
}
.ml-auto { margin-left: auto; }
.mt-sm { margin-top: var(--space-sm); }

/* Groups */
.grp-row {
  display: flex; align-items: center; gap: var(--space-sm);
  width: 100%; padding: 12px; border: 0;
  background: var(--tg-theme-section-bg-color); border-radius: var(--radius-md);
  color: var(--tg-theme-text-color); cursor: pointer;
  text-align: left;
}
.grp-row:active { transform: scale(.98); }
.grp-row__icon { width: 36px; height: 36px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.grp-row__body { flex: 1; min-width: 0; }
.grp-row__name { font-weight: 600; }
.grp-row__sub  { font-size: var(--font-size-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-row__count { color: var(--tg-theme-hint-color); font-size: var(--font-size-sm); padding-right: var(--space-xs); }
.grp-detail__icon { font-size: 40px; }
.badge { display: inline-block; padding: 2px 6px; font-size: var(--font-size-xs); border-radius: 4px; background: var(--tg-theme-section-separator-color); color: var(--tg-theme-hint-color); }
.badge--sub { background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }

/* Nearby */
.nb-user {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 12px;
  background: var(--tg-theme-section-bg-color);
  border-radius: var(--radius-md);
}
.nb-user__av { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.nb-user__body { flex: 1; min-width: 0; }
.nb-user__name { font-weight: 600; }
.nb-user__meta { margin-top: 2px; }
.nb-user__tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.nb-user__actions { display: flex; gap: 4px; }
.nb__ctrl { padding: 12px; }
.nb__ctrl input[type="range"] { accent-color: var(--tg-theme-button-color); }

/* Contacts */
.ct-card {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 12px;
  background: var(--tg-theme-section-bg-color);
  border-radius: var(--radius-md);
}
.ct-card__body { flex: 1; min-width: 0; }
.ct-card__alias { font-weight: 600; }
.ct-card__msg { margin: 4px 0; font-style: italic; }
.ct-card__actions { display: flex; gap: 4px; }

/* Admin */
.adm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}
@media (max-width: 360px) { .adm-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--tg-theme-section-bg-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}
.kpi__num { font-size: 22px; font-weight: 700; }
.kpi__lbl { font-size: 11px; color: var(--tg-theme-hint-color); margin-top: 2px; }
.kpi--warn .kpi__num { color: #FF9500; }
.kpi--good .kpi__num { color: #34C759; }
.adm-row {
  background: var(--tg-theme-section-bg-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.adm-row__name { font-weight: 600; }
.adm-row__text { font-size: var(--font-size-sm); white-space: pre-wrap; word-break: break-word; }
.badge--warn { background: rgba(255,90,95,.15); color: #FF5A5F; }

/* Meeting after-checkin */
.meet-row {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 10px;
  background: var(--tg-theme-section-bg-color);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}
.meet-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meet-row__alias { font-weight: 600; }

/* WHEEL DATETIME PICKER ─────────────────────────────────────────── */
.wdt {
  position: relative;
  background: var(--tg-theme-secondary-bg-color, rgba(0,0,0,.03));
  border-radius: 14px;
  padding: 8px 10px;
  user-select: none;
  -webkit-user-select: none;
}
.wdt__row {
  display: flex; align-items: stretch; gap: 8px;
  height: 180px; /* 5 рядків × 36px */
}
.wdt__col {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: auto;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.wdt__col::-webkit-scrollbar { display: none; }
.wdt__col--narrow { flex: 0 0 64px; }
.wdt__sep {
  display: flex; align-items: center;
  font-size: 22px; font-weight: 700;
  color: var(--tg-theme-text-color);
  opacity: .5;
  padding-bottom: 6px;
}
.wdt__item {
  height: 36px;
  line-height: 36px;
  font-size: 17px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  transition: opacity .12s ease, transform .12s ease;
}
.wdt__item--pad { pointer-events: none; }
.wdt__item.is-active {
  font-weight: 700;
  color: var(--tg-theme-link-color, #2EA6FF);
  transform: scale(1.05);
}
.wdt__hl {
  position: absolute;
  left: 10px; right: 10px;
  top: 50%;
  height: 36px;
  transform: translateY(-50%);
  border-top: 1px solid var(--tg-theme-section-separator-color, rgba(0,0,0,.12));
  border-bottom: 1px solid var(--tg-theme-section-separator-color, rgba(0,0,0,.12));
  pointer-events: none;
  border-radius: 0;
}

/* FIELD ERROR STATE ─────────────────────────────────────────────── */
.input.is-error,
.field.is-error .input {
  border: 1px solid #FF5A5F !important;
  background: rgba(255,90,95,.06);
}
.field-error {
  display: none;
  color: #FF5A5F;
  font-size: 12.5px;
  margin-top: 6px;
  line-height: 1.35;
}
.field.is-error .field-error,
.is-error + .field-error,
.field-error.is-shown { display: block; }
.field {
  display: block;
}

/* MODAL OVERLAY (для conflict-warning) ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: modal-fade-in .15s ease;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  border-radius: 22px 22px 0 0;
  padding: 22px 18px 18px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modal-slide-up .22s cubic-bezier(.2,.7,.2,1);
}
@keyframes modal-slide-up {
  from { transform: translateY(60%); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.modal--warn { border-top: 4px solid #FFB020; }
.modal h3 { font-size: 17px; }

/* EVENT-CARD STATUS COLORS ─────────────────────────────────────── */
/* Стрічки/картки подій маркуються по доступності місць та часу.
   Класи додаються JS на корінь .ev-card.
   Працюють і на discover-feed, і на /plan, і на /matches.
*/
.ev-card { position: relative; }
.ev-card[data-availability="available"] {
  border-left: 3px solid #2BB673;   /* зелений — є місця */
}
.ev-card[data-availability="full"] {
  border-left: 3px solid var(--tg-theme-button-color, #2EA6FF);  /* синій — заповнена */
  opacity: .92;
}
.ev-card[data-availability="past"],
.ev-card[data-availability="cancelled"] {
  border-left: 3px solid #999;       /* сірий — минула/скасована */
  opacity: .55;
  filter: grayscale(.5);
}
/* Інлайн-бейдж справа з підписом */
.ev-card__avail {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  margin-left: 6px;
}
.ev-card[data-availability="available"] .ev-card__avail { background: rgba(43,182,115,.15); color: #2BB673; }
.ev-card[data-availability="full"]      .ev-card__avail { background: rgba(46,166,255,.18); color: #2EA6FF; }
.ev-card[data-availability="past"]      .ev-card__avail,
.ev-card[data-availability="cancelled"] .ev-card__avail { background: rgba(0,0,0,.08); color: #777; }
