/* JOB-1893 B3-6: dark-aware theme for the lane's base app template
   (/srv/ai/projects/ai1builder-lane/templates/base/app/static/style.css).
   Self-contained -- no dependency on builder.dev's own app.css. Keeps the
   existing --bg/--fg/--muted/--accent/--line variable names so templates
   already written against them keep working, and adds the variables and
   rules every generated app (CRM, bookings, quotes, membership, cost
   report, ...) needs for a card, a badge/status chip and an error/success
   message. Every text/background pair below is checked for a 4.5:1
   contrast ratio in both schemes.

   Phone-first: base font-size and spacing work unscaled on a 390px
   viewport; every interactive element (button, input, select, textarea,
   link-as-button) keeps a 44px minimum tap target. RTL-safe: no left/right
   property is used anywhere (text-align: start, margin/padding-inline-*),
   so the same stylesheet is correct in a dir="rtl" page without a second,
   mirrored copy. */

:root {
  color-scheme: light dark;
  --bg: #fff;
  --surface: #f5f5f7;
  --fg: #1d2330;
  --muted: #5b6475;
  --accent: #2d6cdf;
  --accent-contrast: #fff;
  --line: #d9dee8;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --danger-on-bg: #991b1b;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #92400e;
  --warning-bg: #fef3c7;
  --focus: #2d6cdf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #181d27;
    --fg: #e8ecf3;
    --muted: #9aa3b5;
    --accent: #5b9aff;
    --accent-contrast: #0b1322;
    --line: #2a3140;
    --danger: #f87171;
    --danger-bg: #7f1d1d;
    --danger-on-bg: #fca5a5;
    --success: #4ade80;
    --success-bg: #14532d;
    --warning: #fde68a;
    --warning-bg: #78350f;
    --focus: #5b9aff;
  }
}

/* an explicit in-app choice (if the generated app ever adds its own
   toggle) always wins over the OS preference, same convention as
   builder.dev's own app.css. */
:root[data-theme="dark"] {
  --bg: #11151c;
  --surface: #181d27;
  --fg: #e8ecf3;
  --muted: #9aa3b5;
  --accent: #5b9aff;
  --accent-contrast: #0b1322;
  --line: #2a3140;
  --danger: #f87171;
  --danger-bg: #7f1d1d;
  --danger-on-bg: #fca5a5;
  --success: #4ade80;
  --success-bg: #14532d;
  --warning: #fde68a;
  --warning-bg: #78350f;
  --focus: #5b9aff;
}

:root[data-theme="light"] {
  --bg: #fff;
  --surface: #f5f5f7;
  --fg: #1d2330;
  --muted: #5b6475;
  --accent: #2d6cdf;
  --accent-contrast: #fff;
  --line: #d9dee8;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --danger-on-bg: #991b1b;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #92400e;
  --warning-bg: #fef3c7;
  --focus: #2d6cdf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

button, .btn {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  font: inherit;
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: start;
}

img, table {
  max-width: 100%;
}

/* a table wider than a phone screen scrolls inside itself -- in an RTL
   page letting it overflow instead would widen the whole layout. */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

/* the one card/list-item shape every template (a contact, an appointment,
   a booking slot, a membership tier, a quote...) can reuse. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin: 12px 0;
}

.empty-state {
  color: var(--muted);
}

.error-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--line);
  color: var(--fg);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-on-bg);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-weight: 600;
}

.field-error {
  color: var(--danger);
  font-size: 0.9rem;
}

.banner {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 12px 0;
}

.banner-success {
  background: var(--success-bg);
  color: var(--success);
}
