/* ============================================================
   bee-theme.css — Bee Cells design system.
   Visual language aligned with bee carpenter: Oswald/Quicksand,
   accent yellow, sharp 2px corners, 4px accent rules, dark default
   with a light theme, compact sizing.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Quicksand:wght@400;500;600;700&display=swap');

:root {
  --rule: 4px;
  --radius: 2px;
  font-size: 16px;
  --font-head: "Oswald", system-ui, sans-serif;
  --font-body: "Quicksand", system-ui, sans-serif;

  /* Dark (default) */
  --bg: #121212;
  --panel: #1b1b1b;
  --panel-2: #222;
  --ink: #f4f4f0;
  --muted: #8c8c86;
  --faint: #76766f;
  --accent: #ffcb05;
  --accent-ink: #121212;
  --line: #3a3a37;
  --line-strong: #f4f4f0;
  --danger: #ff5a4d;
  --success: #2ecc71;
  --info: #3fa7ff;
  --warning: #ffcb05;
}

html[data-theme="light"] {
  --bg: #f4f4f0;
  --panel: #ffffff;
  --panel-2: #ebebe4;
  --ink: #1a1a1a;
  --muted: #6b6b64;
  --faint: #7c7c72;
  --accent: #f5b800;
  --accent-ink: #121212;
  --line: #d6d6cc;
  --line-strong: #1a1a1a;
  --danger: #d8392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, .tb-title, .nav-brand .sub, .nav-section-title,
table.data thead th, .btn, .modal-head h2, .field label,
.chip, .tag, .pagination, .state, .toast {
  font-family: var(--font-head);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Keyboard focus (WCAG 2.4.7) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
*:focus:not(:focus-visible) { outline: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ============================ Buttons ============================ */
button, .btn {
  font-family: var(--font-head);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, filter 0.15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--ink); }

.card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.muted { color: var(--muted); }
.accent-rule { height: var(--rule); width: 64px; background: var(--accent); margin: 0.5rem 0 1.25rem; }

/* ============================ App shell ============================ */
body.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- Sidebar ---- */
bee-navbar {
  width: 208px;
  flex-shrink: 0;
  background: #121212;
  color: #e9eaec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #232323;
}
.nav-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.nav-brand .logo { width: 24px; height: 24px; display: block; flex: none; }
.nav-brand .sub {
  font-family: var(--font-head); font-weight: 600; font-size: 13px;
  letter-spacing: 0.22em; text-transform: uppercase; color: #e9eaec;
  white-space: nowrap;
}

/* Honeycomb rail: connecting spine behind the per-link hexagons. */
.nav-rail { position: relative; flex: 1; padding: 0.3rem 0; }
.nav-rail::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px;
  background: var(--accent); opacity: 0.16; z-index: 0;
}
.nav-section { padding: 0; }
.nav-section-title {
  font-size: 0.56rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em;
  color: #6f6f68; padding: 0.7rem 0 0.35rem 40px; position: relative; z-index: 1;
}

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 12px 0.5rem 40px; margin: 0.05rem 0;
  color: #c4c5c9;
  font-family: var(--font-body); font-size: 0.84rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
/* Background pill drawn only over the label area, leaving the hex gutter dark. */
.nav-link::after {
  content: ''; position: absolute; left: 28px; right: 6px; top: 2px; bottom: 2px;
  border-radius: var(--radius); z-index: 0; transition: background 0.12s;
}
.nav-link:hover::after { background: rgba(255,255,255,0.06); }
.nav-link.active::after { background: var(--accent); }
.nav-link:hover { text-decoration: none; }
.nav-link:hover .label { color: #fff; }
.nav-link.active .label { color: var(--accent-ink); font-weight: 600; }
.nav-link .ico, .nav-link .label { position: relative; z-index: 1; }
.nav-link .ico { width: 18px; height: 18px; flex: none; color: var(--accent); display: inline-flex; }
.nav-link .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.nav-link.active .ico { color: var(--accent-ink); }

/* Per-link hexagon node — outline by default, filled when active. Bleeds off the left edge. */
.nav-link .hex {
  position: absolute; left: -7px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 26px; z-index: 1; pointer-events: none;
}
.nav-link .hex polygon { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.45; transition: fill 0.12s, opacity 0.12s; }
.nav-link:hover .hex polygon { opacity: 0.85; }
.nav-link.active .hex polygon { fill: var(--accent); opacity: 1; }

/* Collapse toggle at the bottom of the rail. */
.nav-toggle {
  margin: 0; display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 12px 0.7rem 40px; width: 100%; justify-content: flex-start;
  background: none; border: none; border-top: 1px solid rgba(255,255,255,0.07);
  color: #8c8c86; font-family: var(--font-head); font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
}
.nav-toggle:hover { color: #fff; }
.nav-toggle .chev { color: var(--accent); font-size: 1rem; line-height: 1; }

/* ---- Collapsed state ---- */
body.nav-collapsed bee-navbar { width: 62px; }
body.nav-collapsed .nav-brand { justify-content: center; padding: 14px 0; }
body.nav-collapsed .nav-brand .sub { display: none; }
body.nav-collapsed .nav-section-title { display: none; }
body.nav-collapsed .nav-link .label { display: none; }
body.nav-collapsed .nav-link { padding: 0.5rem 0 0.5rem 26px; }
body.nav-collapsed .nav-link::after { left: 24px; right: 6px; }
body.nav-collapsed .nav-toggle { padding-left: 0; justify-content: center; }
body.nav-collapsed .nav-toggle .lbl { display: none; }

/* ---- Topbar ---- */
bee-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: #121212; color: #fff;
  border-bottom: var(--rule) solid var(--accent);
  position: sticky; top: 0; z-index: 10;
}
bee-topbar .tb-title {
  font-family: var(--font-head); font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase;
}
bee-topbar .tb-user { display: flex; align-items: center; gap: 0.7rem; }
bee-topbar .tb-name { font-size: 0.78rem; color: #c4c5c9; }
bee-topbar .tb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--font-head);
  font-weight: 700; font-size: 0.72rem;
}
bee-topbar .tb-icon {
  width: 30px; height: 30px; border: 2px solid #3a3a37; border-radius: var(--radius);
  color: #c4c5c9; display: grid; place-items: center; font-size: 0.85rem; padding: 0;
}
bee-topbar .tb-icon:hover { border-color: var(--accent); color: #fff; }

/* ---- Content ---- */
main.content { padding: 1.25rem 1.5rem; flex: 1; }

/* ============================ Tables ============================ */
.toolbar { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--panel); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 0.4rem 0.65rem; min-width: 230px;
}
.search:focus-within { border-color: var(--accent); }
.search input { border: none; outline: none; font: inherit; flex: 1; background: transparent; color: var(--ink); }

input, select, textarea {
  font-family: var(--font-body); font-size: 0.86rem; color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 0.5rem 0.6rem; background: var(--bg); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 72px; resize: vertical; }

table.data {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.data th, table.data td { text-align: left; padding: 0.55rem 0.85rem; font-size: 0.82rem; }
table.data thead th {
  background: var(--panel-2); border-bottom: 2px solid var(--line);
  font-size: 0.56rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap;
}
table.data thead th .sort { opacity: 0.7; font-size: 0.6rem; color: var(--accent); }
table.data tbody tr { border-bottom: 2px solid var(--line); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data td { color: var(--ink); }

.row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.icon-btn {
  border: 2px solid var(--line); background: none; color: var(--muted);
  border-radius: var(--radius); padding: 0.25rem 0.5rem; cursor: pointer; font-size: 0.8rem;
  letter-spacing: 0; text-transform: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--ink); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.pagination { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pagination button { padding: 0.4rem 0.7rem; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

.state { padding: 2.25rem; text-align: center; color: var(--muted);
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tag, .chip {
  font-family: var(--font-head); font-size: 0.56rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--panel-2); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 0.15rem 0.5rem; color: var(--muted);
}
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ============================ Modal ============================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: grid; place-items: center; z-index: 100; padding: 1rem;
}
.modal {
  background: var(--panel); border: 2px solid var(--line); border-top: var(--rule) solid var(--accent);
  border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0,0,0,0.5);
  width: min(620px, 100%); max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head { padding: 1rem 1.2rem; border-bottom: 2px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-foot { padding: 0.9rem 1.2rem; border-top: 2px solid var(--line);
  display: flex; justify-content: flex-end; gap: 0.6rem; }
.field { margin-bottom: 0.9rem; }
.field label {
  display: block; font-family: var(--font-head); font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem;
}
.field .req { color: var(--danger); }
.field .hint { font-size: 0.74rem; color: var(--muted); margin-top: 0.25rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 0.35rem; }
.checkbox-grid label { display: flex; align-items: center; gap: 0.4rem; font-weight: 500;
  font-size: 0.8rem; font-family: var(--font-body); text-transform: none; letter-spacing: 0; color: var(--ink); }
.checkbox-grid input { width: auto; }

.provider-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.provider-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 0.5rem; align-items: center; }

/* Permission matrix (roles / user overrides) */
.perm-matrix { display: flex; flex-direction: column; gap: 0.75rem; }
.perm-mod { border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.perm-mod-h {
  background: var(--panel-2); padding: 0.4rem 0.7rem;
  font-family: var(--font-head); font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.perm-row { display: grid; grid-template-columns: 110px 1fr; gap: 0.5rem;
  padding: 0.45rem 0.7rem; border-top: 1px solid var(--line); align-items: start; }
.perm-sub { font-family: var(--font-head); font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 0.15rem; }
.perm-acts { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; }
.perm-act { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--ink); }
.perm-act input { width: auto; }

/* ============================ Toast ============================ */
.toast-wrap { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: #1b1b1b; color: #fff; border: 2px solid var(--line); border-left: var(--rule) solid var(--accent);
  padding: 0.65rem 1rem; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  font-family: var(--font-head); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  animation: toast-in 150ms ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
