/* ============================================================
   DentX · ДИЗАЙН-СИСТЕМА
   Светлый, медицинский, «дорогая частная клиника».
   Используется на всех страницах (client / doctor / admin / landing).
   ============================================================ */

/* ── Дизайн-токены ── */
:root {
  --bg:           #F8FAFB;
  --card:         #FFFFFF;
  --card-tint:    #E8F4FD;
  --primary:      #1B4F8A;
  --primary-dark: #143A66;
  --accent:       #2ECC9A;
  --accent-dark:  #25A87E;
  --text:         #1A2332;
  --text-muted:   #6B7A8D;
  --border:       #E2E8F0;
  --danger:       #E74C3C;
  --success:      #27AE60;
  --warning:      #F39C12;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --shadow:       0 1px 4px rgba(27,79,138,0.08);
  --shadow-lg:    0 8px 24px rgba(27,79,138,0.12);
  --shadow-xl:    0 16px 48px rgba(27,79,138,0.16);
  --font-head:    'Montserrat', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --maxw:         1180px;
}

/* ── Сброс ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Атрибут hidden всегда прячет элемент (иначе display:flex/grid его перебивают) */
[hidden] { display: none !important; }

/* overflow-x: hidden на html обрезает случайный горизонтальный скролл на телефоне
   и не ломает sticky-шапки; на body — clip (без лишнего скролл-контейнера). */
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 800; }
h2 { font-size: clamp(24px, 3.5vw, 32px); }
h3 { font-size: 18px; }
p { color: var(--text-muted); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Иконки Lucide ── */
.icon { width: 20px; height: 20px; stroke-width: 2; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ── Раскладка ── */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: 72px 0; }
.section-tint { background: linear-gradient(180deg, #F0F7FD 0%, var(--bg) 100%); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 48px; }
.section-head p { margin-top: 12px; font-size: 16px; }
.eyebrow {
  display: inline-block; font-family: var(--font-head); font-weight: 700;
  font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 12px;
}

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-weight: 600; font-size: 15px;
  padding: 12px 22px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap; min-height: 44px; /* удобная тач-зона */
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-accent { background: var(--accent); color: #06402B; }
.btn-accent:hover { background: var(--accent-dark); transform: translateY(-2px); }
.btn-ghost { background: #fff; color: var(--primary); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); background: #F4F9FE; }
.btn-lg { padding: 16px 32px; font-size: 17px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Карточки ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.card-hover { transition: transform .18s ease, box-shadow .18s ease; }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* ── Бейджи статусов ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  font-family: var(--font-head);
}
.badge-scheduled { background: #EEF1F5; color: #5A6B7D; }
.badge-confirmed { background: #E5F0FB; color: var(--primary); }
.badge-completed { background: #E4F7EE; color: var(--success); }
.badge-cancelled { background: #FDECEA; color: var(--danger); }
.badge-no_show   { background: #FEF3E2; color: var(--warning); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ── Формы ── */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 15px; color: var(--text);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,79,138,0.12);
}
.field { margin-bottom: 16px; }

/* ── Доступность ── */
:focus-visible { outline: 3px solid rgba(27,79,138,0.45); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ── Утилиты ── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .section { padding: 48px 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   Сетка расписания на день (schedule-grid.js) — колонки = кабинеты,
   строки = 30 минут. Переиспользуемый компонент (владелец + регистратура).
   Высоту строки (44px) задаёт JS инлайном — здесь только ширины/цвета/скролл.
   ============================================================ */
.sg { --sg-gutter: 62px; --sg-col: 190px; display: flex; flex-direction: column; }

.sg-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sg-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sg-nav .btn { display: inline-flex; align-items: center; gap: 4px; }
.sg-date { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; color: var(--text); background: #fff; }
.sg-caption { font-family: var(--font-head); font-weight: 700; font-size: 16px; color: var(--text); }
.sg-docfilter { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; color: var(--text); background: #fff; max-width: 210px; }

/* Легенда цветов статусов */
.sg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.sg-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.sg-leg-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.sg-leg-dot.sg-st-scheduled { background: #8496A8; }
.sg-leg-dot.sg-st-confirmed { background: var(--primary); }
.sg-leg-dot.sg-st-completed { background: var(--success); }
.sg-leg-dot.sg-st-cancelled { background: var(--danger); }
.sg-leg-dot.sg-st-no_show   { background: var(--warning); }

.sg-scroll { position: relative; overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.sg-grid { position: relative; width: max-content; min-width: 100%; }
.sg-loading { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* Шапка кабинетов — липкая сверху; левый верхний угол липнет и по горизонтали */
.sg-head { display: flex; position: sticky; top: 0; z-index: 5; background: var(--card); }
.sg-corner { flex: 0 0 var(--sg-gutter); position: sticky; left: 0; z-index: 6; background: var(--card); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.sg-colhead { flex: 0 0 var(--sg-col); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; }
.sg-colhead-ghost { background: #FAFBFC; color: var(--text-muted); }
.sg-colhead-inactive { background: #FAFBFC; color: var(--text-muted); }
.sg-colhead-name { overflow: hidden; text-overflow: ellipsis; }
.sg-colhead-num { color: var(--text-muted); font-weight: 600; }
.sg-colhead-off { background: #EEF1F5; color: #5A6B7D; border-radius: 6px; padding: 0 6px; font-size: 10px; font-weight: 700; }
.sg-colhead-count { flex: none; background: #EEF1F5; color: #5A6B7D; border-radius: 20px; padding: 1px 8px; font-size: 12px; font-weight: 700; }

/* Тело: левый жёлоб времени (липкий слева) + колонки-кабинеты */
.sg-cols { display: flex; position: relative; }
.sg-gutter { flex: 0 0 var(--sg-gutter); position: sticky; left: 0; z-index: 4; background: var(--card); border-right: 1px solid var(--border); }
.sg-tick { position: absolute; right: 8px; padding-top: 2px; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sg-col { flex: 0 0 var(--sg-col); position: relative; border-right: 1px solid var(--border); }
.sg-col-ghost { background: #FCFCFD; }
.sg-slot { position: absolute; left: 0; right: 0; border-top: 1px solid #EFF2F6; }
.sg-slot-hour { border-top-color: #DCE3EB; }
/* Затенение нерабочих часов врача (до/после смены и обед). Не перехватывает клики. */
.sg-shade { position: absolute; left: 0; right: 0; z-index: 0; background: rgba(90, 107, 125, .12); pointer-events: none; }

/* Карточка записи: высоту и позицию (top/height) задаёт JS. Цвет — по статусу (ниже). */
.sg-appt { position: absolute; left: 4px; z-index: 2; border-radius: 8px; padding: 4px 8px; overflow: hidden; background: #EAF2FB; border-left: 3px solid var(--primary); box-shadow: var(--shadow); font-size: 12px; line-height: 1.25; }
.sg-appt-time { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }
.sg-appt-status { flex: none; font-weight: 600; font-size: 10px; color: var(--text-muted); }
.sg-appt-name-row { display: flex; align-items: center; gap: 6px; }
.sg-appt-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-appt-debt { flex: none; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; line-height: 15px; padding: 0 5px; border-radius: 8px; white-space: nowrap; }
.sg-appt-svc, .sg-appt-phone { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Цвета статусов (канон): различимые тинты + цветная левая грань, текст остаётся тёмным.
   Совпадают с палитрой бейджей (.badge-*) в этом же файле. */
.sg-appt.sg-st-scheduled { background: #EEF1F5; border-left-color: #8496A8; }
.sg-appt.sg-st-confirmed { background: #E5F0FB; border-left-color: var(--primary); }
.sg-appt.sg-st-completed { background: #E4F7EE; border-left-color: var(--success); }
.sg-appt.sg-st-cancelled { background: #FDECEA; border-left-color: var(--danger); opacity: .82; }
.sg-appt.sg-st-no_show   { background: #FEF3E2; border-left-color: var(--warning); }
.sg-appt.sg-st-cancelled .sg-appt-name { text-decoration: line-through; }

/* Красная линия текущего времени (только сегодня) */
.sg-now { position: absolute; left: 0; right: 0; height: 0; z-index: 7; pointer-events: none; }
.sg-now::after { content: ''; position: absolute; left: var(--sg-gutter); right: 0; top: 0; border-top: 2px solid var(--danger); }
.sg-now-label { position: absolute; left: 0; top: -8px; width: var(--sg-gutter); text-align: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--danger); border-radius: 4px; padding: 1px 0; font-variant-numeric: tabular-nums; }

/* Пустой день: плашка по ЦЕНТРУ видимой области (оверлей поверх скролла, не в потоке
   сетки), ниже шапки, полностью читаема; не перехватывает клики по слотам. */
.sg-scroll-wrap { position: relative; }
.sg-empty-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: 44px; pointer-events: none; z-index: 8; }
.sg-empty { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 10px 20px; color: var(--text-muted); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); white-space: nowrap; }

/* Кликабельный слот (право записи) */
.sg-col-write { cursor: pointer; }

/* ── Модалка «Новая запись» (кусок г) ── */
.sg-modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(16, 28, 44, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.sg-modal { position: relative; width: 100%; max-width: 460px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 22px 22px 24px; }
.sg-modal-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: none; background: #F1F5F9; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.sg-modal-close:hover { background: #E2E8F0; color: var(--text); }
.sg-modal-title { font-family: var(--font-head); font-size: 18px; margin: 0 0 2px; }
.sg-modal-when { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.sgm-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sg-field { margin-bottom: 12px; }
.sg-field > label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.sg-field input[type="text"], .sg-field input[type="time"], .sg-field select { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; color: var(--text); background: #fff; }
.sg-field input:focus, .sg-field select:focus { outline: 2px solid rgba(27, 79, 138, .3); outline-offset: 1px; }
.sgm-remember { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); margin: -4px 0 14px; cursor: pointer; }
.sgm-remember input { width: 15px; height: 15px; }
.sgm-pat { position: relative; }
.sgm-psearch-wrap { position: relative; }
.sgm-presults { position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 5; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 220px; overflow: auto; }
.sgm-presult { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border: none; border-bottom: 1px solid var(--border); background: #fff; cursor: pointer; font: inherit; }
.sgm-presult:last-child { border-bottom: none; }
.sgm-presult:hover { background: #F4F9FE; }
.sgm-presult-name { font-weight: 600; color: var(--text); }
.sgm-presult-phone { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.sgm-pempty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }
.sgm-psummary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px; padding: 8px 12px; background: #F6F9FC; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.sgm-sum-item { color: var(--text-muted); }
.sgm-sum-item b { color: var(--text); }
.sgm-sum-item b.sgm-debt { color: var(--danger); }
.sgm-open-card { margin-left: auto; border: none; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.sgm-open-card:hover { text-decoration: underline; }
.sgm-newp-toggle { margin-top: 8px; border: none; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.sgm-newp-toggle:hover { text-decoration: underline; }
.sgm-newp { display: grid; gap: 8px; margin-top: 10px; }
.sgm-newp input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; }
.sgm-error { margin: 4px 0 12px; padding: 9px 12px; background: #FDECEA; border: 1px solid #F5C6C0; border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; font-weight: 500; }

/* Строка пациента в режиме переноса (модалка edit) */
.sgm-edit-patient { margin: 0 0 14px; padding: 8px 12px; background: #F6F9FC; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); font-weight: 500; }

/* Тост */
.sg-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 1100; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 1; transition: opacity .35s ease; }
.sg-toast-out { opacity: 0; }

/* ── Попап «Детали записи» (кусок в) ── */
.sg-detail-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(16, 28, 44, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; }
.sg-detail { position: relative; width: 100%; max-width: 400px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 20px 20px 22px; }
.sg-detail-close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border: none; background: #F1F5F9; border-radius: 8px; font-size: 19px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.sg-detail-close:hover { background: #E2E8F0; color: var(--text); }
.sg-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 28px 14px 0; }
.sg-detail-time { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-head); font-weight: 700; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.sg-detail-time i { width: 18px; height: 18px; }
.sg-detail-rows { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.sg-detail-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.sg-detail-row:last-child { border-bottom: none; }
.sg-detail-row > i { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.sg-detail-lbl { color: var(--text-muted); width: 78px; flex: none; }
.sg-detail-val { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.sg-detail-debt { color: var(--danger); }
.sg-detail-wa { display: inline-flex; align-items: center; gap: 5px; color: var(--success); font-weight: 600; }
.sg-detail-wa i { width: 15px; height: 15px; }
.sg-detail-status-btns { display: flex; gap: 8px; margin-bottom: 8px; }
.sg-detail-status-btns .btn { flex: 1; justify-content: center; }
.sg-detail-actions { display: flex; gap: 8px; }
.sg-detail-actions .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.sg-detail-error { margin-top: 10px; padding: 9px 12px; background: #FDECEA; border: 1px solid #F5C6C0; border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; font-weight: 500; }

@media (max-width: 640px) {
  .sg { --sg-col: 150px; --sg-gutter: 52px; }
  .sg-scroll { max-height: calc(100vh - 240px); }
  .sgm-2col { grid-template-columns: 1fr; }
}
