/**
 * RASATA.LK — restaurant-tables.html
 * Page-specific styles only. All colours, radii and shadows come from
 * assets/css/variables.css so the page tracks the existing dashboard theme.
 * Every selector is prefixed with .rt- to avoid collisions with shared CSS.
 */

/* ── Base ────────────────────────────────────────────────────────────────── */

/* This page toggles state with the [hidden] attribute. Several blocks below
   set display:flex / display:grid, which would otherwise beat the UA rule for
   [hidden], so hidden is made authoritative here. */
[hidden] {
  display: none !important;
}

/* ── Page header ─────────────────────────────────────────────────────────── */

.rt-page-sub {
  max-width: 60ch;
  margin: .4rem 0 0;
}

/* ── Demo-mode banner ────────────────────────────────────────────────────── */

.rt-demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-top: 1.25rem;
  padding: .9rem 1.1rem;
  border: 2px dashed var(--orange);
  border-radius: 14px;
  background: #fff4ee;
  font-size: .92rem;
}

.rt-demo-chip {
  flex: none;
  padding: .28rem .7rem;
  border-radius: 999px;
  background: var(--charcoal);
  color: #fff;
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.rt-demo-banner .btn {
  margin-left: auto;
}

/* ── Shared blocks ───────────────────────────────────────────────────────── */

.rt-h2 {
  font-size: 1.4rem;
  margin: 0;
}

.rt-h3 {
  font-size: 1.05rem;
  margin: 1.8rem 0 .6rem;
}

.rt-card {
  margin-bottom: 1.6rem;
}

.rt-card-sub {
  margin: .3rem 0 0;
  font-size: .9rem;
  max-width: 62ch;
}

.rt-card-head {
  margin-bottom: 1rem;
}

.rt-section {
  margin-bottom: 2.4rem;
}

.rt-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.rt-hint {
  margin: .15rem 0 0;
  font-size: .82rem;
}

.rt-inline-label {
  font-weight: 700;
  font-size: .9rem;
}

.rt-req {
  color: var(--danger);
}

/* ── Page-level states ───────────────────────────────────────────────────── */

.rt-state {
  margin-bottom: 1.6rem;
}

.rt-state-title {
  font-weight: 800;
  font-size: 1.1rem;
  margin: 0 0 .35rem;
}

.rt-state-denied {
  border-left: 4px solid var(--danger);
}

.rt-state-error {
  border-left: 4px solid var(--orange);
}

.rt-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1rem 0 0;
}

/* ── Branch selector ─────────────────────────────────────────────────────── */

.rt-branch-bar {
  margin-bottom: 1.6rem;
}

.rt-branch-field {
  max-width: 420px;
}

.rt-branch-hint {
  margin: .6rem 0 0;
  font-size: .85rem;
}

.rt-branch-single {
  margin: 0 0 1.4rem;
  font-size: .92rem;
}

/* ── Reservation settings ────────────────────────────────────────────────── */

.rt-notice {
  margin-bottom: 1.4rem;
}

.rt-notice p {
  margin: 0;
  font-size: .92rem;
}

.rt-example {
  margin-top: .55rem !important;
  font-weight: 700;
}

.rt-settings-grid {
  grid-template-columns: repeat(3, 1fr);
}

.rt-settings-grid .span-2 {
  grid-column: 1 / -1;
}

.rt-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .9rem;
}

/* ── Status + error messages ─────────────────────────────────────────────── */

.rt-status {
  margin: 0;
  font-size: .88rem;
  font-weight: 700;
  min-height: 1.2em;
}

.rt-status:empty {
  min-height: 0;
}

/* Status is never signalled by colour alone — JS prefixes a text/glyph marker. */
.rt-status-ok {
  color: var(--success);
}

.rt-status-bad {
  color: var(--danger);
}

.rt-status-busy {
  color: var(--muted);
}

.rt-error {
  margin: .2rem 0 0;
  font-size: .84rem;
  font-weight: 700;
  color: var(--danger);
  min-height: 1.1em;
}

.rt-error:empty {
  min-height: 0;
}

.rt-field input[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff6f6;
}

/* ── Table cards ─────────────────────────────────────────────────────────── */

.rt-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.rt-table-card {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rt-table-card.is-inactive {
  background: var(--soft);
  border-style: dashed;
}

.rt-table-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .6rem;
}

.rt-table-name {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rt-table-seats {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}

.rt-table-seats span {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.rt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .9rem;
  margin: 0;
  font-size: .85rem;
  color: var(--muted);
}

.rt-meta strong {
  color: var(--charcoal);
  font-weight: 700;
}

/* Status pill: glyph + word, so meaning does not depend on colour. */
.rt-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .62rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.rt-pill-on {
  background: #e7f5ef;
  color: #12664a;
  border-color: #bfe4d4;
}

.rt-pill-off {
  background: #f3f4f6;
  color: #4b5563;
  border-color: var(--line);
}

.rt-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: auto;
  padding-top: .3rem;
}

.rt-table-actions .btn {
  flex: 1 1 auto;
  min-width: 108px;
}

.rt-btn-sm {
  padding: .5rem .8rem;
  font-size: .85rem;
  min-height: 40px;
}

.rt-btn-danger {
  color: var(--danger);
  border-color: #f0c9c9;
}

.rt-btn-danger:hover {
  background: #fff6f6;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.rt-empty {
  background: #fff;
}

.rt-empty-mark {
  font-size: 2.4rem;
  margin: 0 0 .4rem;
  color: var(--orange);
}

.rt-empty-title {
  margin: 0 0 .4rem;
}

.rt-empty .muted {
  max-width: 46ch;
  margin: 0 auto 1.2rem;
}

/* ── Combinable tables ───────────────────────────────────────────────────── */

.rt-fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.2rem;
}

.rt-legend {
  padding: 0;
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: .6rem;
}

.rt-combo-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .55rem;
}

.rt-combo-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  min-height: 48px;
}

.rt-combo-option:hover {
  background: var(--warm);
}

.rt-combo-option input {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--orange);
}

.rt-combo-option-text {
  font-size: .9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.rt-combo-option-text small {
  display: block;
  font-weight: 600;
  color: var(--muted);
}

.rt-combo-option.is-checked {
  border-color: var(--orange);
  background: #fff4ee;
}

.rt-combo-form {
  align-items: start;
}

.rt-capacity {
  margin: .35rem 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.rt-combo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .7rem;
}

.rt-combo-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .9rem 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.rt-combo-item-main {
  min-width: 0;
}

.rt-combo-item-title {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rt-combo-item-sub {
  margin: .15rem 0 0;
  font-size: .85rem;
  color: var(--muted);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

.rt-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(11, 15, 20, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  overflow-y: auto;
}

.rt-modal-backdrop[hidden] {
  display: none;
}

.rt-modal {
  width: min(100%, 560px);
  max-height: calc(100vh - 2.4rem);
  overflow-y: auto;
  box-shadow: 0 30px 70px rgba(11, 15, 20, .35);
}

.rt-field {
  margin-bottom: 1rem;
}

.rt-check-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.rt-check-row input {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--orange);
}

.rt-check-row label {
  font-weight: 700;
  font-size: .9rem;
  margin: 0;
}

.rt-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.2rem;
}

.rt-modal-danger {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

body.rt-modal-open {
  overflow: hidden;
}

/* ── Focus visibility ────────────────────────────────────────────────────── */

#rt-main a:focus-visible,
#rt-main button:focus-visible,
#rt-main input:focus-visible,
#rt-main select:focus-visible,
.rt-modal a:focus-visible,
.rt-modal button:focus-visible,
.rt-modal input:focus-visible,
.rt-modal select:focus-visible,
.rt-demo-banner a:focus-visible,
.sidebar a:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width:1000px) {
  .rt-settings-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rt-section-head .btn {
    width: 100%;
  }
}

@media (max-width:620px) {

  .rt-settings-grid,
  .rt-combo-picker,
  .rt-tables-grid {
    grid-template-columns: 1fr;
  }

  .rt-demo-banner .btn {
    margin-left: 0;
    width: 100%;
  }

  .rt-branch-field {
    max-width: none;
  }

  .rt-table-actions .btn,
  .rt-modal-actions .btn,
  .rt-state-actions .btn {
    width: 100%;
    flex: 1 1 100%;
  }

  .rt-combo-item .btn {
    width: 100%;
  }

  .rt-modal-backdrop {
    padding: .8rem;
    align-items: flex-start;
  }

  .rt-modal {
    max-height: calc(100vh - 1.6rem);
  }
}
