/* ============================================================
   Ridgeback Portal - design system
   portal/public/portal.css
   Light-theme only. No dark mode.
   ============================================================ */

/* ── 1. Design tokens ──────────────────────────────────────── */
:root {
  /* Colors */
  --rb-ink: #0c0c0c;
  --rb-page: #f3f3f1;
  --rb-surface: #ffffff;
  --rb-surface-2: #f7f7f5;
  --rb-border: #e3e3e0;
  --rb-border-strong: #cfcfca;
  --rb-text: #161615;
  --rb-text-2: #6c6c68;
  --rb-text-3: #9a9a96;
  --rb-red: #ce1a1e;
  --rb-red-hover: #b3171a;
  --rb-red-soft: #fdecec;
  --rb-red-text: #a32d2d;
  --rb-blue: #2b5c8a;
  --rb-blue-soft: #e7f0f8;

  /* Radius */
  --rb-r: 7px;
  --rb-r-lg: 10px;
  --rb-r-pill: 999px;

  /* Spacing */
  --rb-s1: 4px;
  --rb-s2: 8px;
  --rb-s3: 12px;
  --rb-s4: 16px;
  --rb-s5: 24px;

  /* Focus ring */
  --rb-focus: 0 0 0 3px rgba(43, 92, 138, .35);

  /* Layout */
  --rb-container: 1100px;
}

/* ── 2. Base reset ─────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, sans-serif;
  color: var(--rb-text);
  background: var(--rb-page);
}

main {
  max-width: var(--rb-container);
  margin: 24px auto;
  padding: 0 20px;
}

/* ── 3. Buttons ────────────────────────────────────────────── */
.rb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 8px 14px;
  border-radius: var(--rb-r);
  font-size: 13px;
  font-family: inherit;
  font-weight: 400;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.rb-btn:focus-visible {
  outline: none;
  box-shadow: var(--rb-focus);
}

.rb-btn:active {
  opacity: 0.88;
}

/* Primary */
.rb-btn--primary {
  background: var(--rb-red);
  color: #ffffff;
  border-color: var(--rb-red);
}

.rb-btn--primary:hover {
  background: var(--rb-red-hover);
  border-color: var(--rb-red-hover);
}

/* Secondary */
.rb-btn--secondary {
  background: var(--rb-surface);
  border-color: var(--rb-border-strong);
  color: var(--rb-text);
}

.rb-btn--secondary:hover {
  background: var(--rb-surface-2);
}

/* Ghost */
.rb-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--rb-text-2);
}

.rb-btn--ghost:hover {
  background: var(--rb-surface-2);
  color: var(--rb-text);
}

/* Danger */
.rb-btn--danger {
  background: var(--rb-surface);
  border-color: #f0acac;
  color: var(--rb-red-text);
}

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

/* Small */
.rb-btn--sm {
  height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

/* ── 4. Badges ─────────────────────────────────────────────── */
.rb-badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: var(--rb-r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.rb-badge.is-open {
  background: #e6f4ea;
  color: #1f7a4d;
}

.rb-badge.is-review {
  background: #fbf1d9;
  color: #8a6400;
}

.rb-badge.is-urgent {
  background: var(--rb-red-soft);
  color: var(--rb-red);
}

.rb-badge.is-info {
  background: var(--rb-blue-soft);
  color: var(--rb-blue);
}

.rb-badge.is-closed {
  background: #eeeeec;
  color: #5f5f5b;
}

/* ── 5. Cards ──────────────────────────────────────────────── */
.rb-card {
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r-lg);
  padding: 16px;
}

.rb-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.rb-card__row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
  padding: 4px 0;
  border-top: 1px solid var(--rb-border);
}

.rb-card__row:first-of-type {
  border-top: none;
}

/* ── 6. Metric cards ───────────────────────────────────────── */
.rb-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--rb-s3);
}

.rb-metric {
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r);
  padding: 12px 14px;
}

.rb-metric__label {
  font-size: 12px;
  color: var(--rb-text-2);
  margin-bottom: 4px;
}

.rb-metric__value {
  font-size: 23px;
  font-weight: 500;
  line-height: 1.2;
}

.rb-metric--alert .rb-metric__value {
  color: var(--rb-red);
}

/* ── 7. Forms ──────────────────────────────────────────────── */
.rb-form input,
.rb-form select,
.rb-form textarea {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--rb-border-strong);
  border-radius: var(--rb-r);
  padding: 8px 11px;
  width: 100%;
  background: var(--rb-surface);
  color: var(--rb-text);
  transition: box-shadow 0.12s;
}

.rb-form input,
.rb-form select {
  height: 36px;
}

.rb-form textarea {
  resize: vertical;
  min-height: 80px;
}

.rb-form input:focus-visible,
.rb-form select:focus-visible,
.rb-form textarea:focus-visible {
  outline: none;
  box-shadow: var(--rb-focus);
}

.rb-field {
  margin-bottom: 12px;
}

.rb-label {
  display: block;
  font-size: 12px;
  color: var(--rb-text-2);
  margin-bottom: 4px;
  font-weight: 500;
}

.rb-help {
  font-size: 12px;
  color: var(--rb-text-3);
  margin-top: 3px;
}

.rb-error {
  font-size: 12px;
  color: var(--rb-red-text);
  margin-top: 3px;
}

/* ── 8. Tables ─────────────────────────────────────────────── */
.rb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rb-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--rb-text-2);
  padding: 8px 10px;
  border-bottom: 2px solid var(--rb-border-strong);
  white-space: nowrap;
}

.rb-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--rb-border);
  vertical-align: top;
}

.rb-table tbody tr:hover {
  background: var(--rb-surface-2);
}

@media (max-width: 720px) {
  .rb-table thead {
    display: none;
  }

  .rb-table tr {
    display: block;
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-r-lg);
    margin-bottom: 10px;
    padding: 6px 12px;
  }

  .rb-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: none;
    padding: 6px 0;
  }

  .rb-table td::before {
    content: attr(data-label);
    color: var(--rb-text-2);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 90px;
  }
}

/* ── 9. Page chrome ────────────────────────────────────────── */
.rb-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.rb-page-header h1 {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
}

.rb-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rb-section {
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.rb-section > h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: var(--rb-s3);
}

.rb-empty {
  text-align: center;
  color: var(--rb-text-2);
  padding: 24px;
}

.rb-back {
  color: var(--rb-red);
  text-decoration: none;
  font-size: 13px;
}

.rb-back:hover {
  text-decoration: underline;
}

/* ── 10. Utilities ─────────────────────────────────────────── */
.rb-muted {
  color: var(--rb-text-2);
}

.rb-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.rb-col {
  display: flex;
  flex-direction: column;
}

.rb-gap-2 { gap: var(--rb-s2); }
.rb-gap-3 { gap: var(--rb-s3); }
.rb-gap-4 { gap: var(--rb-s4); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── 11. Header / nav ──────────────────────────────────────── */
.rb-header {
  background: var(--rb-ink);
  color: #ffffff;
  padding: 12px 20px;
  position: relative;
  z-index: 200;
}

.rb-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rb-header__left {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.rb-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.rb-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  text-decoration: none;
  flex-shrink: 0;
}

.rb-header__brand strong {
  font-size: 15px;
}

.rb-nav {
  display: flex;
  align-items: center;
}

.rb-nav a {
  color: #cfcfcf;
  margin-right: 16px;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.rb-nav a:hover {
  color: #ffffff;
}

/* Dropdown container */
.rb-navdd {
  position: relative;
  display: inline-block;
  margin-right: 16px;
}

.rb-navdd button {
  background: transparent;
  border: none;
  color: #cfcfcf;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
  white-space: nowrap;
}

.rb-navdd button:hover {
  color: #ffffff;
}

.rb-navdd__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: #1a1a1a;
  border: 1px solid #333333;
  border-radius: 6px;
  min-width: 160px;
  z-index: 100;
  padding: 6px 0;
}

.rb-navdd__menu a {
  display: block;
  color: #cfcfcf;
  text-decoration: none;
  font-size: 14px;
  padding: 7px 14px;
  white-space: nowrap;
  margin-right: 0;
}

.rb-navdd__menu a:hover {
  color: #ffffff;
  background: #2a2a2a;
}

/* Header search form - sits between left nav group and right who/hamburger group */
.rb-search {
  position: relative;
  width: 250px;
  flex-shrink: 0;
}

.rb-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--rb-r);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.rb-search input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.rb-search input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

/* Global search dropdown */
.gs-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: var(--rb-surface);
  border: 1px solid var(--rb-border-strong);
  border-radius: var(--rb-r-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.13);
  z-index: 9999;
  overflow: hidden;
}

.gs-group-header {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--rb-text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--rb-surface-2);
  border-top: 1px solid var(--rb-border);
}

.gs-group-header:first-child {
  border-top: none;
}

.gs-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--rb-text);
  border-top: 1px solid var(--rb-border);
  transition: background 0.08s;
}

.gs-item:first-child {
  border-top: none;
}

.gs-item:hover,
.gs-item.gs-active {
  background: var(--rb-surface-2);
  color: var(--rb-text);
}

.gs-item-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--rb-text);
}

.gs-item-sub {
  font-size: 12px;
  color: var(--rb-text-2);
}

.gs-item.gs-all {
  font-size: 13px;
  font-weight: 500;
  color: var(--rb-blue);
  background: var(--rb-surface-2);
  border-top: 1px solid var(--rb-border-strong);
  padding: 9px 12px;
}

.gs-item.gs-all:hover {
  background: var(--rb-blue-soft);
  color: var(--rb-blue);
}

.gs-no-results {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--rb-text-3);
  font-style: italic;
}

/* User chip */
.rb-who {
  font-size: 13px;
  color: #b9b9b9;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Hamburger - hidden at desktop */
.rb-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--rb-r);
  min-width: 40px;
  min-height: 40px;
}

.rb-hamburger:focus-visible {
  outline: none;
  box-shadow: var(--rb-focus);
}

/* ── 12. Weather island (.cw-*) ────────────────────────────── */
.cw-loc {
  font-size: 13px;
  color: var(--rb-text-2);
  margin-bottom: var(--rb-s3);
}

.cw-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rb-s3);
}

.cw-card {
  flex: 1 1 110px;
  min-width: 100px;
  max-width: 160px;
  background: var(--rb-surface-2);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cw-day {
  font-size: 12px;
  font-weight: 600;
  color: var(--rb-text);
}

.cw-temp {
  font-size: 16px;
  font-weight: 500;
  color: var(--rb-text);
  line-height: 1.2;
}

.cw-cond {
  font-size: 12px;
  color: var(--rb-text-2);
  line-height: 1.3;
}

.cw-meta {
  font-size: 11px;
  color: var(--rb-text-3);
  margin-top: 2px;
}

@media (max-width: 520px) {
  .cw-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: var(--rb-s2);
  }

  .cw-card {
    flex-shrink: 0;
  }
}

/* ── 13. Cases bulk action bar (.cb-*) ─────────────────────── */
.cb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rb-s2);
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--rb-blue-soft);
  border-color: var(--rb-blue);
}

.cb-presets-row {
  margin-bottom: 18px;
}

.cb-preset-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* ── 14. Mobile nav (max-width: 720px) ─────────────────────── */
@media (max-width: 720px) {
  .rb-header__top {
    flex-wrap: wrap;
  }

  .rb-header__left {
    /* Takes remaining space on the brand row */
    gap: 12px;
    flex: 1;
    min-width: 0;
  }

  .rb-header__right {
    /* who + hamburger stay on the first row */
    gap: 8px;
    flex-shrink: 0;
  }

  /* Search wraps to its own full-width second row (order > 1 so it lands after the first row) */
  .rb-search {
    order: 10;
    width: 100%;
    flex-basis: 100%;
    padding-top: 8px;
  }

  .rb-search input {
    height: 36px;
    font-size: 14px;
  }

  /* On mobile the gs-menu should span more of the viewport */
  .gs-menu {
    width: calc(100vw - 32px);
    left: 0;
  }

  .rb-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    background: var(--rb-ink);
    padding: 8px 20px 16px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 199;
    border-top: 1px solid #222222;
  }

  .rb-nav.is-open {
    display: flex;
  }

  .rb-nav a {
    display: block;
    width: 100%;
    padding: 10px 0;
    margin-right: 0;
    font-size: 15px;
    border-bottom: 1px solid #222222;
  }

  .rb-nav a:last-child {
    border-bottom: none;
  }

  .rb-hamburger {
    display: inline-flex;
  }

  /* Dropdowns become static lists inside the mobile panel */
  .rb-navdd {
    position: static;
    display: block;
    width: 100%;
    margin-right: 0;
  }

  .rb-navdd button {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #222222;
    min-height: 40px;
  }

  .rb-navdd__menu {
    position: static;
    background: transparent;
    border: none;
    border-radius: 0;
    min-width: 0;
    padding: 0 0 0 12px;
    z-index: auto;
  }

  .rb-navdd__menu a {
    font-size: 14px;
    padding: 8px 0;
    border-bottom: 1px solid #1e1e1e;
    background: transparent;
  }

  .rb-navdd__menu a:hover {
    background: transparent;
    color: #ffffff;
  }
}

/* ── 11. Notifications ─────────────────────────────────────── */
.nt-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nt-bell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--rb-r);
  color: #cfcfcf;
  cursor: pointer;
}

.nt-bell:hover {
  color: #ffffff;
}

.nt-bell:focus-visible {
  outline: none;
  box-shadow: var(--rb-focus);
}

.nt-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--rb-r-pill);
  background: var(--rb-red);
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

.nt-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 200;
}

.nt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rb-border);
}

.nt-head-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--rb-text);
}

.nt-readall {
  background: transparent;
  border: none;
  color: var(--rb-blue);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 0;
}

.nt-readall:hover {
  text-decoration: underline;
}

.nt-list {
  display: block;
}

.nt-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rb-border);
  text-decoration: none;
  color: var(--rb-text);
}

.nt-item:hover {
  background: var(--rb-surface-2);
}

.nt-item-title {
  display: block;
  font-size: 13px;
  color: var(--rb-text);
}

.nt-item-title.is-unread {
  font-weight: 600;
}

.nt-item-body {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--rb-text-2);
}

.nt-item-time {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--rb-text-3);
}

.nt-empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--rb-text-2);
}

.nt-foot {
  display: block;
  padding: 9px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--rb-blue);
  text-decoration: none;
}

.nt-foot:hover {
  text-decoration: underline;
}

/* Full notifications page */
.nt-page-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nt-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-r-lg);
  text-decoration: none;
  color: var(--rb-text);
}

.nt-row:hover {
  background: var(--rb-surface-2);
}

.nt-row.is-unread {
  border-left: 3px solid var(--rb-red);
}

.nt-row-main {
  min-width: 0;
}

.nt-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nt-row-title {
  font-size: 14px;
  color: var(--rb-text);
}

.nt-row.is-unread .nt-row-title {
  font-weight: 600;
}

.nt-row-body {
  margin-top: 3px;
  font-size: 13px;
  color: var(--rb-text-2);
}

.nt-row-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--rb-text-3);
  white-space: nowrap;
}

.nt-prefs {
  margin-bottom: var(--rb-s4);
}

.nt-prefs-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--rb-text);
}

.nt-prefs-help {
  margin: var(--rb-s1) 0 var(--rb-s3);
  font-size: 13px;
  color: var(--rb-text-2);
}

.nt-pref-row {
  display: flex;
  align-items: center;
  gap: var(--rb-s2);
  padding: var(--rb-s1) 0;
  font-size: 14px;
  color: var(--rb-text);
  cursor: pointer;
}

.nt-pref-row .nt-pref {
  cursor: pointer;
}

.nt-pref-row .nt-pref:disabled {
  cursor: default;
}
