/* Static fallback only - overwritten at runtime from the `sites` record's brand_* fields
   once app.js fetches it (Phase 1+). Nothing tenant-specific should be hardcoded beyond this
   safe default so the dashboard renders sensibly before that fetch resolves. */
:root {
  --brand-primary: #ffc400;
  --brand-accent: #00a19a;
  --brand-dark: #1b1b1b;
  --brand-alert: #e5322d;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1b1b1b;
  --text-muted: #6b6b6b;
  --border: #e0e0e0;
  --touch-target: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--brand-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar__brand {
  padding: 20px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  border-radius: 8px;
  font-size: 1rem;
}

.sidebar__link:hover,
.sidebar__link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar__link .badge {
  margin-left: auto;
  background: var(--brand-alert);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 2px 8px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar__title {
  font-size: 1.25rem;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 24px;
  overflow: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.btn {
  min-height: var(--touch-target);
  padding: 0 20px;
  border-radius: 8px;
  border: none;
  background: var(--brand-primary);
  color: var(--brand-dark);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn--secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

/* The sidebar itself is always dark (var(--brand-dark)) regardless of the light-surface theme
   the rest of the dashboard uses, so a secondary button placed in it (the Log out button) needs
   its own light-on-dark colours rather than .btn--secondary's normal dark-on-light ones - without
   this the label was rendering ~invisible (near-black text on a near-black background). */
.sidebar .btn--secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }
  .sidebar__nav {
    flex-direction: row;
  }
}

/* ---- Login ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-dark);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--text-muted);
}

/* ---- Forms ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  min-height: var(--touch-target);
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.field textarea {
  min-height: 90px;
  padding: 10px 14px;
  resize: vertical;
}

.field input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

.form-section {
  margin-bottom: 28px;
}

.form-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- Tables / lists ---- */
.card + .card {
  margin-top: 16px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.list-row:hover {
  border-color: var(--brand-accent);
}

.list-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-row__title {
  font-weight: 600;
}

.list-row__subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--brand-accent);
  color: #fff;
  white-space: nowrap;
}

.badge--alert {
  background: var(--brand-alert);
}

.badge--muted {
  background: var(--text-muted);
}

/* ---- Drawer (job card detail) ---- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
}

.drawer {
  width: min(560px, 100%);
  background: var(--surface);
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.drawer__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.item-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.item-row:last-child {
  border-bottom: none;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding-top: 12px;
  font-size: 1.05rem;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--brand-dark);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  z-index: 200;
  max-width: 320px;
}

.toast--error {
  background: var(--brand-alert);
}

.spinner-row {
  display: flex;
  justify-content: center;
  padding: 40px 0;
  color: var(--text-muted);
}
