/*
 * Park Rost — компоненти (етап 0.5). Спільні для сайту й адмінки; лише токени з tokens.css.
 * Макроси Twig: templates/components/{ui,form,icons}.twig. Витрина: /admin/system/ui.
 */

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* атрибут hidden сильніший за display компонентів */
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs-base)/var(--lh) var(--font); overflow-wrap: break-word; }
img, svg, video { max-width: 100%; }
img { height: auto; }
a { color: var(--brand); }
a:hover { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: var(--lh-tight); letter-spacing: -.015em; margin: 0; }
h1, .h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2, .h2 { font-size: var(--fs-xl); font-weight: 800; }
h3, .h3 { font-size: var(--fs-lg); font-weight: 800; }
h4, .h4 { font-size: var(--fs-md); font-weight: 700; }
p { margin: 0 0 var(--s-3); }
code { font-family: var(--mono); font-size: .92em; }
.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: var(--s-2); left: var(--s-2); z-index: var(--z-toast); padding: var(--s-2) var(--s-3); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.grid-auto { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.code { margin: 0; padding: var(--s-3) 14px; border-radius: var(--r); background: var(--code-bg); color: var(--code-text); font: var(--fs-sm)/1.5 var(--mono); overflow-x: auto; }
.req { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r); border: 1px solid var(--input-line); background: var(--surface); color: var(--text); font-size: var(--fs-ui); font-weight: 700; line-height: 1.2; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn--danger { color: var(--danger); border-color: var(--danger-line); }
.btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--hover); }
.btn--outline { background: transparent; }
.btn--small { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--large { min-height: 52px; padding: 0 var(--s-6); font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn--block { width: 100%; min-height: var(--tap); }
.btn--icon { width: 40px; padding: 0; }
.btn--small.btn--icon { width: 32px; }
.btn[aria-busy="true"]::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 767px) { .btn { min-height: var(--tap); } .btn--small { min-height: 36px; } }

/* ---------- Бейджі й статуси ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warn { background: var(--warning-bg); color: var(--warning); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Повідомлення ---------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-ui); }
.alert > .ic { margin-top: 1px; }
.alert p { margin: 0; }
.alert--success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.alert--warn { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.alert--danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.alert--info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

/* ---------- Картки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card--pad { padding: var(--s-5); }
.card__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.card__title { margin: 0; font-size: var(--fs-md); font-weight: 800; flex: 1 1 auto; }
.card__body { padding: var(--s-5); }
.card__media { aspect-ratio: 3 / 2; background: var(--n-150); border-radius: var(--r-lg) var(--r-lg) 0 0; overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__foot { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft); }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.tile { display: flex; align-items: center; gap: var(--s-3); padding: 18px var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--text); font-weight: 700; text-decoration: none; }
.tile:hover { border-color: var(--selected-line); background: var(--selected); color: var(--text); }

/* ---------- Поля ---------- */
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-6); }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px var(--s-6); }
.form__full { grid-column: 1 / -1; }
.form__bar { position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-6) calc(var(--s-6) * -1) calc(var(--s-6) * -1); padding: var(--s-4) var(--s-6); background: var(--surface); border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form__section { margin: var(--s-6) 0 0; padding: 0; border: 0; min-width: 0; }
.form__section legend, .form__section summary { font-size: 15px; font-weight: 800; margin-bottom: var(--s-3); cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; min-width: 0; }
.field--textarea { grid-column: 1 / -1; }
.field > label, .field__label { font-size: var(--fs-sm); font-weight: 600; }
.input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea { width: 100%; height: 40px; padding: 0 var(--s-3); border: 1px solid var(--input-line); border-radius: var(--r); background: var(--input-bg); font-size: var(--fs-ui); }
.field textarea { height: auto; min-height: 120px; padding: 10px var(--s-3); resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus,
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); outline: none; box-shadow: var(--focus-ring); }
.field--money input { padding-right: var(--s-8); }
.field .suffix { position: absolute; right: var(--s-3); bottom: 9px; color: var(--muted); font-weight: 600; }
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.field .error { margin: 0; color: var(--danger); font-size: var(--fs-sm); font-weight: 600; }
.field .hint, .hint { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: var(--fs-ui); font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); flex: 0 0 auto; }
@media (max-width: 767px) {
    .input, .field input:not([type="checkbox"]):not([type="radio"]), .field select { height: var(--tap); font-size: var(--fs-base); }
    .form { padding: var(--s-4); }
    .form__grid { grid-template-columns: 1fr; }
    .form__bar { margin: var(--s-4) calc(var(--s-4) * -1) calc(var(--s-4) * -1); padding: var(--s-3) var(--s-4); }
}

/* Перемикач */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: var(--fs-ui); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--input-line); flex: 0 0 44px; transition: background .15s; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--n-0); box-shadow: var(--shadow-sm); transition: left .15s; }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { left: 21px; }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Діапазон дат */
.daterange { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-2) var(--s-3); }
.daterange__nights { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--muted); }

/* Лічильник гостей */
.guests { display: flex; flex-direction: column; gap: var(--s-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.guests > legend { padding: 0; margin-bottom: var(--s-1); }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: var(--tap); }
.stepper__label { display: flex; flex-direction: column; font-size: var(--fs-ui); font-weight: 600; }
.stepper__label small { font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }
.stepper__ctrl { display: inline-flex; align-items: center; gap: var(--s-2); }
.stepper__ctrl output { min-width: 28px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper__ctrl .btn { width: 40px; padding: 0; border-radius: 50%; }
.guests__ages { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s-2); }
.guests__ages:empty { display: none; }

/* ---------- Список і таблиця ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.toolbar input, .toolbar select, .bulk select { height: 40px; padding: 0 var(--s-3); border: 1px solid var(--input-line); border-radius: var(--r); background: var(--input-bg); font-size: var(--fs-ui); max-width: 100%; }
.toolbar input[type="search"] { flex: 1 1 240px; max-width: 360px; background: var(--search-bg); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-ui); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table th a { color: inherit; text-decoration: none; }
.table td { padding: 14px var(--s-4); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td a { font-weight: 700; text-decoration: none; }
.col-check, .col-drag { width: 1%; }
.col-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.col-drag { cursor: grab; color: var(--subtle); user-select: none; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-actions .btn + .btn, .col-actions form + form { margin-left: 6px; }
.col-actions form { display: inline; }
tr.is-dragging { opacity: .5; }
.bulk { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-3); font-size: var(--fs-ui); font-weight: 600; }
.bulk .muted { margin-left: auto; font-weight: 500; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager__btn { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-ui); font-weight: 600; text-decoration: none; }
.pager__btn:hover { border-color: var(--brand-line); color: var(--brand-text); }
.pager__btn.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager__btn.is-disabled { opacity: .4; pointer-events: none; }
.pager__btn--next svg { transform: scaleX(-1); }
.pager__gap { min-width: 24px; text-align: center; color: var(--muted); }
.pager__info { margin-left: var(--s-3); font-size: var(--fs-ui); color: var(--muted); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-3) var(--s-8); margin: 0; padding: var(--s-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); font-size: var(--fs-ui); }
.details dt { color: var(--muted); font-weight: 600; }
.details dd { margin: 0; min-width: 0; }
@media (max-width: 767px) {
    .details { grid-template-columns: 1fr; gap: var(--s-1); }
    .details dd { margin-bottom: 10px; }
    .bulk .muted { margin-left: 0; flex-basis: 100%; }
}

/* ---------- Порожній стан і скелетон ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-10) var(--s-6); text-align: center; color: var(--muted); background: var(--surface); border: 2px dashed var(--dash-line); border-radius: var(--r-lg); }
.empty .ic { width: 32px; height: 32px; color: var(--subtle); }
.empty__title { margin: 0; color: var(--text); font-size: var(--fs-md); font-weight: 800; }
.empty p { margin: 0; }
.empty .btn { margin-top: var(--s-2); }
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--n-150) 25%, var(--n-50) 50%, var(--n-150) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton--text { height: 14px; margin: 6px 0; }
.skeleton--title { height: 22px; width: 50%; margin-bottom: var(--s-3); }
.skeleton--box { aspect-ratio: 3 / 2; border-radius: var(--r-lg); }
.grid-auto > .card, .grid-auto > .empty { align-self: start; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Вкладки ---------- */
.tabs__list { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs__list::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; min-height: var(--tap); padding: 0 var(--s-4); border: 0; border-bottom: 2px solid transparent; background: transparent; font-size: var(--fs-ui); font-weight: 700; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.tabs__panel { padding-top: var(--s-4); }
.tabs__panel[hidden] { display: none; }

/* ---------- Модальне вікно (<dialog>) ---------- */
.modal { border: 0; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - var(--s-8))); max-width: calc(100vw - var(--s-8)); max-height: calc(100dvh - var(--s-8)); border-radius: var(--r-xl); flex-direction: column; }
.modal[open] { display: flex; }
.modal--wide { width: min(900px, calc(100vw - var(--s-8))); }
.modal::backdrop { background: var(--overlay); }
.modal__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.modal__title { margin: 0; font-size: var(--fs-md); font-weight: 800; flex: 1 1 auto; }
.modal__body { padding: var(--s-5); flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.modal__body h3 { font-size: var(--fs-md); font-weight: 700; color: var(--n-700); letter-spacing: 0; } /* підзаголовки в модалках — спокійніші */
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft); }
.modal[open] { animation: pop .15s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@media (max-width: 767px) {
    .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
}

/* ---------- Тости ---------- */
.toasts { position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-2); max-width: min(440px, calc(100vw - var(--s-8))); }
.toast { padding: 14px 18px; border-radius: 12px; background: var(--n-900); color: var(--n-0); font-size: var(--fs-ui); font-weight: 600; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; }
.toast--success { background: var(--brand); color: var(--on-brand); }
.toast--error { background: var(--danger); color: #fff; }
@media (max-width: 767px) { .toasts { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); max-width: none; } }

/* ---------- Кроки ---------- */
.step { display: flex; align-items: center; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-ui); }
.step:last-child { border-bottom: 0; }
.dot { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--input-line); flex: 0 0 22px; display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); }
.step.done .dot { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.step.run .dot { border-color: var(--brand); }

/* ---------- Хлібні крихти ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--muted); }
.crumbs li + li::before { content: '/'; margin-right: var(--s-2); color: var(--subtle); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
