/* PadelMatch — собственный CSS вместо Tailwind CDN:
   работает офлайн в PWA, без FOUC и внешних зависимостей.
   Отступы заданы логическими свойствами, поэтому RTL работает без хаков. */

:root {
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #ccfbf1;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #b91c1c;
  --warning: #b45309;
  --ok: #15803d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Rubik, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }

.wrap { max-width: 480px; margin: 0 auto; padding: 12px 16px 96px; }

/* ---------- header / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }

.langs { display: flex; gap: 4px; }
.langs a {
  min-width: 40px; min-height: 36px;
  display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted); background: #fff;
}
.langs a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.bottomnav a {
  flex: 1; min-height: 48px; display: grid; place-items: center; gap: 2px;
  font-size: 12px; color: var(--muted); border-radius: 12px;
}
.bottomnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.bottomnav .ico { font-size: 18px; line-height: 1; }

/* ---------- typography / layout ---------- */
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px;
}
.card + .card { margin-top: 12px; }
.card.link { display: block; color: inherit; }
.card.link:active { transform: scale(.995); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-dark);
}
.badge.waiting { background: #e0f2fe; color: #075985; }
.badge.confirmed { background: #dcfce7; color: var(--ok); }
.badge.booked { background: #ede9fe; color: #5b21b6; }
.badge.cancelled { background: #fee2e2; color: var(--danger); }
.badge.warn { background: #fef3c7; color: var(--warning); }


/* ---------- slot avatars ---------- */
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.slot {
  display: grid; justify-items: center; gap: 6px;
  padding: 10px 4px; border-radius: 14px;
  border: 1px dashed var(--line); background: #fbfdfd;
  min-height: 92px; align-content: center;
}
.slot.filled { border-style: solid; border-color: var(--accent-soft); background: #f0fdfa; }
.slot.me { box-shadow: 0 0 0 2px var(--accent) inset; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  background: var(--accent-soft); color: var(--accent-dark);
}
.slot.filled .avatar { background: var(--accent); color: #fff; }
.slot .name { font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .lvl { font-size: 11px; color: var(--muted); }
.slot .plus { font-size: 22px; color: var(--muted); line-height: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent;
  font-size: 16px; font-weight: 600; font-family: inherit;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn.subtle { background: #f1f5f9; color: var(--text); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.wa { background: #25d366; color: #0b3d1f; }
.btn.tg { background: #229ed9; color: #fff; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 12px; }

.actionbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 15;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.actionbar .wrapbar { max-width: 480px; margin: 0 auto; display: flex; gap: 8px; }
.actionbar .btn { flex: 1; }
body.has-actionbar .wrap { padding-bottom: 150px; }
body.has-bottomnav .wrap { padding-bottom: 96px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font-family: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- chat ---------- */
.chat { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 4px 2px; }
.msg {
  max-width: 85%; padding: 9px 12px; border-radius: 14px;
  background: #f1f5f9; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine { background: var(--accent-soft); margin-inline-start: auto; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--accent-dark); margin-bottom: 2px; }
.msg .time { font-size: 10px; color: var(--muted); margin-top: 2px; text-align: end; }
.msg .msg-toggle {
  margin-top: 4px; padding: 0; border: 0; background: none;
  font-family: inherit; font-size: 11px; color: var(--accent);
  text-decoration: underline dotted; cursor: pointer;
}
.msg.showing-original .msg-toggle { color: var(--muted); }
.msg.system { background: transparent; color: var(--muted); font-size: 12px; text-align: center; max-width: 100%; }
.chat form { display: flex; gap: 8px; margin-top: 8px; }
.chat form input { flex: 1; }

/* ---------- misc ---------- */
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 40px; display: block; margin-bottom: 8px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.notice { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: #fef3c7; color: var(--warning); }
.notice.info { background: #eff6ff; color: #1d4ed8; }
.notice.error { background: #fef2f2; color: var(--danger); }
.hide { display: none !important; }

#toast {
  position: fixed; inset-inline: 16px; bottom: 84px; z-index: 50;
  max-width: 448px; margin-inline: auto;
  padding: 12px 16px; border-radius: 12px;
  background: #0f172a; color: #fff; font-size: 14px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

textarea { min-height: 72px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
