/* Shared shell, theme tokens and form controls for the tree utilities. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dce3;
  --border-strong: #b9c0cb;
  --text: #1c2128;
  --text-muted: #5b6675;
  --accent: #2f6fb5;
  --accent-soft: #e4eefb;
  --male: #3b7fc4;
  --female: #c25b8f;
  --unknown: #7d8794;
  --danger: #b3382c;
  --warning: #9a6a00;
  --ok: #2c7a4b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --radius: 7px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Rick Tony Software palette (ricktony.com, as in WorkLog): navy bars inside a brass band */
  --rt-navy: #142744;
  --brass: #c0a050;
  --brass-dark: #8a6e2f;
  --brass-deep: #6b5423;
  --brass-light: #dcc079;
  --brass-pale: #efdba4;
  --brass-ink: #16202a;            /* text on a brass button */
  --brass-band: linear-gradient(135deg, var(--brass-dark) 0%, var(--brass-pale) 10%, var(--brass) 22%,
    var(--brass-deep) 36%, var(--brass-light) 52%, var(--brass) 66%, var(--brass-pale) 82%, var(--brass-dark) 100%);
  --brass-bevel: 0 0 0 1px rgba(46, 34, 10, 0.9), 0 3px 10px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(46, 34, 10, 0.78), inset 0 0 0 2px rgba(255, 244, 214, 0.26);
  --on-navy: #e6edf5;              /* text straight on the navy */
  --on-navy-muted: #aebbcc;
  --on-navy-line: rgba(255, 255, 255, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #232830;
    --border: #333a45;
    --border-strong: #454e5c;
    --text: #e6e9ee;
    --text-muted: #9aa4b2;
    --accent: #6ba5e7;
    --accent-soft: #1e2c3d;
    --male: #6ba5e7;
    --female: #e08ab5;
    --unknown: #97a1ae;
    --danger: #f08076;
    --warning: #e0aa3e;
    --ok: #63c98d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------- header and footer */

/* The same frame as the WorkLog pages: navy inside a brass band, floating a little off the page edge.
   Header: brand (icon + page name) on the left, then the file/view controls, the View / Edit switch on the right.
   Footer: the save buttons in one thin row, the company line under them. */
.app-header, .app-footer {
  flex: none;
  z-index: 5;
  margin: 0.5rem 0.5rem 0;
  border: 5px solid transparent;
  border-radius: 16px;
  background: linear-gradient(var(--rt-navy), var(--rt-navy)) padding-box, var(--brass-band) border-box;
  box-shadow: var(--brass-bevel);
  color: var(--on-navy);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--brass-pale);
}
.app-header .brand a { display: inline-flex; line-height: 0; border-radius: 50%; }
.app-header .brand a:focus-visible { outline: 2px solid var(--brass-pale); outline-offset: 2px; }
.app-header .brand img { width: 32px; height: 32px; border-radius: 50%; box-shadow: 0 0 0 1px var(--brass-dark); display: block; }
.app-header .brand h1 { font: inherit; margin: 0; }

.app-header .spacer { flex: 1; }

/* captions above the header's fields read light on the navy; the fields themselves keep white boxes */
.app-header label.field, .app-header .header-field > span { color: var(--on-navy-muted); }
.app-header .header-sep { background: var(--on-navy-line); }

/* controls sitting on the navy: outlined in light, the current page and the primary actions in brass */
.app-header button, .app-footer button {
  background: transparent;
  color: var(--on-navy);
  border-color: var(--on-navy-line);
}
.app-header button:hover:not(:disabled), .app-footer button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.app-header button.primary, .app-footer button.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.app-header button.primary:hover:not(:disabled), .app-footer button.primary:hover:not(:disabled) { background: var(--brass-light); filter: none; }
.app-header button:focus-visible, .app-footer button:focus-visible,
.app-header input:focus-visible, .app-header select:focus-visible { outline-color: var(--brass-pale); }

/* View / Edit switch: one outlined group, the current page filled in brass */
.app-nav {
  display: inline-flex;
  gap: 0;
  padding: 0;
  background: transparent;
  border: 1px solid var(--on-navy-line);
  border-radius: 8px;
  overflow: hidden;
}
.app-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 0;
  border-left: 1px solid var(--on-navy-line);
  text-decoration: none;
  color: var(--on-navy);
  font-weight: 550;
  font-size: 13px;
  white-space: nowrap;
}
.app-nav a:first-child { border-left: none; }
.app-nav a:hover { color: var(--on-navy); background: rgba(255, 255, 255, 0.08); }
.app-nav a[aria-current="page"] { background: var(--brass); color: var(--brass-ink); font-weight: 650; box-shadow: none; }

/* footer: as thin as the buttons allow */
.app-footer {
  margin: 0 0.5rem 0.5rem;
  padding: 3px 12px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.footer-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.footer-actions button { padding: 2px 11px; font-size: 12.5px; }
.footer-legal {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.3;
  text-align: center;
  color: var(--on-navy-muted);
}
.footer-legal a { color: inherit; }
/* ------------------------------------------------------------------ inputs */

label.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="text"], input[type="search"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
  width: 100%;
}

textarea { resize: vertical; min-height: 62px; line-height: 1.45; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .7; }

button, .btn {
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:hover:not(:disabled), .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }

button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-strong)); }
button.icon { padding: 5px 8px; }

/* ------------------------------------------------------------------ layout */

.app-body { flex: 1; display: flex; min-height: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-size: 12px; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state strong { color: var(--text); font-size: 15px; font-weight: 600; }

/* ----------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-size: 13px;
  max-width: 420px;
  animation: toast-in .18s ease-out;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- scrollbar */

.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--surface); }
.scroll::-webkit-scrollbar-track { background: transparent; }
