/* BTSystem — design language inspired by btbraintrust.com.
 * Primary green: #64995c (Braintrust sage)
 * Typography: Old Standard TT (serif) for h1/h2; Roboto for everything else.
 */

:root {
  --green-700: #4a7544;
  --green-600: #64995c;
  --green-500: #7ab074;
  --green-100: #dde9da;
  --green-050: #f0f5ee;

  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e5dfd4;
  --border-strong: #cdc6b8;

  --text: #2c2f2a;
  --text-muted: #6b6f66;

  --danger: #b85a3e;
  --danger-bg: #f3dcd2;
  --warn: #c08a3e;
  --warn-bg: #f6e8d0;
  --info: #5b7f9e;
  --info-bg: #dee7ee;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(60, 50, 30, 0.06), 0 4px 12px rgba(60, 50, 30, 0.04);
  --shadow-lg: 0 4px 16px rgba(60, 50, 30, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* === Headings (serif, like the site) === */

h1, h2, h3 {
  font-family: "Old Standard TT", Georgia, serif;
  font-weight: 700;
  color: var(--green-700);
  margin: 0 0 0.5em;
  line-height: 1.25;
}

h1 {
  font-size: 1.9rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.4rem;
  margin-top: 2rem;
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
}

p, dt, dd, li {
  font-family: "Roboto", system-ui, sans-serif;
}

a {
  color: var(--green-700);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--green-600);
  text-decoration: underline;
}

/* === Sidebar === */

.sidebar {
  background: var(--green-050);
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-family: "Old Standard TT", serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--green-700);
  display: block;
  padding: 0.25rem 0.5rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  border-bottom: 2px solid var(--green-600);
  padding-bottom: 0.75rem;
}

.sidebar .brand:hover {
  text-decoration: none;
  color: var(--green-600);
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin: 0.15rem 0;
}

.sidebar a {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar a:hover {
  background: var(--green-100);
  color: var(--green-700);
}

.sidebar .section-label {
  margin-top: 1.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 0 0.75rem;
}

.sidebar form.logout {
  margin-top: auto;
  padding-top: 1.5rem;
}

.sidebar form.logout button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-family: "Roboto", sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar form.logout button:hover {
  background: var(--green-100);
  color: var(--green-700);
  border-color: var(--green-500);
}

/* === Main area === */

main {
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

section {
  margin-bottom: 2rem;
}

/* === Forms === */

form {
  display: grid;
  gap: 1rem;
  max-width: 520px;
  margin-top: 1rem;
}

form.search-form,
form[style*="display:flex"] {
  max-width: none;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
select,
textarea {
  font-family: "Roboto", sans-serif;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(100, 153, 92, 0.15);
}

input[readonly] {
  background: var(--green-050);
  color: var(--text-muted);
}

textarea {
  font-family: "Roboto", sans-serif;
  resize: vertical;
  min-height: 80px;
}

/* === Buttons === */

button,
button[type="submit"],
input[type="submit"] {
  font-family: "Roboto", sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  background: var(--green-600);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover {
  background: var(--green-700);
}

button:active {
  transform: translateY(1px);
}

button[type="submit"] + a,
button + a {
  display: inline-block;
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

button[type="submit"] + a:hover,
button + a:hover {
  color: var(--green-700);
}

/* Secondary buttons (e.g., destructive within a form) */
form[action*="deactivate"] button,
form[action*="cancel"] button,
form[action*="absent"] button {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--border-strong);
}

form[action*="deactivate"] button:hover,
form[action*="cancel"] button:hover,
form[action*="absent"] button:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

form[action*="realize"] button {
  background: var(--surface);
  color: var(--green-700);
  border: 1px solid var(--green-500);
}

form[action*="realize"] button:hover {
  background: var(--green-100);
}

/* === Tables === */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

thead th {
  background: var(--green-050);
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green-700);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--green-050);
}

/* === Status messages === */

.error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--danger);
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

.success {
  background: var(--green-100);
  color: var(--green-700);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--green-600);
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

/* === Lists / definition lists === */

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0.75rem 0 1.5rem;
}

dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

dd {
  margin: 0;
  font-size: 0.95rem;
}

/* === Details / collapsible sections === */

details {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s;
}

details[open] {
  box-shadow: var(--shadow);
}

details > summary {
  cursor: pointer;
  padding: 0.5rem 0;
  font-weight: 500;
  color: var(--green-700);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "▸";
  color: var(--green-600);
  transition: transform 0.15s;
  display: inline-block;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

/* === Agenda grid (override harsher cell borders) === */

#agenda-grid table {
  border-radius: var(--radius);
  overflow: hidden;
}

#agenda-grid thead th {
  background: var(--green-100);
  color: var(--green-700);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  text-align: center;
  padding: 0.6rem 0.4rem;
}

#agenda-grid tbody td {
  border: 1px solid var(--border) !important;
  padding: 0 !important;
  vertical-align: top;
  background: var(--surface);
}

#agenda-grid tbody tr:hover {
  background: transparent;
}

#agenda-grid tbody td a {
  display: block;
  padding: 0.4rem 0.5rem;
  margin: 2px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  line-height: 1.25;
  transition: opacity 0.15s, transform 0.05s;
}

#agenda-grid tbody td a:hover {
  opacity: 0.85;
  transform: translateY(-1px);
  text-decoration: none;
}

/* Status colors for the agenda — harmonized with sage palette */
#agenda-grid a[style*="background:#bbdefb"] {
  background: var(--info-bg) !important;
  color: var(--info) !important;
}

#agenda-grid a[style*="background:#c8e6c9"] {
  background: var(--green-100) !important;
  color: var(--green-700) !important;
}

#agenda-grid a[style*="background:#ffcdd2"] {
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
}

#agenda-grid a[style*="background:#ffe0b2"] {
  background: var(--warn-bg) !important;
  color: var(--warn) !important;
}

#agenda-grid a[style*="background:#eeeeee"] {
  background: #f0ede6 !important;
  color: var(--text-muted) !important;
}

#agenda-grid tbody td:hover {
  background: var(--green-050);
}

/* Empty slot links: invisible "+" but clickable */
#agenda-grid tbody td > a:not([href*="session_id"]) {
  color: transparent !important;
  background: transparent !important;
  font-size: 1.2rem;
}

#agenda-grid tbody td > a:not([href*="session_id"]):hover {
  color: var(--green-600) !important;
  background: var(--green-050) !important;
}

/* === Login page (simpler, centered look) === */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-050) 0%, var(--bg) 100%);
}

body.login-page main {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  margin: 1rem;
}

body.login-page h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

body.login-page form {
  max-width: none;
}

body.login-page button[type="submit"] {
  margin-top: 0.5rem;
  padding: 0.75rem;
  font-size: 1rem;
}

/* === Mobile === */

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
    align-items: center;
    gap: 0.5rem;
  }
  .sidebar .brand {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    margin-right: 1rem;
  }
  .sidebar ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex: 1;
  }
  .sidebar .section-label {
    display: none;
  }
  .sidebar form.logout {
    margin-top: 0;
    padding-top: 0;
    margin-left: auto;
  }
  .sidebar form.logout button {
    padding: 0.4rem 0.75rem;
  }
  main {
    padding: 1.25rem 1rem;
  }
  table {
    font-size: 0.85rem;
  }
  thead th, tbody td {
    padding: 0.5rem 0.75rem;
  }
}

/* === Utility === */

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

code {
  font-family: "SF Mono", "Monaco", "Menlo", monospace;
  font-size: 0.85em;
  background: var(--green-050);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  color: var(--green-700);
}
