/*
 * HotelOS base component styles (spec §16.2). CSS-only so both apps share them.
 * Uses logical properties only — layouts mirror automatically under dir="rtl".
 */

.hos-stack { display: flex; flex-direction: column; gap: var(--hos-space-4); }
.hos-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hos-space-3); }
.hos-row--between { justify-content: space-between; }
.hos-grid { display: grid; gap: var(--hos-space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.hos-muted { color: var(--hos-color-text-muted); font-size: var(--hos-font-size-sm); }
.hos-visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.hos-page-title { font-size: var(--hos-font-size-xl); margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.hos-section-title { font-size: var(--hos-font-size-lg); margin: 0; font-weight: 650; }

.hos-card {
  background: var(--hos-color-surface);
  border: 1px solid var(--hos-color-border);
  border-radius: var(--hos-radius-lg);
  box-shadow: var(--hos-shadow);
  padding: var(--hos-space-4) var(--hos-space-6);
  min-inline-size: 0;
}
/* Phones (and 200% text): keep the compact padding so amounts and long words still fit at 320px. */
@media (max-width: 480px) { .hos-card { padding: var(--hos-space-4); } }
a.hos-card, button.hos-card { transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
a.hos-card:hover { box-shadow: var(--hos-shadow-hover); transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) { a.hos-card, button.hos-card { transition: none; } a.hos-card:hover { transform: none; } }

/*
 * A screen can give all its cards one accent: put class hos-tone and --hos-card-accent on its root element (a card opts
 * out with hos-card--plain). Used by the guest portal, where each tab has its own colour.
 */
/*
 * Colourful card boxes: set --hos-card-accent to one of the --hos-accent-* colours. The card gets an accent bar on
 * its start edge, a soft tint that fades out, and a tinted icon tile. Text stays in the normal text colour.
 */
.hos-card--accent,
.hos-tone .hos-card:not(.hos-card--plain) {
  --_accent: var(--hos-card-accent, var(--hos-color-primary));
  border-inline-start: 4px solid var(--_accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--_accent) 9%, var(--hos-color-surface)), var(--hos-color-surface) 140px);
}
.hos-card__head { display: flex; align-items: center; gap: var(--hos-space-3); margin-block-end: var(--hos-space-3); }
.hos-card__icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  inline-size: 38px; block-size: 38px; border-radius: 12px;
  color: var(--hos-card-accent, var(--hos-color-primary));
  background: color-mix(in srgb, var(--hos-card-accent, var(--hos-color-primary)) 16%, transparent);
}
.hos-card__title { font-size: var(--hos-font-size-lg); margin: 0; font-weight: 650; }
.hos-card-grid { display: grid; gap: var(--hos-space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

.hos-stat { display: flex; flex-direction: column; gap: var(--hos-space-1); }
.hos-stat__value { font-size: var(--hos-font-size-xl); font-weight: 700; }
.hos-stat__label { color: var(--hos-color-text-muted); font-size: var(--hos-font-size-sm); }

/* KPI tile: a solid accent icon, a big number, a label. Use inside .hos-grid; make it a link for a drill-down. */
.hos-kpi {
  --_accent: var(--hos-card-accent, var(--hos-color-primary));
  position: relative; overflow: hidden; display: flex; align-items: center; gap: var(--hos-space-3);
  background: var(--hos-color-surface); border: 1px solid var(--hos-color-border); border-radius: var(--hos-radius-lg);
  box-shadow: var(--hos-shadow); padding: var(--hos-space-4); color: inherit; text-decoration: none; min-inline-size: 0;
}
.hos-kpi::after {
  content: ''; position: absolute; inset-inline-end: -30px; inset-block-start: -30px; inline-size: 110px; block-size: 110px;
  border-radius: 50%; background: var(--_accent); opacity: 0.09; pointer-events: none;
}
.hos-kpi__icon {
  display: grid; place-items: center; flex: none; inline-size: 46px; block-size: 46px; border-radius: 14px;
  background: var(--_accent); color: var(--hos-on-accent);
}
.hos-kpi__body { display: flex; flex-direction: column; min-inline-size: 0; }
.hos-kpi__value { font-size: 1.65rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hos-kpi__label { color: var(--hos-color-text-muted); font-size: var(--hos-font-size-sm); font-weight: 550; }
a.hos-kpi:hover { box-shadow: var(--hos-shadow-hover); }

/*
 * Compact density for desktop work screens (staff app, owner 2026-11-01): smaller tiles and cards, so more data fits
 * at once. Put class hos-compact on the app's root; phones keep the roomier sizes.
 */
@media (min-width: 761px) {
  .hos-compact { --hos-space-4: 0.75rem; --hos-space-6: 1.125rem; }
  .hos-compact .hos-card { padding: var(--hos-space-3) var(--hos-space-4); }
  .hos-compact .hos-card__head { margin-block-end: var(--hos-space-2); }
  .hos-compact .hos-card__icon { inline-size: 30px; block-size: 30px; border-radius: 9px; }
  .hos-compact .hos-kpi { padding: var(--hos-space-2) var(--hos-space-3); gap: var(--hos-space-2); }
  .hos-compact .hos-kpi::after { inline-size: 80px; block-size: 80px; inset-inline-end: -24px; inset-block-start: -24px; }
  .hos-compact .hos-kpi__icon { inline-size: 34px; block-size: 34px; border-radius: 10px; }
  .hos-compact .hos-kpi__icon svg { inline-size: 18px; block-size: 18px; }
  .hos-compact .hos-kpi__value { font-size: 1.3rem; }
  .hos-compact .hos-kpi__label { font-size: 0.8rem; }
  .hos-compact .hos-page-title { font-size: 1.4rem; }
  .hos-compact .hos-section-title, .hos-compact .hos-card__title { font-size: 1.05rem; }
  .hos-compact .hos-grid { gap: var(--hos-space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
  .hos-compact .hos-table th, .hos-compact .hos-table td { padding-block: 6px; padding-inline: var(--hos-space-2); }
}

/*
 * A screen in its section's colour (staff app: the colour of its menu item, on the page root as --hos-card-accent with
 * class hos-tone): the page title gets an accent bar, tables an accent header, tabs an accent marker. Cards already
 * take it from the rule above.
 */
.hos-tone .hos-page-title { border-inline-start: 5px solid var(--hos-card-accent, var(--hos-color-primary)); padding-inline-start: var(--hos-space-3); }
.hos-tone .hos-table th {
  background: color-mix(in srgb, var(--hos-card-accent, var(--hos-color-primary)) 12%, var(--hos-color-surface));
  color: var(--hos-color-text);
}
.hos-tone .hos-tab[aria-selected='true'] { border-block-end-color: var(--hos-card-accent, var(--hos-color-primary)); }

/*
 * Spot-view building blocks shared by the work screens (owner, 2026-11-01): a strip of KPI tiles that can act as filters,
 * compact item tiles, coloured status chips with an icon, and a cards / table toggle. All take their colour from
 * --hos-card-accent (or --c on a chip), so a screen stays in its section's colour.
 */
.hos-kpis { display: grid; gap: var(--hos-space-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr)); }
button.hos-kpi { font: inherit; text-align: start; cursor: pointer; }
.hos-kpi[aria-pressed='true'], .hos-kpi[aria-selected='true'] { outline: 2px solid var(--_accent); outline-offset: 1px; background: color-mix(in srgb, var(--_accent) 8%, var(--hos-color-surface)); }
.hos-kpi--mini { padding: 6px var(--hos-space-2); gap: var(--hos-space-2); }
.hos-kpi--mini .hos-kpi__icon { inline-size: 28px; block-size: 28px; border-radius: 8px; }
.hos-kpi--mini .hos-kpi__icon svg { inline-size: 15px; block-size: 15px; }
.hos-kpi--mini .hos-kpi__value { font-size: 1.1rem; }
.hos-kpi--mini .hos-kpi__label { font-size: 0.75rem; }
.hos-kpi--mini::after { inline-size: 56px; block-size: 56px; inset-inline-end: -18px; inset-block-start: -18px; }

.hos-tiles { display: grid; gap: var(--hos-space-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.hos-tile {
  --_accent: var(--hos-card-accent, var(--hos-color-primary));
  display: flex; flex-direction: column; gap: 4px; min-inline-size: 0; padding: var(--hos-space-2) var(--hos-space-3);
  border: 1px solid var(--hos-color-border); border-inline-start: 4px solid var(--_accent); border-radius: var(--hos-radius-md);
  background: linear-gradient(180deg, color-mix(in srgb, var(--_accent) 7%, var(--hos-color-surface)), var(--hos-color-surface) 60px);
  box-shadow: var(--hos-shadow); color: inherit; text-decoration: none; font-size: var(--hos-font-size-sm);
}
a.hos-tile:hover, button.hos-tile:hover { box-shadow: var(--hos-shadow-hover); }
.hos-tile__head { display: flex; align-items: center; gap: var(--hos-space-2); min-inline-size: 0; }
.hos-tile__title { font-weight: 650; font-size: var(--hos-font-size-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-inline-size: 0; flex: 1; }
.hos-tile__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--hos-space-3); color: var(--hos-color-text-muted); }
.hos-tile__meta > span { display: inline-flex; align-items: center; gap: 4px; }
.hos-tile__badge {
  display: inline-grid; place-items: center; flex: none; min-inline-size: 34px; block-size: 26px; padding-inline: 6px; border-radius: 8px;
  background: var(--_accent); color: var(--hos-on-accent); font-weight: 750; font-variant-numeric: tabular-nums;
}

.hos-chip {
  --c: var(--hos-card-accent, var(--hos-color-primary));
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  font-size: 0.78rem; font-weight: 600; line-height: 1.6; color: var(--hos-color-text);
  background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.hos-chip svg { color: var(--c); }
button.hos-chip { font-family: inherit; cursor: pointer; }
button.hos-chip[aria-pressed='true'] { background: var(--c); color: var(--hos-on-accent); }
button.hos-chip[aria-pressed='true'] svg { color: inherit; }
.hos-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.hos-seg { display: inline-flex; border: 1px solid var(--hos-color-border-control); border-radius: var(--hos-radius-md); overflow: hidden; }
.hos-seg button { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--hos-color-surface); color: var(--hos-color-text-muted); font: inherit; font-size: var(--hos-font-size-sm); padding: 4px 10px; cursor: pointer; }
.hos-seg button[aria-pressed='true'] { background: var(--hos-card-accent, var(--hos-color-primary)); color: var(--hos-on-accent); }

/* Avatar: a photo, or initials on the accent when there is none. */
.hos-avatar {
  --_accent: var(--hos-card-accent, var(--hos-color-primary));
  display: inline-grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%;
  inline-size: var(--hos-avatar-size, 40px); block-size: var(--hos-avatar-size, 40px);
  background: var(--_accent); color: var(--hos-on-accent); font-weight: 700; font-size: calc(var(--hos-avatar-size, 40px) * 0.38);
  object-fit: cover; user-select: none;
}

/* Toggle switch (accessible: it wraps a real checkbox input). */
.hos-switch { display: inline-flex; align-items: center; gap: var(--hos-space-2); cursor: pointer; }
.hos-switch input { position: absolute; opacity: 0; inline-size: 1px; block-size: 1px; }
.hos-switch__track {
  inline-size: 40px; block-size: 22px; border-radius: 999px; background: var(--hos-color-border-control);
  position: relative; transition: background 0.15s ease; flex-shrink: 0;
}
.hos-switch__track::after {
  content: ''; position: absolute; inset-block-start: 2px; inset-inline-start: 2px;
  inline-size: 18px; block-size: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start 0.15s ease;
}
.hos-switch input:checked + .hos-switch__track { background: var(--hos-color-primary); }
.hos-switch input:checked + .hos-switch__track::after { inset-inline-start: 20px; }
.hos-switch input:focus-visible + .hos-switch__track { outline: 2px solid var(--hos-color-primary); outline-offset: 2px; }

/*
 * Persian typography. Arabic script has no italic or small caps: never let the browser fake them.
 * Persian letters reach further above and below the line (گ ک ی), so the line box is taller.
 */
:root { font-synthesis: none; }
:root:lang(fa) body { line-height: 1.7; }
:lang(fa) :where(.hos-page-title, .hos-section-title) { line-height: 1.5; }

/* Links follow the theme (browser default blue fails contrast on dark surfaces). */
:where(a) { color: var(--hos-color-primary); }

/* Buttons */
.hos-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--hos-space-2);
  min-block-size: 40px; padding-inline: var(--hos-space-4);
  border-radius: var(--hos-radius-md); border: 1px solid var(--hos-color-border-control);
  background: var(--hos-color-surface); color: var(--hos-color-text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
}
.hos-btn:hover { border-color: var(--hos-color-primary); background: var(--hos-color-surface-2); }
.hos-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hos-btn--primary {
  background: var(--hos-gradient-primary); border-color: transparent; color: var(--hos-color-on-primary);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--hos-color-primary) 28%, transparent);
}
.hos-btn--primary:hover { background: var(--hos-gradient-primary); filter: brightness(1.06); border-color: transparent; }
.hos-btn--danger { color: var(--hos-status-failed); border-color: currentColor; }
.hos-btn--sm { min-block-size: 32px; padding-inline: var(--hos-space-3); font-size: var(--hos-font-size-sm); }

:where(.hos-btn, .hos-input, a, button, select, [tabindex]):focus-visible {
  outline: 3px solid var(--hos-color-primary);
  outline-offset: 2px;
}

/* Forms */
.hos-field { display: flex; flex-direction: column; gap: var(--hos-space-1); }
.hos-field__label { font-weight: 600; font-size: var(--hos-font-size-sm); }
.hos-input {
  min-block-size: 40px; padding-inline: var(--hos-space-3);
  border: 1px solid var(--hos-color-border-control); border-radius: var(--hos-radius-md);
  background: var(--hos-color-surface); color: var(--hos-color-text); font: inherit;
}
textarea.hos-input { padding-block: var(--hos-space-2); min-block-size: 80px; }

/* Status badges — requested / pending / confirmed / failed / unknown / stale (spec §16.2, §14.3) */
.hos-badge {
  display: inline-flex; align-items: center; gap: var(--hos-space-1);
  padding-inline: var(--hos-space-2); border-radius: 999px;
  font-size: var(--hos-font-size-sm); font-weight: 600; white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 40%, transparent); color: var(--hos-color-text-muted);
  background: color-mix(in srgb, currentColor 11%, transparent);
}
.hos-badge--requested { color: var(--hos-status-requested); }
.hos-badge--pending { color: var(--hos-status-pending); }
.hos-badge--confirmed { color: var(--hos-status-confirmed); }
.hos-badge--failed { color: var(--hos-status-failed); }
.hos-badge--unknown { color: var(--hos-status-unknown); border-style: dashed; }
.hos-badge--stale { color: var(--hos-status-stale); border-style: dashed; }

/* Tables: horizontal scroll inside the card, never the page */
.hos-table-wrap { overflow-x: auto; position: relative; } /* contains abs-positioned visually-hidden labels */
.hos-table { inline-size: 100%; border-collapse: collapse; font-size: var(--hos-font-size-sm); }
.hos-table th, .hos-table td { white-space: nowrap; text-align: start; padding-block: var(--hos-space-2); padding-inline: var(--hos-space-3); border-block-end: 1px solid var(--hos-color-border); }
.hos-table th { color: var(--hos-color-text-muted); font-weight: 650; background: var(--hos-color-surface-2); }
.hos-table tbody tr:hover td { background: color-mix(in srgb, var(--hos-color-primary) 5%, transparent); }
.hos-num { font-variant-numeric: tabular-nums; text-align: end !important; }

/* Tabs */
.hos-tabs { display: flex; gap: var(--hos-space-2); border-block-end: 1px solid var(--hos-color-border); }
.hos-tab { padding-block: var(--hos-space-2); padding-inline: var(--hos-space-3); border: 0; background: none; font: inherit; color: var(--hos-color-text-muted); cursor: pointer; border-block-end: 2px solid transparent; }
.hos-tab[aria-selected='true'] { color: var(--hos-color-text); border-block-end-color: var(--hos-color-primary); font-weight: 600; }

/* Prototype banner — always visible on prototype screens */
.hos-prototype-banner {
  background: repeating-linear-gradient(-45deg, #fff4d6, #fff4d6 12px, #ffe9ad 12px, #ffe9ad 24px);
  color: #5a3d00; text-align: center; font-size: var(--hos-font-size-sm); font-weight: 600;
  padding-block: var(--hos-space-1); padding-inline: var(--hos-space-4);
}

/* Steps */
.hos-steps { display: flex; flex-wrap: wrap; gap: var(--hos-space-2); list-style: none; margin: 0; padding: 0; }
.hos-step { padding-block: var(--hos-space-1); padding-inline: var(--hos-space-3); border-radius: 999px; border: 1px solid var(--hos-color-border); font-size: var(--hos-font-size-sm); color: var(--hos-color-text-muted); }
.hos-step[aria-current='step'] { border-color: var(--hos-color-primary); color: var(--hos-color-text); font-weight: 600; }
.hos-step--done { color: var(--hos-status-confirmed); }
