/* Court NOTUS — base styles. X.com-inspired layout. */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg:       #ffffff;
  --surface:  #ffffff;
  --border:   #eff3f4;
  --text:     #0f1419;
  --muted:    #536471;
  --accent:   #1d9bf0;
  --hover-bg: rgba(15, 20, 25, 0.07);
  --radius:   8px;

  --sp1:  4px;
  --sp2:  8px;
  --sp3:  12px;
  --sp4:  16px;
  --sp5:  20px;
  --sp6:  24px;
  --sp8:  32px;
  --sp12: 48px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

/* ── 3-column layout ─────────────────────────────────────────────────────── */
.layout {
  display: flex;
  max-width: 1265px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Guest (unauthenticated): no sidebar, content centered */
.layout--guest {
  justify-content: center;
  align-items: flex-start;
}
.layout--guest .layout-body {
  width: 100%;
  max-width: 480px;
  padding: var(--sp8) var(--sp4);
}
.layout--guest .layout-center {
  border: none;
}
.layout--guest .layout-right { display: none; }

/* Sidebar */
.sidebar {
  width: 275px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0 var(--sp3);
  display: flex;
  flex-direction: column;
}

/* Center + right wrapper */
.layout-body {
  display: flex;
  flex: 1;
  min-width: 0;
}

.layout-center {
  flex: 1;
  min-width: 0;
  max-width: 600px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.layout-right {
  width: 350px;
  flex-shrink: 0;
  padding: var(--sp4) var(--sp5);
}

/* ── Sidebar brand + nav ─────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp4);
  padding: var(--sp3);
  margin: var(--sp2) 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  border-radius: 9999px;
  transition: background 0.15s;
}
.brand:hover { background: var(--hover-bg); color: var(--text); }
.brand-icon { font-size: 26px; line-height: 1; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 9999px;
  background: #FBBF24;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.sidenav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidenav-item {
  display: flex;
  align-items: center;
  gap: var(--sp5);
  padding: var(--sp3);
  border-radius: 9999px;
  font-size: 19px;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.sidenav-item:hover { background: var(--hover-bg); color: var(--text); }
.sidenav-item.is-active { font-weight: 700; }

.sidenav-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.sidebar-user {
  margin-top: auto;
  padding: var(--sp4) var(--sp3);
  display: flex;
  flex-direction: column;
  gap: var(--sp2);
}
.user-email {
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}
.linkbtn.slack-status,
.sidebar-user .linkbtn {
  font-size: 13px;
}
.slack-status--connected { color: var(--success, #2d9a4e); }
.slack-status--connected:hover { color: var(--text); }
.slack-status--disconnected { color: var(--muted); }
.slack-status--disconnected:hover { color: var(--text); }

/* ── New filings bar ─────────────────────────────────────────────────────── */
.new-filings-bar {
  display: block;
  width: 100%;
  padding: var(--sp3) var(--sp4);
  text-align: center;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  transition: background 0.15s;
}
.new-filings-bar:hover { background: var(--hover-bg); }

/* ── Feed tabs ───────────────────────────────────────────────────────────── */
.feed-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.feed-tab {
  flex: 1;
  text-align: center;
  padding: var(--sp4);
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  position: relative;
  transition: background 0.15s;
}
.feed-tab:hover { background: var(--hover-bg); color: var(--text); }
.feed-tab.is-active { color: var(--text); font-weight: 700; }
.feed-tab.is-active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 4px;
  background: var(--accent);
  border-radius: 9999px;
}

/* ── Feed items ──────────────────────────────────────────────────────────── */
.feed-item {
  padding: var(--sp3) var(--sp4);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.feed-item:hover { background: var(--hover-bg); }

.feed-item-time {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--sp2);
}

.feed-item-case {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.feed-item-case:hover { text-decoration: underline; color: var(--text); }

.feed-item-row2 {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--sp2);
  align-items: center;
}
.feed-item-row2 span + span::before,
.feed-item-row2 a::before { content: '· '; }

.feed-item-cl {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}
.feed-item-cl:hover { text-decoration: underline; }

.feed-item-body {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

.feed-entry-num {
  color: var(--muted);
  font-size: 13px;
}

.feed-show-more {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
}
.feed-show-more:hover { text-decoration: underline; }

/* ── Right panel ─────────────────────────────────────────────────────────── */
.right-search {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: var(--sp3) var(--sp5);
  margin-bottom: var(--sp5);
  transition: border-color 0.15s;
}
.right-search:focus-within {
  border-color: var(--accent);
}
.right-search input[type="text"] {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding: 0;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  color: var(--text);
}
.right-search input::placeholder { color: var(--muted); }

.right-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--sp4);
  margin-bottom: var(--sp4);
}
.right-box-title {
  font-size: 19px;
  font-weight: 800;
  margin: 0 0 var(--sp4);
}

/* Recent cases list (right panel) */
.recent-case-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp3) 0;
  border-bottom: 1px solid var(--border);
}
.recent-case-item:last-child { border-bottom: none; }
.recent-case-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
}
.recent-case-name:hover { text-decoration: underline; color: var(--text); }
.recent-case-meta {
  font-size: 13px;
  color: var(--muted);
}

.or-divider {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  color: var(--muted);
  font-size: 13px;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px var(--sp5);
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  width: 100%;
}
.btn:hover { opacity: 0.88; }

.btn--sm {
  padding: var(--sp2) var(--sp4);
  font-size: 14px;
  width: auto;
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--accent { background: var(--accent); }

.linkbtn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.linkbtn:hover { color: var(--text); }

.inline-form { display: inline; margin: 0; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp2);
}

fieldset.field { border: none; padding: 0; margin: 0; }

.field-label { font-size: 14px; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="date"],
textarea,
select {
  padding: var(--sp3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }

.radio-row {
  display: flex;
  gap: var(--sp5);
  font-size: 15px;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flashes {
  padding: var(--sp4);
  display: flex;
  flex-direction: column;
  gap: var(--sp2);
}
.flash {
  padding: var(--sp3) var(--sp4);
  border-radius: var(--radius);
  font-size: 14px;
}
.flash--error   { background: #fdecec; color: #9b1c1c; }
.flash--message,
.flash--success { background: #eaf2ec; color: #1c6b34; }

/* ── Cards (legacy pages) ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp6);
}
.card + .card { margin-top: var(--sp4); }
.card h1 { margin: 0 0 var(--sp4); font-size: 24px; }
.card--narrow { max-width: 420px; }

/* ── Box header ──────────────────────────────────────────────────────────── */
.box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp4);
  flex-wrap: wrap;
  margin-bottom: var(--sp4);
}
.box-head h1, .box-head h2 { margin: 0; }

h2 { font-size: 18px; margin: 0; }

/* ── All/Mine toggle ─────────────────────────────────────────────────────── */
.toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.toggle-opt {
  padding: var(--sp1) var(--sp3);
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface);
}
.toggle-opt + .toggle-opt { border-left: 1px solid var(--border); }
.toggle-opt.is-active { background: var(--text); color: #fff; }

/* ── Pager ───────────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp4);
  padding: var(--sp4);
}
.pager-link { font-size: 14px; text-decoration: none; }
.pager-link.is-disabled { color: var(--muted); opacity: 0.5; pointer-events: none; }
.pager-status { font-size: 13px; color: var(--muted); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0 var(--sp2);
  border-radius: 9999px;
  font-size: 12px;
  line-height: 20px;
  font-weight: 600;
}
.badge--important {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 9999px;
  background: #FBBF24;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 0;
  line-height: 1;
}
.badge--active    { background: #eaf2ec; color: #1c6b34; }
.badge--paused    { background: #f1f1f4; color: var(--muted); }

/* ── Count pill ──────────────────────────────────────────────────────────── */
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 var(--sp2);
  margin-left: var(--sp2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state, .empty {
  padding: var(--sp8);
  text-align: center;
  color: var(--muted);
}

/* ── Entries list (case detail) ──────────────────────────────────────────── */
.plain-list, .entries {
  list-style: none;
  padding: 0;
  margin: var(--sp4) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp3);
}
.entries li {
  padding: var(--sp3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.entry-head {
  display: flex;
  gap: var(--sp3);
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--sp1);
}
.entry-desc { font-size: 15px; }
.entry-link { font-size: 13px; }
.entry-num  { font-size: 13px; color: var(--muted); }

/* ── Meta grid (case detail) ─────────────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp3) var(--sp4);
  margin: var(--sp4) 0 0;
}
.meta-grid dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.meta-grid dd {
  margin: 0;
  font-size: 15px;
}

/* ── Attorneys list ──────────────────────────────────────────────────────── */
.attorneys {
  margin: var(--sp1) 0 0 var(--sp4);
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--muted);
}

/* ── Confirmation matches ────────────────────────────────────────────────── */
.matches {
  display: flex;
  flex-direction: column;
  gap: var(--sp2);
}
.match {
  display: flex;
  gap: var(--sp3);
  align-items: flex-start;
  padding: var(--sp3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.match-body { display: flex; flex-direction: column; gap: var(--sp1); }
.match-name { font-weight: 600; }
.match-meta { font-size: 13px; color: var(--muted); }
.match-link { font-size: 13px; }

/* ── Cases browse ────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: var(--sp3);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: var(--sp4);
}
.filters--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp3);
}
.filters--stacked .filters-search {
  width: 100%;
  flex: 0 0 auto;
}
.filters-row2 {
  display: flex;
  gap: var(--sp3);
  align-items: flex-end;
  flex-wrap: wrap;
}
.filters-search  { flex: 1 1 240px; }
.filters-actions { display: flex; gap: var(--sp3); align-items: center; }
.filters input[type="text"],
.filters input[type="date"] { border-radius: 4px; }

.case-row  { padding: var(--sp2) 0; }
.case-name { font-weight: 600; text-decoration: none; color: var(--text); }
.case-name:hover { text-decoration: underline; }
.case-meta { font-size: 13px; color: var(--muted); margin-top: var(--sp1); }

/* ── Case detail actions ─────────────────────────────────────────────────── */
.detail-actions { margin-top: var(--sp4); }
.syncing { margin-bottom: var(--sp4); }

/* ── Notifications ───────────────────────────────────────────────────────── */
.notif-head {
  display: flex;
  align-items: center;
  gap: var(--sp3);
}
.notif-controls {
  display: flex;
  align-items: center;
  gap: var(--sp4);
  flex-wrap: wrap;
  margin-top: var(--sp3);
}
.inline-controls {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  margin: 0;
}
.inline-controls select { width: auto; }

/* ── Event rows ──────────────────────────────────────────────────────────── */
.event-row { display: flex; gap: var(--sp3); align-items: baseline; }
.event-date {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
  min-width: 88px;
}
.event-body { font-size: 15px; }

/* ── Calendar ────────────────────────────────────────────────────────────── */
.cal-nav { display: flex; gap: var(--sp4); margin-bottom: var(--sp4); }
.cal-weekhead, .cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-weekday {
  padding: var(--sp1);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.cal-cell {
  min-height: 72px;
  border: 1px solid var(--border);
  margin: -0.5px;
  padding: var(--sp1);
  display: flex;
  flex-direction: column;
  gap: var(--sp1);
}
.cal-cell.is-outside { background: var(--bg); }
.cal-cell.is-outside .cal-daynum { color: var(--muted); }
.cal-cell.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-daynum { font-size: 12px; color: var(--text); }
.cal-event {
  display: block;
  background: #fef3c7;
  color: #92600a;
  border-radius: var(--sp1);
  padding: 0 var(--sp1);
  font-size: 11px;
  line-height: 16px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-list { display: none; margin-top: var(--sp4); }

/* ── Narrow centering frame (legacy fallback) ────────────────────────────── */
.frame {
  max-width: 700px;
  margin: 0 auto;
  padding: var(--sp6) var(--sp4);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .layout-right { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    width: 72px;
  }
  .brand-text,
  .sidenav-item span,
  .sidebar-user .user-email { display: none; }
  .sidenav-item { justify-content: center; padding: var(--sp3); }
  .brand { justify-content: center; }
  .sidebar-user { align-items: center; }
}

@media (max-width: 500px) {
  .sidebar { display: none; }
  .cal-grid, .cal-nav { display: none; }
  .cal-list { display: block; }
}
