/* Reusable pieces: cards, forms, buttons, notices, badges, tiles, tables, tabs. */

.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--space);
}

/* Forms */
.form { display: grid; gap: 12px; max-width: 720px; }
.form fieldset { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 12px; }
.form legend { font-weight: 600; margin-bottom: 8px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 0.9rem; color: var(--c-muted); }
.field input, .field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.field-row { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 600px) {
  .field-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  color: var(--c-text);
  text-decoration: none;
  cursor: pointer;
}
.button--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.button--primary:hover { background: var(--c-primary-dark); }
.button--danger { border-color: var(--c-bad); color: var(--c-bad); }
.button[disabled] { opacity: 0.6; cursor: wait; }
.button--small { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.link-button { border: 0; background: none; padding: 8px; cursor: pointer; text-decoration: underline; }

/* Notices */
.notice { padding: 12px var(--space); border-radius: 8px; margin: 0 0 var(--space); border: 1px solid; }
.notice ul { margin: 4px 0 0; padding-left: 20px; }
.notice p { margin: 0; }
.notice--success { background: #eaf6ef; border-color: #b7dfc6; color: var(--c-good); }
.notice--info { background: #eaf2f8; border-color: #bcd3e6; color: var(--c-primary-dark); }
.notice--warn { background: #fdf3e2; border-color: #efd29e; color: var(--c-warn); }
.notice--error { background: #fbeceb; border-color: #efbdb9; color: var(--c-bad); }

/* Alerts that stay on the page until the cause is fixed, e.g. grace period */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px var(--space);
  margin: 0 0 var(--space);
  border-radius: var(--radius);
  border: 1px solid #efd29e;
  border-left: 6px solid var(--c-warn);
  background: #fdf3e2;
}
.alert__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-warn);
  color: #fff;
  font-weight: 700;
}
.alert__title { margin: 0; font-weight: 700; color: var(--c-warn); }
.alert__text { margin: 2px 0 0; }

/* Status badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.badge--paid { background: #eaf6ef; color: var(--c-good); }
.badge--grace { background: #fdf3e2; color: var(--c-warn); }
.badge--expired, .badge--none { background: #fbeceb; color: var(--c-bad); }
.badge--scheduled { background: #eaf2f8; color: var(--c-primary-dark); }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: var(--space) 0; }
.tile {
  display: grid;
  gap: 2px;
  padding: var(--space);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-primary);
  border-radius: var(--radius);
  color: var(--c-text);
  text-decoration: none;
}
.tile--warn { border-left-color: var(--c-warn); }
.tile--muted { border-left-color: var(--c-muted); }
.tile--bad { border-left-color: var(--c-bad); }
.tile--bad .tile__count { color: var(--c-bad); }
.tile__count { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile__label { font-weight: 600; }
.tile__hint { font-size: 0.85rem; color: var(--c-muted); }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; }
.tabs__tab {
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--c-text);
  text-decoration: none;
  border: 1px solid var(--c-border);
  background: #fff;
}
.tabs__tab.is-current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.tabs__count { font-variant-numeric: tabular-nums; opacity: 0.8; }

/* Tables: a normal table on wide screens, stacked cards on phones. */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--c-card); }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.table th { font-size: 0.85rem; color: var(--c-muted); font-weight: 600; }
.table th.num, .table td.num { text-align: right; }
.table tr.is-off { color: var(--c-muted); }

@media (max-width: 699px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--c-border); border-radius: var(--radius); margin-bottom: 12px; padding: 8px 0; }
  .table td { border: 0; padding: 4px 12px; text-align: left; }
  .table td.num { text-align: left; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--c-muted); font-size: 0.85rem; }
}

/* Live bill preview on admin forms */
.bill-total { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--c-bg); font-weight: 600; }

/* Simple stacked lists */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.plain-list li:last-child { border-bottom: 0; }

/* Definition lists for detail pages */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 var(--space); }
.details dt { color: var(--c-muted); }
.details dd { margin: 0; }

.text-warn { color: var(--c-warn); font-weight: 600; font-size: 0.9rem; }

/* Language picker and Admin → Languages */
.lang-picker { margin-top: auto; padding: 12px var(--space); }
.lang-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }
.chip-button { min-height: 40px; padding: 4px 14px; border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-card); color: var(--c-text); font: inherit; cursor: pointer; }
.chip-button.is-current { border-color: var(--c-primary); background: var(--c-primary); color: #fff; }
.meter { display: inline-block; width: 80px; height: 8px; border-radius: 4px; background: var(--c-bg); vertical-align: middle; overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--c-good); }
.words .word textarea { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--c-border); border-radius: 8px; font: inherit; resize: vertical; }
.source { font-size: 0.75rem; padding: 1px 6px; border-radius: 6px; background: var(--c-bg); color: var(--c-muted); font-weight: 600; }
.source--missing { background: #fdecea; color: var(--c-bad); }
.source--google { background: #fdf3e2; color: var(--c-warn); }
.source--edited { background: #eaf6ef; color: var(--c-good); }

/* Customer pages */
.customer-page { max-width: 640px; margin: 0 auto; padding: 16px; }
.auth__alt { text-align: center; margin: 12px 0 0; }
.lang-picker__choices { display: flex; flex-wrap: wrap; gap: 6px; }
.vendor-item p { margin: 0 0 4px; }
.vendor-item .actions form { margin: 0; }

/* Sign in with Google */
.google-signin { margin-top: 12px; }
.google-signin__or { display: flex; align-items: center; gap: 8px; color: var(--c-muted); font-size: 0.85rem; margin: 0 0 12px; }
.google-signin__or::before, .google-signin__or::after { content: ''; flex: 1; border-top: 1px solid var(--c-border); }
.google-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.topbar__link { color: inherit; margin-right: 12px; }
.topbar__link:first-of-type { margin-left: auto; }

/* Star rating: 5 radio buttons shown right-to-left so CSS can light up the stars before the chosen one */
.stars { display: inline-flex; flex-direction: row-reverse; gap: 4px; margin: 8px 0 12px; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { font-size: 2.4rem; line-height: 1; color: #c9ced6; cursor: pointer; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: #f2a541; }
.stars input:focus-visible + label { outline: 2px solid var(--c-primary); border-radius: 4px; }
.code-input { text-transform: uppercase; letter-spacing: 0.4em; font-size: 1.4rem; text-align: center; }

/* One login, several roles */
.login-who { margin: 0 0 12px; }
.role-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.role-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-card); color: var(--c-text); text-decoration: none; font: inherit; text-align: left; cursor: pointer; }
.role-card:hover, .role-card:focus { border-color: var(--c-primary); }
.role-card--add { border-style: dashed; }

/* File pickers: never wider than their card */
.form input[type="file"] { max-width: 100%; min-width: 0; }
.form > * { min-width: 0; }
.photo-error { color: var(--danger, #b42318); font-size: .85rem; margin: .25rem 0 0; }

/* Urgent orders */
.badge--urgent { background: #fdecea; color: #b42318; font-weight: 600; border-radius: 999px; padding: 2px 10px; font-size: .8rem; }
.urgent-card { border-left: 4px solid #b42318; }
.urgent-card h2 { display: flex; align-items: center; gap: 8px; }
.urgent-pick { margin: 8px 0; }

/* Customer app: 🔔 updates */
.topbar__bell { position: relative; font-size: 1.15rem; text-decoration: none; }
.bell-count { position: absolute; top: -4px; right: -10px; background: #b42318; color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; line-height: 1.5; }
.notice-item { display: flex; flex-direction: column; gap: 4px; }
.notice-item--new { border-left: 4px solid var(--c-primary); }
.push-offer .button { margin-top: 6px; }
