/*
 * PIZHON.99 Booking WebApp — design tokens + utility classes.
 * Matches PDF mockup: dark chat backdrop, coral-red accent, rounded cards,
 * SF-Pro-like sans (via system stack). Mobile-first, 402×874 iPhone reference.
 */

:root {
  --bg:        #0b0c0e;
  --bg-elev:  #141619;
  --card:     #1a1d21;
  --card-2:   #22262b;
  --line:     #2a2e34;

  --fg:       #f2f3f5;
  --fg-dim:   #9aa0a6;
  --fg-muted: #6b7075;

  --red:       #ef4444;
  --red-bg:    #ef444422;
  --red-hover: #dc2626;
  --red-text:  #ffdcdc;

  --green:     #10b981;
  --green-bg:  #10b98118;

  --gold:      #f5c96e;

  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;

  --shadow: 0 2px 20px rgba(0, 0, 0, 0.35);

  --pad: 16px;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100dvh;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* Scrollbar — hide but keep scroll */
::-webkit-scrollbar { width: 0; height: 0; }

/* ----- Top bar (BARBER · Pizhon) ----- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .back { width: 28px; color: var(--fg-dim); font-size: 22px; text-align: left; background: none; border: 0; }
.topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.topbar .title { flex: 1; }
.topbar .title b { font-size: 15px; }
.topbar .title small { display: block; color: var(--red); font-size: 11px; margin-top: 1px; }
.topbar .clock { color: var(--fg-dim); font-size: 18px; }

/* ----- Chat bubble greeting ----- */
.chat {
  padding: 18px var(--pad) 8px;
  display: flex; gap: 10px; align-items: flex-start;
}
.chat .bb {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
}
.chat .bubble {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 12px; max-width: 78%;
  position: relative;
}
.chat .bubble h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.chat .bubble p  { margin: 0; color: var(--fg-dim); font-size: 13px; }
.chat .bubble .time {
  position: absolute; right: 8px; bottom: -16px;
  font-size: 10px; color: var(--fg-muted);
}

/* ----- Section card (appears as Telegram message card) ----- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 12px var(--pad);
  padding: 14px;
  box-shadow: var(--shadow);
  position: relative;
}
.card .time {
  position: absolute; right: 12px; bottom: 6px;
  font-size: 10px; color: var(--fg-muted);
}
.card + .card { margin-top: 10px; }

.section-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ----- Hero: NEAREST BOOKING ----- */
.hero {
  background: var(--red);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  margin: 12px var(--pad) 4px;
}
.hero .hero-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  font-weight: 700; opacity: 0.9;
  margin-bottom: 6px;
}
.hero .hero-head .pill {
  background: rgba(0,0,0,0.25);
  padding: 3px 8px; border-radius: 999px;
  font-weight: 600; letter-spacing: 0.5px;
}
.hero .when { font-size: 22px; font-weight: 700; letter-spacing: -0.2px; }
.hero .svc  { font-size: 13px; opacity: 0.92; margin-top: 2px; }

.hero-master {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px;
  padding: 10px;
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius);
}
.hero-master .mavatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: grid; place-items: center;
  font-weight: 700;
}
.hero-master .minfo { flex: 1; min-width: 0; }
.hero-master .mname { font-weight: 700; font-size: 14px; }
.hero-master .mmeta { font-size: 12px; opacity: 0.85; }
.hero-master .mprice { font-weight: 800; font-size: 16px; white-space: nowrap; }

.hero-actions {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 10px;
}
.hero-actions button {
  background: rgba(0,0,0,0.25);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 9px 0;
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.hero-actions button.danger { background: rgba(255,255,255,0.16); }

/* ----- Stats (3 tiles) ----- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 10px;
}
.stats .tile {
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}
.stats .tile.primary { background: var(--red); }
.stats .tile .big {
  font-size: 22px; font-weight: 800; letter-spacing: -0.3px;
}
.stats .tile.primary .big { color: #fff; }
.stats .tile .sub {
  font-size: 10px; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 1px;
  margin-top: 2px;
}
.stats .tile.primary .sub { color: #fff; opacity: 0.85; }

.progress {
  margin-top: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 11px; color: var(--fg-dim);
}
.progress .bar {
  height: 4px;
  background: rgba(239, 68, 68, 0.2);
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
.progress .bar > i {
  display: block; height: 100%;
  background: var(--red);
  border-radius: inherit;
}

/* ----- Quick action card ----- */
.quick-action {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
}
.quick-action .q-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center; font-size: 18px;
}
.quick-action .q-text { flex: 1; min-width: 0; }
.quick-action .q-text b { display: block; font-size: 14px; }
.quick-action .q-text span { font-size: 12px; color: var(--fg-dim); }
.quick-action .q-chev { color: var(--fg-dim); font-size: 18px; }

/* ----- Bottom actions (Новий запис / Історія) ----- */
.bottom-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 10px var(--pad);
}
.bottom-actions button {
  background: var(--card-2);
  color: var(--fg);
  border: 0;
  border-radius: var(--radius);
  padding: 12px;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.bottom-actions button.primary {
  background: var(--red); color: #fff;
}

/* ----- Reminder row ----- */
.reminder {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 10px var(--pad);
  font-size: 12px;
}
.reminder .r-ic { color: var(--gold); font-size: 18px; }
.reminder b { color: #80c8ff; font-size: 12px; }
.reminder p { margin: 2px 0 0; color: var(--fg-dim); }

/* ----- Chip bar (for Quick-Book / Visual Masters categories) ----- */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
.chip {
  background: var(--card-2);
  color: var(--fg);
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 600;
}
.chip.active {
  background: var(--red);
  color: #fff;
}
.chip.outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-dim);
}

/* ----- Message input (fake, like Telegram bottom bar) ----- */
.input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--pad);
  border-top: 1px solid var(--line);
  background: var(--bg);
  position: sticky; bottom: 0;
}
.input-bar input {
  flex: 1; background: var(--card-2); color: var(--fg);
  border: 0; border-radius: 999px;
  padding: 10px 14px; font-size: 13px;
}
.input-bar .send {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff; border: 0;
  display: grid; place-items: center; font-size: 16px;
}

/* ----- Helpers ----- */
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.muted { color: var(--fg-dim); }
.hide  { display: none !important; }

/* ===== Quick-Book (V1) =================================================== */
.qb-section + .qb-section { margin-top: 14px; }
.qb-section .section-label { display: flex; align-items: center; gap: 6px; }
.qb-section .section-label .ic { opacity: 0.7; font-size: 11px; }
.qb-filial-name, .qb-svc-name, .qb-staff-name, .qb-when {
  font-size: 14px; margin: 2px 0 6px;
}

.avatars { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-chip {
  width: 48px; height: 48px; border-radius: 50%;
  background: transparent; border: 2px solid transparent; padding: 2px;
  display: grid; place-items: center;
}
.avatar-chip.active { border-color: var(--red); }
.avatar-chip .ac-img {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; overflow: hidden;
}
.avatar-chip .ac-img img { width: 100%; height: 100%; object-fit: cover; }

.qb-dates, .qb-times {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.qb-summary { margin-top: 10px; }
.qb-confirm {
  background: var(--red); color: #fff; border: 0;
  border-radius: var(--radius); padding: 12px 22px;
  font-weight: 700; font-size: 14px; min-width: 140px;
}
.qb-confirm:disabled { background: var(--card-2); color: var(--fg-muted); }

/* ===== Visual Masters (V2) =============================================== */
.svc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.svc-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-2); color: var(--fg);
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 10px 12px; text-align: left;
}
.svc-row.sel { border-color: var(--red); background: rgba(239, 68, 68, 0.08); }
.svc-row .svc-main { display: flex; flex-direction: column; gap: 2px; }
.svc-row .svc-main b { font-size: 14px; }
.svc-row .svc-main span { font-size: 12px; }
.svc-row .svc-price { font-weight: 800; color: var(--red); white-space: nowrap; }

.master-card {
  display: flex; background: var(--card);
  border: 1px solid transparent; border-radius: var(--radius-lg);
  margin: 8px var(--pad); overflow: hidden;
  min-height: 120px;
}
.master-card.highlight { border-color: var(--red); }
.master-card .mc-photo {
  width: 120px; flex: none; position: relative;
  display: grid; place-items: center;
}
.master-card .mc-photo img { width: 100%; height: 100%; object-fit: cover; }
.master-card .mc-photo-name {
  position: absolute; left: 8px; bottom: 6px;
  font-size: 11px; color: #fff;
  background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px;
}
.master-card .mc-body {
  flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.master-card .mc-head { display: flex; align-items: baseline; gap: 6px; }
.master-card .mc-head b { font-size: 15px; }
.master-card .mc-head .rank { color: var(--red); font-size: 11px; font-weight: 700; }
.master-card .mc-meta { font-size: 12px; }
.master-card .mc-meta b { color: var(--gold); }
.master-card .mc-tags { font-size: 11px; }
.master-card .mc-slot {
  margin-top: auto; font-size: 11px;
  padding: 5px 8px; border-radius: 999px;
  background: rgba(128, 200, 255, 0.12); color: #80c8ff;
  align-self: flex-start;
}

/* ===== Timeline (V3) ===================================================== */
.hero-thin { background: var(--card); padding: 12px 14px; }
.nav-btn {
  background: var(--card-2); color: var(--fg);
  border: 0; border-radius: 8px; width: 30px; height: 28px;
  font-size: 16px;
}
.week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-top: 10px;
}
.day-tile {
  background: var(--card-2); color: var(--fg);
  border: 0; border-radius: var(--radius-sm);
  padding: 6px 2px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0; font-size: 10px;
}
.day-tile .dow  { font-size: 9px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.day-tile .num  { font-size: 18px; font-weight: 700; }
.day-tile .count { font-size: 9px; color: var(--fg-dim); }
.day-tile.active { background: var(--red); color: #fff; }
.day-tile.active .dow,
.day-tile.active .count { color: #fff; opacity: 0.85; }
.day-tile.past   { opacity: 0.35; }
.day-tile.nope   { color: var(--fg-muted); }

.tl-slots { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.slot {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center;
  background: transparent; color: var(--fg);
  border: 0; border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; text-align: left;
  gap: 10px;
}
.slot .time   { position: static; color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.slot.busy { background: rgba(255,255,255,0.03); }
.slot.busy .time   { color: var(--fg-muted); font-weight: 500; }
.slot.busy .status { color: var(--fg-muted); }
.slot.free { background: rgba(16, 185, 129, 0.12); color: #4ade80; }
.slot.free .status { color: #4ade80; font-weight: 600; }
.slot.free.sel { background: var(--red); color: #fff; }
.slot.free.sel .status, .slot.free.sel .time { color: #fff; }
.slot .dur { font-size: 11px; }
