/* ==========================================================================
   Sendero Trip Tracker — design system
   Palette taken from senderohumanitarian.org (slate #29343D, blue-grey
   #6A7F8F, light blue #ADC7D5, cream #F5EFE2). Light mode is default;
   [data-theme="dark"] on <html> swaps to a deeper slate variant. Red is kept
   for danger/rejected only, since that signal carries meaning.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@600&family=Josefin+Sans:wght@600;700&family=Roboto:wght@400;500;700&display=swap");

:root {
  --bg: #f7f3ea;
  --surface-1: #ffffff;   /* top bar */
  --surface-2: #ffffff;   /* cards */
  --surface-3: #f1ebdd;   /* hover / active surfaces */
  --border: #e4dccb;
  --text: #29343d;
  --text-secondary: #5b6f7e;
  --text-faint: #9ea9b1;

  --accent: #29343d;        /* primary — Sendero slate */
  --accent-strong: #1b242b;
  --accent-soft: rgba(106, 127, 143, 0.14);
  --accent-2: #6a7f8f;       /* secondary — blue-grey */
  --accent-2-soft: rgba(106, 127, 143, 0.16);
  --on-accent: #f5efe2;      /* cream text on top of --accent fills */

  --sidebar-bg: #29343d;
  --sidebar-text: #adc7d5;
  --sidebar-active-bg: rgba(245, 239, 226, 0.12);
  --sidebar-active-text: #f5efe2;

  --danger: #dc4437;
  --danger-soft: rgba(220, 68, 55, 0.10);

  --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-label: "Josefin Sans", "Roboto", sans-serif;
  --font-hand: "Caveat", cursive;

  --radius-card: 11px;
  --radius-pill: 999px;
  --radius-btn: 8px;

  --sidebar-width: 220px;
  --topbar-height: 54px;

  --shadow-modal: 0 20px 60px rgba(41, 52, 61, 0.2);
}

html[data-theme="dark"] {
  --bg: #1b242b;
  --surface-1: #222d35;
  --surface-2: #26323b;
  --surface-3: #2f3c46;
  --border: #3a4854;
  --text: #f5efe2;
  --text-secondary: #adc7d5;
  --text-faint: #7f8f9b;

  --accent: #f5efe2;
  --accent-strong: #ffffff;
  --accent-soft: rgba(173, 199, 213, 0.14);
  --accent-2: #adc7d5;
  --accent-2-soft: rgba(173, 199, 213, 0.16);
  --on-accent: #29343d;

  --sidebar-bg: #151d23;

  --danger: #f0554a;
  --danger-soft: rgba(240, 85, 74, 0.14);

  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font-family: inherit; }

/* ---------------------------------------------------------------------- */
/* App shell                                                              */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px;
}

.brand-logo {
  display: block;
  height: 34px;
  width: auto;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-btn);
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
}

.nav-item:hover { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-spacer { flex: 1; }

.sidebar-bottom {
  border-top: 1px solid rgba(173, 199, 213, 0.2);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------------------------------------------------------------------- */
/* Top bar                                                                 */
/* ---------------------------------------------------------------------- */

.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  flex: 0 0 var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
}

.topbar-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-btn);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------------- */
/* Content area / views                                                    */
/* ---------------------------------------------------------------------- */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 60px;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.view-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.view-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                  */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------------- */
/* Cards + KPI tiles                                                       */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  transition: border-color 0.12s ease;
}

.card:hover { border-color: var(--accent); }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  cursor: default;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.kpi-tile.clickable { cursor: pointer; }
.kpi-tile.clickable:hover { border-color: var(--accent); background: var(--surface-3); }

.kpi-num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-num.warn { color: var(--accent-2); }
.kpi-num.good { color: var(--accent); }
.kpi-label { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* ---------------------------------------------------------------------- */
/* Pill filter chips                                                       */
/* ---------------------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { border-color: var(--accent); color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* Progress bars                                                           */
/* ---------------------------------------------------------------------- */

.progress-track {
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* ---------------------------------------------------------------------- */
/* Tables                                                                   */
/* ---------------------------------------------------------------------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  font-family: var(--font-label);
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-clickable { cursor: pointer; }
.data-table tr.row-clickable:hover { background: var(--surface-3); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.badge.status-applied { background: var(--surface-3); color: var(--text-secondary); }
.badge.status-accepted { background: var(--accent-soft); color: var(--accent); }
.badge.status-rejected { background: var(--danger-soft); color: var(--danger); }
.badge.status-withdrawn { background: var(--surface-3); color: var(--text-faint); }

/* ---------------------------------------------------------------------- */
/* Modals                                                                   */
/* ---------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-backdrop.active { display: flex; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; max-height: 68vh; overflow-y: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                    */
/* ---------------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea { min-height: 64px; resize: vertical; }

.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.hint { color: var(--text-faint); font-size: 11.5px; margin-top: 4px; }

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-modal);
  z-index: 200;
  display: none;
}

.toast.error { border-left-color: var(--danger); }
.toast.show { display: block; }

/* ---------------------------------------------------------------------- */
/* Public pages (application form, applicant portal)                       */
/* ---------------------------------------------------------------------- */

.site-bar {
  background: var(--sidebar-bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
}

.site-bar img { height: 36px; width: auto; display: block; }

.public-wrap h1 {
  font-family: var(--font-hand);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
}
