/* ============================================================
   Managertools — design system
   Tokens first, then base, then components. The /styleguide route renders every
   component below against these tokens, so it is the place to check a change.
   ============================================================ */

:root {
  /* Neutrals — cool slate rather than pure grey */
  --ink-900: #0E1320;
  --ink-700: #28324A;
  --ink-500: #5A6678;
  --ink-300: #93A0B4;
  --line: #E5E9F0;
  --paper: #F7F8FA;
  --surface: #FFFFFF;

  /* Accents — reserved for actions and status, never for decoration */
  --accent: #2F5FD0;
  --accent-ink: #23479C;
  --positive: #1B7F4A;
  --negative: #C0392B;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 8px;
  --e1: 0 1px 2px rgba(14, 19, 32, 0.08);
  --e2: 0 4px 12px rgba(14, 19, 32, 0.10);

  /* The one breakpoint. Also hard-coded in the @media rules below, because CSS custom
     properties cannot be used in a media query. Keep the two in step, and keep both in step with
     ApplicationSystemTestCase::BREAKPOINT. */
  --breakpoint: 768px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ---------- Navbar ----------
   The markup this styles is depended on by the system suite: below the breakpoint .navbar-menu is
   hidden until the navbar Stimulus controller opens it, which is what click_nav_link drives. */
.navbar {
  background: var(--surface);
  box-shadow: var(--e1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 2rem;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink-900);
  text-decoration: none;
}

.navbar-menu { display: contents; }
.navbar-links { display: flex; gap: 0.25rem; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.navbar-user { color: var(--ink-500); font-size: 0.85rem; }

.navbar-link {
  color: var(--ink-700);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.navbar-link:hover { background: var(--paper); }
.navbar-link.active { color: var(--accent); font-weight: 600; }

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
}

.navbar-toggle-icon,
.navbar-toggle-icon::before,
.navbar-toggle-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink-900);
}

.navbar-toggle-icon { position: relative; }

.navbar-toggle-icon::before,
.navbar-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.navbar-toggle-icon::before { top: -6px; }
.navbar-toggle-icon::after { top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--ink-700); border-color: var(--line); }
.btn-secondary:hover { background: var(--paper); }
.btn-danger { background: var(--negative); color: #fff; }

/* ---------- Page header and cards ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 { margin: 0; font-size: 1.5rem; }
.page-header-actions { margin-left: auto; display: flex; gap: 0.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--e1);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title { margin: 0 0 0.75rem; font-size: 1.05rem; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }

.form-input {
  width: 100%;
  max-width: 26rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}

.form-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-hint { display: block; color: var(--ink-500); font-size: 0.8rem; margin-top: 0.25rem; }
.form-error { display: block; color: var(--negative); font-size: 0.8rem; margin-top: 0.25rem; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }

.form-errors {
  border: 1px solid var(--negative);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.form-errors h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--negative); }

/* ---------- Data table ---------- */
.data-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table-header,
.data-table-row {
  display: grid;
  grid-template-columns: repeat(var(--data-table-columns, 3), 1fr);
  gap: 1rem;
  padding: 0.75rem 1rem;
}

.data-table-header {
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table-row + .data-table-row { border-top: 1px solid var(--line); }

/* ---------- Meeting page ---------- */
.muted { color: var(--ink-500); }

.prose p { margin: 0 0 0.75rem; line-height: 1.55; }
.prose p:last-child { margin-bottom: 0; }

.meeting-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0 0 1rem;
}

.action-item-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0 0 1rem;
  align-items: flex-start;
}

.meeting-fact dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-500);
}

.meeting-fact dd { margin: 0.15rem 0 0; font-weight: 600; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.filters .form-group { margin-bottom: 0; }
.filters .form-input { max-width: 14rem; }

/* ---------- Transcript ---------- */
.transcript {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.transcript-summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--ink-700); }

.transcript-turns { margin-top: 1rem; }
.transcript-turn + .transcript-turn { margin-top: 0.75rem; }
.transcript-speaker { display: block; font-size: 0.75rem; font-weight: 600; color: var(--ink-500); }
.transcript-line { margin: 0.15rem 0 0; line-height: 1.5; }

.transcript-text {
  margin: 1rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ---------- Comments ---------- */
.comment + .comment { border-top: 1px solid var(--line); }
.comment { padding: 0.75rem 0; }

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-500);
}

.comment-author { font-weight: 600; color: var(--ink-700); }
.comment-actions { margin-left: auto; display: flex; gap: 0.75rem; }
.comment-action { font-size: 0.8rem; }
.comment-body { margin-top: 0.35rem; line-height: 1.5; white-space: pre-wrap; }
.comment-form { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge--todo { background: var(--paper); color: var(--ink-700); border-color: var(--line); }
.status-badge--in-progress { background: #E9EFFB; color: var(--accent-ink); }
.status-badge--done { background: #E8F2EC; color: var(--positive); }

.status-badge--dropped {
  background: var(--surface);
  color: var(--ink-500);
  border-color: var(--line);
  text-decoration: line-through;
}

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.25rem;
  border-left: 2px solid var(--line);
}

.timeline-entry { position: relative; padding: 0 0 1.25rem 0.5rem; }
.timeline-entry:last-child { padding-bottom: 0; }

.timeline-entry::before {
  content: "";
  position: absolute;
  left: -1.85rem;
  top: 0.4rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.timeline-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.timeline-entry-heading { font-size: 0.85rem; font-weight: 600; }
.timeline-entry-meta { font-size: 0.75rem; color: var(--ink-500); }

.timeline-entry-body { margin-top: 0.35rem; line-height: 1.5; }
.timeline-entry-body p { margin: 0.35rem 0 0; white-space: pre-wrap; }

/* ---------- Action items on a meeting ---------- */
.discussed-item + .discussed-item { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }

.discussed-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.discussed-item-title { font-weight: 600; }
.discussed-item-owner { margin-left: auto; font-size: 0.8rem; color: var(--ink-500); }

.raise-form { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.update-form { margin-top: 0.75rem; }
.update-form .form-group { margin-bottom: 0.5rem; }

/* ---------- Dashboard ---------- */
.dashboard-panel { margin-bottom: 1.5rem; }
.dashboard-panel .sg-section-title { margin-top: 0; }

/* ---------- Flash ---------- */
#flash-messages {
  max-width: 1100px;
  margin: 1rem auto 0;
  padding: 0 1rem;
}

.flash {
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.flash-notice { background: #E8F2EC; color: var(--positive); }
.flash-alert { background: #FBEAE8; color: var(--negative); }

/* ---------- Styleguide ---------- */
.sg-section-title { font-size: 1.1rem; margin: 2rem 0 0.75rem; }
.sg-subtitle { font-size: 0.85rem; color: var(--ink-500); margin: 1rem 0 0.5rem; }
.sg-section-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.sg-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.sg-swatches { display: flex; flex-wrap: wrap; gap: 1rem; }
.sg-swatch { width: 8rem; }
.sg-swatch-chip { height: 3rem; border-radius: 6px; border: 1px solid var(--line); }
.sg-swatch-name { display: block; font-size: 0.85rem; margin-top: 0.35rem; }
.sg-swatch-token { display: block; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-500); }
.sg-type-row { display: flex; gap: 1.5rem; align-items: baseline; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.sg-type-label { flex: 0 0 12rem; font-size: 0.75rem; color: var(--ink-500); font-family: var(--font-mono); }
.sg-ts-2xl { font-size: 2rem; font-weight: 700; }
.sg-ts-xl { font-size: 1.4rem; font-weight: 700; }
.sg-ts-base { font-size: 1rem; }
.sg-ts-sm { font-size: 0.85rem; }
.sg-ts-mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* ---------- Below the breakpoint ----------
   768px, matching ApplicationSystemTestCase::BREAKPOINT and the --breakpoint token above. */
@media (max-width: 768px) {
  .navbar-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    gap: 0;
  }

  .navbar-toggle { display: block; }

  .navbar-menu {
    display: none;
    width: 100%;
    padding-bottom: 0.75rem;
  }

  .navbar-menu--open { display: block; }

  .navbar-links { flex-direction: column; }
  .navbar-right { margin-left: 0; flex-wrap: wrap; }

  /* Rows restack into cards, each cell labelled by the column it came from — which is why
     Ui::DataTable copies the column name into data-label. */
  .data-table-header { display: none; }

  .data-table-row { grid-template-columns: 1fr; gap: 0.25rem; }

  .data-table-cell::before {
    content: attr(data-label) " ";
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-500);
  }

  .sg-type-row { flex-direction: column; gap: 0.25rem; }

  .filters { flex-direction: column; align-items: stretch; }
  .filters .form-input { max-width: 100%; }
  .meeting-facts { gap: 0.75rem; }
  .action-item-facts { gap: 0.75rem; }
  .comment-actions { margin-left: 0; width: 100%; }
  .discussed-item-owner { margin-left: 0; width: 100%; }
}
