/* =========================================================================
   AdhiDesk — PRODUCTION STYLESHEET
   Mobile-first. Base rules target phones (320px+); larger layouts are
   layered on with min-width media queries. No HTML/JS was changed —
   every fix here is achieved with selectors against the existing markup.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. RESET
   ------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
}

img { max-width: 100%; display: block; }

/* -------------------------------------------------------------------------
   2. DESIGN TOKENS
   Single source of truth for color, spacing, radius, shadow, type.
   ------------------------------------------------------------------------- */
:root {
  /* --- Brand palette (systematized from the existing terracotta/clay scheme) --- */
  --color-primary: #824c35;
  --color-primary-dark: #6a3c29;
  --color-primary-light: #a49c7e;
  --color-accent: #c37858;
  --color-accent-soft: #fff0e9;

  /* --- Semantic colors --- */
  --color-success-bg: #d4edda;
  --color-success-text: #155724;
  --color-info-bg: #cce5ff;
  --color-info-text: #004085;
  --color-danger: #c0392b;
  --color-focus-ring: rgba(37, 99, 235, 0.18);

  /* --- Neutrals --- */
  --color-bg: #f7f5f2;
  --color-surface: #ffffff;
  --color-surface-alt: #fbfaf8;
  --color-border: #e2ddd6;
  --color-border-strong: #c9c2b8;
  --color-text: #1e293b;
  --color-text-muted: #667085;
  --color-text-inverse: #ffffff;

  /* --- Typography --- */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --fs-sm: clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);
  --fs-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --fs-md: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  --fs-lg: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --fs-xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --lh-tight: 1.25;
  --lh-normal: 1.5;

  /* --- Spacing scale (4px base) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* --- Radius --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* --- Elevation --- */
  --shadow-sm: 0 1px 3px rgba(30, 24, 18, 0.08);
  --shadow-md: 0 4px 15px rgba(30, 24, 18, 0.12);
  --shadow-lg: 0 10px 30px rgba(30, 24, 18, 0.18);

  /* --- Layout --- */
  --container-max: 1440px;
  --header-height: 56px;
  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
}

/* -------------------------------------------------------------------------
   3. BASE TYPOGRAPHY
   ------------------------------------------------------------------------- */
body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  padding: var(--space-3);
  overflow-x: hidden; /* belt-and-suspenders: page never scrolls sideways */
}

h1 {
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
  font-weight: 700;
}

h2 { font-size: var(--fs-lg); margin: 0 0 var(--space-3); font-weight: 700; }
h3 { font-size: var(--fs-md); margin: 0 0 var(--space-2); font-weight: 600; }

p { color: var(--color-text-muted); margin: 0 0 var(--space-3); }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

/* -------------------------------------------------------------------------
   4. LAYOUT PRIMITIVES
   ------------------------------------------------------------------------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

/* Consistent vertical rhythm between top-level blocks so nothing
   needs manual <br><br> spacing to look right. */
.container > * + *,
body > .card + button,
body > button + button {
  margin-top: var(--space-4);
}

/* -------------------------------------------------------------------------
   5. APP HEADER / PROFILE BAR
   Fixed -> sticky. Sticky keeps it pinned on scroll WITHOUT removing it
   from document flow, so it can never overlap the content beneath it —
   this is the fix for the core overlap/white-screen bug.
   ------------------------------------------------------------------------- */
#profileContainer {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  background: var(--color-surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin: 0 0 var(--space-4);
  min-height: var(--header-height);
  /* establishes a positioning context for #profileMenu below */
}

#google_translate_element {
  margin-right: auto;
}

#groupSwitcher {
  height: 40px;
  flex: 1 1 140px;
  min-width: 0;
  max-width: 220px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong);
  padding: 0 var(--space-3);
  font-size: var(--fs-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

#groupMenuBtn {
  background: transparent !important;
  color: var(--color-text);
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: var(--space-1) var(--space-2);
  width: auto;
  min-width: auto;
  border-radius: var(--radius-sm);
}
#groupMenuBtn:hover { background: var(--color-bg) !important; }

#profilePhoto {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  object-fit: cover;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

#loginBtn {
  display: block;
  margin-left: auto;
}

/* -------------------------------------------------------------------------
   6. DROPDOWN MENUS
   Anchored with real positioning contexts instead of guessed pixels,
   and always clamped inside the viewport.
   ------------------------------------------------------------------------- */
#profileMenu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: var(--space-2);
  left: auto;
  background: var(--color-primary);
  border: 1px solid var(--color-primary-dark);
  border-radius: var(--radius-md);
  min-width: 180px;
  max-width: min(80vw, 220px);
  padding: var(--space-2);
  box-shadow: var(--shadow-md);
  z-index: 1000;
}
#profileMenu button {
  width: 100%;
  text-align: left;
  margin-bottom: var(--space-1);
  color: var(--color-text-inverse);
  background: transparent;
  border-radius: var(--radius-sm);
}
#profileMenu button:last-child { margin-bottom: 0; }
#profileMenu button:hover { background: rgba(255, 255, 255, 0.15); }

#groupMenu {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-3);
  left: auto;
  max-width: min(88vw, 220px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  box-shadow: var(--shadow-lg);
  z-index: 999;
}
#groupMenu button {
  display: block;
  width: 100%;
  border: none;
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
#groupMenu button:hover { background: var(--color-bg); }

/* -------------------------------------------------------------------------
   7. BUTTONS
   ------------------------------------------------------------------------- */
button {
  font-family: var(--font-family);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  min-height: 38px; /* still an easy tap target, without looking oversized */
  background: var(--color-primary-light);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

button:not(.actionBtn):hover {
  background: var(--color-primary-light);
  filter: brightness(0.92);
}

button:hover { background-color: var(--color-primary); }
button:active { transform: translateY(1px); }

.actionBtn {
  border: none;
  background: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 1rem;
  min-height: 32px;
  min-width: 32px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}
.actionBtn:hover { background: var(--color-accent-soft); }

#addCaseBtn,
#calendarToggleBtn {
  background: var(--color-primary);
}

/* -------------------------------------------------------------------------
   7b. PENDING / DECIDED TOGGLE
   Targeted by their exact onclick handlers so no HTML changes are needed.
   Rendered as a single connected segmented control instead of two
   separate, visually-merged buttons.
   ------------------------------------------------------------------------- */
button[onclick="displayCases()"],
button[onclick="showDecidedCases()"] {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  margin-top: var(--space-3);
  margin-right: 0;
}
button[onclick="displayCases()"] {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}
button[onclick="showDecidedCases()"] {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 2px solid var(--color-primary); /* the visible separator */
}
button[onclick="displayCases()"]:hover,
button[onclick="showDecidedCases()"]:hover {
  background: var(--color-accent-soft);
}
/* "active" is applied by the small UI-enhancements script — see JS notes */
button[onclick="displayCases()"].active,
button[onclick="showDecidedCases()"].active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* Body-level toolbar buttons (export / import) wrap cleanly on mobile */
body > button,
body > input[type="file"] + button {
  margin-right: var(--space-2);
}

/* -------------------------------------------------------------------------
   8. FORMS
   #formCard is laid out with flex (mobile) -> grid (desktop) by hiding
   style.css - Add/Update this */
    main.container {
    display: flex;
    flex-direction: column;
    gap: var(--space-6); /* This provides consistent space between all sections */
    padding: var(--space-4);
}

/* Remove manual spacing hacks if present in your markup */
main.container br { display: none; }

/* Ensure every section card is uniform */
section.card {
    width: 100%;
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  font-family: var(--font-family);
  font-size: 1rem; /* keep >=16px to prevent iOS auto-zoom on focus */
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 44px;
}

textarea { min-height: 88px; resize: vertical; }

/* -------------------------------------------------------------------------
   8b. TO-DO NOTE TEXTAREAS
   The global textarea rule above sets min-height:88px for normal forms.
   That same min-height was forcing every per-item note box in the To Do
   list to render ~88px tall even when its real content was one line.
   The JS auto-resize logic was already correct — this just stops the
   global rule from overriding it.
   ------------------------------------------------------------------------- */
#workToDoList textarea {
  min-height: 0;
  height: auto;
}


input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

#formCard br { display: none; } /* rhythm now comes from flex/grid gap */

#formCard {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

#formCard input,
#formCard select {
  max-width: 100%;
}

#workToDo { width: 100%; }

/* -------------------------------------------------------------------------
   9. CARDS
   ------------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.caseCard { border-radius: var(--radius-md); }

/* -------------------------------------------------------------------------
   10. TABLES
   ------------------------------------------------------------------------- */
.tableContainer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-2);
}

table {
  width: 100%;
  min-width: 560px;
  background-color: var(--color-surface);
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

thead th {
  position: sticky;
  top: 0;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  z-index: 1;
}

th, td {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  text-align: center;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

/* Keep short, fixed-format columns (numbers/icons) from wrapping awkwardly */
th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2),
th:nth-child(3), td:nth-child(3) {
  white-space: nowrap;
}

/* Fix Case Status wrapping in Selected Date table */
#selectedDateCasesTable th:nth-child(6),
#selectedDateCasesTable td:nth-child(6) {
    white-space: normal;
    min-width: 100px;
    word-break: break-word;
}
td:has(.actionBtn) {
  white-space: nowrap;
  width: 1%;
}

tr:nth-child(even) td { background-color: var(--color-surface-alt); }
tr:hover td { background-color: var(--color-accent-soft); }

/* -------------------------------------------------------------------------
   11. BADGES / TAGS
   ------------------------------------------------------------------------- */
.applicantTag,
.respondentTag,
.viewBadge {
  display: inline-block;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--fs-xs);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
}

.applicantTag { background: var(--color-success-bg); color: var(--color-success-text); }
.respondentTag { background: var(--color-info-bg); color: var(--color-info-text); }

.partyTag {
  display: inline-block;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--fs-xs);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
  background: var(--color-info-bg);
  color: var(--color-info-text);
  margin-bottom: 4px;
}

.viewBadge {
  padding: var(--space-2) var(--space-5);
  font-size: var(--fs-base);
  background: var(--color-accent-soft);
  color: var(--color-primary-dark);
}

/* -------------------------------------------------------------------------
   12. CALENDAR (custom, lightweight — replaces FullCalendar)
   -------------------------------------------------------------------------
   Built entirely with CSS Grid, so it reflows correctly the instant the
   container becomes visible (no library-side size caching, which was the
   likely cause of the old "table-like on mobile" complaint). The selected
   date is a real CSS class (.cal-day.selected), not an inline style, so
   it can never be left in an inconsistent state by a partial re-render.
   ------------------------------------------------------------------------- */
#calendar {
  width: 100%;
  min-width: 0;
  overflow-x: hidden; /* the grid is intrinsically responsive, never needs to scroll */
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border); /* separator instead of a full nested box */
}

.selectedDate {
  background-color: var(--color-info-bg) !important;
  border-radius: 50%;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.cal-toolbar button {
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--color-surface-alt);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.cal-toolbar button:hover { background: var(--color-accent-soft); }

.cal-month-label {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--color-text);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  min-height: 0;
  padding: 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.cal-day:hover { background: var(--color-accent-soft); }
.cal-day:active { transform: scale(0.94); }

.cal-day.today {
  box-shadow: inset 0 0 0 2px var(--color-primary-light);
}

.cal-day.selected {
  background: var(--color-info-bg);
  box-shadow: inset 0 0 0 2px var(--color-primary);
  font-weight: 700;
}

.cal-day-blank {
  visibility: hidden;
  pointer-events: none;
}

.cal-dots {
  display: flex;
  gap: 3px;
  height: 6px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.cal-dot-case { background: #666; }  /* same gray as the old case dot */
.cal-dot-work { background: blue; }  /* same blue as the old work-to-do dot */

/* -------------------------------------------------------------------------
   13. MODAL
   ------------------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000; /* Increased z-index */
  overflow-y: auto;
  background-color: rgba(30, 24, 18, 0.55);
  padding: var(--space-4);
}

.modalContent {
  background-color: var(--color-surface);
  width: min(95vw, 800px);
  max-height: 90vh;
  overflow-y: auto;
  margin: var(--space-4) auto;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  position: relative; /* Context for close button */
}

.closeBtn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: var(--color-text-muted);
}
.closeBtn:hover {
  color: var(--color-text);
}

/* Timeline UI */
.timeline {
    display: flex;
  flex-direction: column;
    margin: var(--space-3) 0;
}
.timeline-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.timeline-dot {
    color: var(--color-primary);
    font-size: 1.2rem;
}
.timeline-line {
    padding-left: 0.4rem;
    color: var(--color-border);
    font-weight: bold;
}
.timeline-content {
    font-size: var(--fs-sm);
  }

.modalGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.modalColumn {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.historyTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.historyTable th, .historyTable td {
    padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
}
/* -------------------------------------------------------------------------
   14. MISC FIXED ELEMENTS
   ------------------------------------------------------------------------- */
#appVersion {
  position: fixed;
  bottom: var(--space-2);
  right: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  background: var(--color-surface);
    padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  z-index: 200;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  }

/* Hide the default Google Translate bar and branding */
.goog-te-banner-frame.skiptranslate,
.goog-te-gadget-simple {
    display: none !important;
}
body { top: 0 !important; }

#userInfo { display: none; }

/* -------------------------------------------------------------------------
   15. ACCESSIBILITY & POLISH
   ------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-primary)16;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* Thin, unobtrusive scrollbars on the horizontal-scroll containers */
.tableContainer::-webkit-scrollbar,
#calendar::-webkit-scrollbar {
  height: 8px;
}
.tableContainer::-webkit-scrollbar-thumb,
#calendar::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-pill);
}

/* =========================================================================
   16. RESPONSIVE BREAKPOINTS (mobile-first: rules above are the phone
   baseline; each breakpoint below only ADDS/ADJUSTS for more space)
   ========================================================================= */

/* --- Small tablets / large phones (≥600px) --- */
@media (min-width: 600px) {
  body { padding: var(--space-6); }

  #formCard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4) var(--space-5);
    align-items: start;
  }
  #formCard label,
  #formCard button {
    grid-column: 1 / -1;
  }

  /* "AdhiDesk" title + tagline: centered, stacked, on their own row
     above the two-column field grid. */
  #formCard h1,
  #formCard > p:first-of-type {
    grid-column: 1 / -1;
    text-align: center;
  }
  #formCard h1 { margin-bottom: 0; }
  #formCard > p:first-of-type { margin-bottom: var(--space-2); }

  body > button { width: auto; }
}

/* --- Tablets / small laptops (≥900px) --- */
@media (min-width: 900px) {
  .card { padding: var(--space-6); }

  #profileContainer {
    justify-content: flex-end;
    padding: var(--space-3) var(--space-5);
  }

  table { font-size: var(--fs-base); }

  button {
    font-size: var(--fs-sm);
    padding: var(--space-2) var(--space-4);
    min-height: 40px;
  }

  /* On roomier screens, a max-width keeps day cells from becoming huge */
  .cal-grid { max-width: 480px; margin: 0 auto; }
  .cal-weekdays { max-width: 480px; margin: 0 auto var(--space-1); }
}
/* --- Desktop (≥1200px) --- */
@media (min-width: 1200px) {
  body { padding: var(--space-8) var(--space-10); }

  .container { padding: 0; }
}

/* --- Narrow phones (≤380px): tighten up further, never overflow --- */
@media (max-width: 380px) {
  h1 { font-size: 1.35rem; }
  .card { padding: var(--space-4); }
  #groupSwitcher { max-width: 130px; }
  .modalContent { padding: var(--space-4); }

  /* Make buttons smaller on very narrow screens */
  button {
    font-size: 0.7rem;
    padding: var(--space-1) var(--space-2);
    min-height: 30px;
  }

  .cal-day { font-size: var(--fs-xs); }
}

table th:nth-child(3),
table td:nth-child(3) {
    min-width: 140px;
}

table th:nth-child(5),
table td:nth-child(5) {
    min-width: 220px;
}

/* Force Party Name column to behave correctly on mobile */
#selectedDateCasesTable th:nth-child(4),
#selectedDateCasesTable td:nth-child(4) {
    white-space: normal;
    min-width: 150px;
    word-break: break-word;
}

/* Force Next Date/Status column to behave correctly on mobile */
#tableBody tr td:last-child {
    white-space: normal;
    min-width: 120px;
    word-break: break-word;
}

/* style.css */

/* Add spacing between sibling sections */
main.container > section.card {
  margin-bottom: var(--space-4);
}

/* Ensure the form card doesn't look weird when it toggles */
#formCard {
  margin-bottom: var(--space-6);
}

/* Make sure the "All Cases" section toggle button looks good */
#toggleAllCasesBtn {
  margin-bottom: var(--space-2);
}
/* style.css */

.partyTag {
  display: inline-block;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--fs-xs);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
  /* Applying the light blue color as requested */
  background: var(--color-info-bg);
  color: var(--color-info-text);
  margin-bottom: 4px;
}

/* =========================================================================
   17. LOGIN SCREEN (pre-authentication state)
   -------------------------------------------------------------------------
   Scope of this whole section: it only ever applies while the user is
   logged out, detected via :has() against the *existing* inline style
   script.js already sets on #loginBtn:
     - logged out -> loginBtn.style.display = "inline-block"
     - logged in  -> loginBtn.style.display = "none"
   Because of that:
     - Zero HTML changes.
     - No ID/class/function/variable renamed or removed.
     - No element moved in the DOM.
     - No Firebase/auth/case logic touched.
   The heading and subtitle are rendered as ::before/::after generated
   content on the existing <main class="container">, then repositioned
   with the flex `order` property — generated content counts as a real
   flex item and can be freely reordered, so no new DOM nodes are needed
   to place "icon+heading" above "subtitle" above the real #loginBtn.
   Browsers without :has() support just keep the earlier plain button —
   nothing breaks, it's a progressive enhancement only.
   ========================================================================= */

/* Local tokens, additive only — the existing :root block is untouched */
body:has(#loginBtn[style*="inline-block"]) {
  --login-ink: #2c1b12;
  --login-wash-a: #fdf6ef;
  --login-wash-b: #f1e2d3;
}

/* Full-page backdrop wash behind the card (uses existing brand tokens,
   no new brand colors introduced) */
body:has(#loginBtn[style*="inline-block"]) {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--color-accent-soft), transparent),
    linear-gradient(180deg, var(--login-wash-a), var(--login-wash-b));
}

/* Large, faint scales-of-justice watermark — purely decorative, sits
   behind the card (z-index 0), attached to <body> itself so it never
   interferes with the real content or its show/hide logic */
body:has(#loginBtn[style*="inline-block"])::before {
  content: "⚖️";
  position: fixed;
  top: 6%;
  right: 6%;
  font-size: clamp(4rem, 14vw, 9rem);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

/* The card: <main class="container"> already exists in the markup and is
   only restyled while logged out. Every real app section inside it is
   already display:none at this point (script.js's own logic does that),
   so only the login pieces actually render inside the card. */
  body:has(#loginBtn[style*="inline-block"]) main.container {
  position: relative;
  z-index: 1;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  width: min(92vw, 420px);
  margin: 8vh auto;
  padding: var(--space-8) var(--space-6);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  }

/* Heading — "⚖️ Welcome to AdhiDesk" — generated content, placed first */
  body:has(#loginBtn[style*="inline-block"]) main.container::before {
  content: "⚖️ Welcome to AdhiDesk";
  order: 1;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--login-ink);
  line-height: var(--lh-tight);
  }

/* Subtitle — generated content, moved above the button purely via
   flex `order` (no DOM change needed to reorder it) */
body:has(#loginBtn[style*="inline-block"]) main.container::after {
  content: "Smart Case Management for Advocates";
  order: 2;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  letter-spacing: 0.2px;
  margin-bottom: var(--space-2);
}

/* The real #loginBtn — same element, same onclick="googleLogin()", just
   restyled into a prominent SaaS-style primary action */
body:has(#loginBtn[style*="inline-block"]) #loginBtn {
  order: 3;
  position: relative;
  width: 100%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  font-size: var(--fs-base);
  font-weight: 700;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
body:has(#loginBtn[style*="inline-block"]) #loginBtn:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
body:has(#loginBtn[style*="inline-block"]) #loginBtn:active {
  transform: translateY(0);
}
/* Small circular "G" mark before the label — CSS only, no external asset */
body:has(#loginBtn[style*="inline-block"]) #loginBtn::before {
  content: "G";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: var(--color-primary);
  font-weight: 800;
  font-size: 0.8rem;
}

/* #userInfo sits right after #loginBtn in the markup; it's empty text
   while logged out, so just keep it from taking visual space — the
   element itself is untouched, only hidden while it has no content */
body:has(#loginBtn[style*="inline-block"]) #userInfo:empty {
  display: none;
}

/* -------------------------------------------------------------------------
   Loading state (optional, purely visual).
   Toggled ONLY by a small additive class-toggle in ui-enhancements.js —
   that listener does not call Firebase or touch script.js in any way,
   it only adds/removes "login-loading" on <body> around the click.
   ------------------------------------------------------------------------- */
body.login-loading #loginBtn {
  pointer-events: none;
  color: transparent !important;
}
body.login-loading #loginBtn::before {
  opacity: 0;
}
body.login-loading #loginBtn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}

/* Responsive: tighten the card on small phones */
@media (max-width: 420px) {
  body:has(#loginBtn[style*="inline-block"]) main.container {
    margin: 6vh auto;
    padding: var(--space-6) var(--space-5);
    width: min(94vw, 380px);
  }
  body:has(#loginBtn[style*="inline-block"]) main.container::before {
    font-size: var(--fs-lg);
  }
}
