/* ============================================================
   district_additions.css
   Additive overrides for the 3-level region → district nav.
   Load AFTER district_styles.css.
   Mobile-first · conserves vertical space · no cards on lists.
   ============================================================ */

/* ── 1. REGION LIST ─────────────────────────────────────────────
   Plain rows: dot + underlined name. Nothing else.
   ─────────────────────────────────────────────────────────────── */
.region-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 100px;     /* bottom pad clears footer pill */
  width: 100%;
}

.region-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
  border-bottom: 1px solid var(--ds-card-border);
  width: 100%;
  box-sizing: border-box;
}
.region-row:active { background: rgba(0,0,0,.04); }
.theme-dark .region-row:active { background: rgba(255,255,255,.05); }

/* Status dot */
.region-row-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.region-row-dot--open   { background: var(--ds-open-dot); }
.region-row-dot--full   { background: var(--ds-full-dot); }
.region-row-dot--chosen { background: var(--ds-accent);   }

/* Underlined name */
.region-row-name {
  flex: 1;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-primary, #1C1C1E);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(0,0,0,.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.theme-dark .region-row-name {
  text-decoration-color: rgba(255,255,255,.22);
}

/* Subtle "my district" suffix */
.region-row-mine {
  font-size: .72rem;
  font-weight: 400;
  color: var(--ds-accent);
  margin-left: 5px;
  text-decoration: none;
}

/* Chevron */
.region-row-chevron {
  color: var(--text-tertiary, #8E8E93);
  flex-shrink: 0;
  opacity: .55;
}

/* ── 2. DISTRICT LIST ───────────────────────────────────────────
   Single-line: [name][bar][info icon][avatars or Select btn]
   ─────────────────────────────────────────────────────────────── */
.district-list-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 100px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.dl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--ds-card-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
  min-height: 46px;
  width: 100%;
  box-sizing: border-box;
}
.dl-row:active { background: rgba(0,0,0,.04); }
.theme-dark .dl-row:active { background: rgba(255,255,255,.04); }

/* Name: flex shrink so bar always has room */
.dl-row-name {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-primary, #1C1C1E);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* flex: 1 so it takes available space, then bar fills the rest */
  flex: 1 1 auto;
  min-width: 60px;
  /* No vw cap — the parent column is already constrained to 600px */
}

/* Thin progress bar in middle */
.dl-bar-wrap {
  flex: 0 0 64px;   /* fixed width — predictable, not competing with name */
  min-width: 28px;
  height: 3px;
  background: var(--ds-bar-bg);
  border-radius: 99px;
  overflow: hidden;
}
.dl-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .3s ease;
}
.dl-bar-fill--low  { background: var(--ds-open-dot); }
.dl-bar-fill--half { background: #f59e0b; }
.dl-bar-fill--full { background: var(--ds-full-dot); }

/* Info icon — removed: replaced by unified dl-action-btn */

/* Right side: avatar stack OR action button */
.dl-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0;
}

/* Stacked avatars */
.dl-av {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--ds-card-bg, #fff);
  object-fit: cover;
  flex-shrink: 0;
}
.dl-av + .dl-av { margin-left: -8px; }
.dl-av--initials {
  display: grid; place-items: center;
  font-size: .55rem; font-weight: 700;
  color: #fff;
  background: var(--ds-accent);
}
.dl-av--more {
  background: var(--ds-bar-bg);
  color: var(--text-tertiary);
  font-size: .58rem; font-weight: 700;
}

/* ── Unified action button ─────────────────────────────────────────────────
   Single button per district row. Replaces both the info ⓘ icon and the
   old separate Select button.
   - Default "Select" → blue border/text, opens detail view
   - "--chosen"       → solid blue, already selected
   - "--taken"        → gray, user has another district (shows "View")
   - "--full"         → red-tinted, district is at capacity
   ──────────────────────────────────────────────────────────────────────── */
.dl-select-btn {
  border: 1px solid var(--ds-accent);
  color: var(--ds-accent);
  background: none;
  border-radius: var(--ds-radius-full);
  padding: 4px 12px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
}
.dl-select-btn:active,
.dl-select-btn:hover {
  background: var(--ds-accent);
  color: #fff;
}

/* Chosen — this is the user's district */
.dl-select-btn--chosen {
  background: var(--ds-accent);
  color: #fff;
  border-color: var(--ds-accent);
  cursor: default;
}
.dl-select-btn--chosen:hover,
.dl-select-btn--chosen:active {
  background: var(--ds-accent);
  color: #fff;
}

/* Taken — user already chose a different district; gray out, still clickable to view */
.dl-select-btn--taken {
  border-color: var(--text-tertiary, #8E8E93);
  color: var(--text-tertiary, #8E8E93);
  opacity: .65;
}
.dl-select-btn--taken:hover,
.dl-select-btn--taken:active {
  background: rgba(0,0,0,.06);
  color: var(--text-tertiary, #8E8E93);
  border-color: var(--text-tertiary, #8E8E93);
}
.theme-dark .dl-select-btn--taken:hover { background: rgba(255,255,255,.08); }

/* Full — district has no open slots */
.dl-select-btn--full {
  border-color: var(--ds-full-dot);
  color: var(--ds-full-dot);
  opacity: .75;
  cursor: default;
}
.dl-select-btn--full:hover,
.dl-select-btn--full:active {
  background: var(--ds-full-bg);
  color: var(--ds-full-dot);
}

/* Dimmed row when user can't select (already has a district elsewhere) */
.dl-row--dimmed {
  opacity: .72;
}

/* Chosen badge instead of select */
.dl-chosen-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ds-accent);
  flex-shrink: 0;
}

/* ── 3. DETAIL PAGE ─────────────────────────────────────────────
   Full scrollable sheet for a single district.
   ─────────────────────────────────────────────────────────────── */

/* Topbar already styled in district_styles.css (.detail-topbar).
   We only need to add new sections below. */

/* Detail page fills available screen width */
.district-detail-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.dd-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 100px;
}

/* Weather card */
.dd-weather {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ds-card-border);
}
.dd-weather-icon {
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.dd-weather-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dd-weather-temp {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
  line-height: 1;
}
.dd-weather-desc {
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}
.dd-weather-meta {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: .74rem;
  color: var(--text-tertiary);
}

/* Info row: zone + map */
.dd-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--ds-card-border);
}
.dd-zone-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,.05);
  border-radius: var(--ds-radius-full);
  padding: 4px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: capitalize;
}
.theme-dark .dd-zone-badge { background: rgba(255,255,255,.09); }

.dd-map-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-radius-full);
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.dd-map-btn:hover,
.dd-map-btn:active { border-color: var(--ds-accent); color: var(--ds-accent); }

/* Students section */
.dd-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ds-card-border);
}
.dd-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.dd-students-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dd-student-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dd-student-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.dd-student-av--initials {
  display: grid; place-items: center;
  font-size: .62rem; font-weight: 700;
  color: #fff;
  background: var(--ds-accent);
}
.dd-student-name {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd-student-reg {
  font-size: .72rem;
  color: var(--text-tertiary);
}
.dd-no-data {
  font-size: .83rem;
  color: var(--text-tertiary);
  padding: 4px 0;
}

/* Actions section */
.dd-actions {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--ds-card-border);
}

/* Select District button */
.dd-select-btn {
  width: 100%;
  background: var(--ds-accent);
  color: #fff;
  border: none;
  border-radius: var(--ds-radius-full);
  padding: 13px 20px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.dd-select-btn:active { transform: scale(.98); }
.dd-select-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Locked variant — used when user already has a district */
.dd-select-btn--locked {
  background: var(--ds-bar-bg);
  color: var(--text-tertiary);
}

/* Info note shown above disabled button when user already has a district */
.dd-taken-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-size: .78rem;
  color: var(--text-tertiary);
  line-height: 1.45;
  padding: 2px 0 4px;
  background: color-mix(in srgb, var(--ds-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--ds-accent) 18%, transparent);
  border-radius: 10px;
  padding: 8px 10px;
}
.dd-taken-note > svg { flex-shrink: 0; }
.dd-taken-note > span { flex: 1; min-width: 0; }

/* "Go to Settings" inline action button */
.dd-goto-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: var(--ds-accent);
  color: #fff;
  font-size: .74rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.dd-goto-profile-btn:hover { background: color-mix(in srgb, var(--ds-accent) 85%, #000); }
.dd-goto-profile-btn:active { transform: scale(.9); }
.dd-applied-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: #22c55e;
  padding: 8px 0;
}
.dd-full-badge {
  font-size: .83rem;
  color: var(--text-tertiary);
  padding: 6px 0;
}

/* Contact accordion */
.dd-contact-wrap {
  padding: 0 20px;
}
.dd-contact-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-primary);
  border-top: 1px solid var(--ds-card-border);
  -webkit-tap-highlight-color: transparent;
  transition: color .12s;
}
.dd-contact-btn:hover { color: var(--ds-accent); }
.dd-contact-btn svg { flex-shrink: 0; }
.dd-contact-chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform .22s;
}
.dd-contact-btn[aria-expanded="true"] .dd-contact-chevron {
  transform: rotate(180deg);
}

.dd-contact-body {
  overflow: hidden;
  transition: max-height .28s ease, opacity .22s ease;
  max-height: 0;
  opacity: 0;
}
.dd-contact-body.open {
  max-height: 200px;
  opacity: 1;
}
.dd-contact-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--ds-card-border);
  font-size: .83rem;
}
.dd-contact-row:last-child { border-bottom: none; padding-bottom: 16px; }
.dd-contact-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 48px;
  flex-shrink: 0;
}
.dd-contact-value { color: var(--text-primary); }
.dd-contact-value a {
  color: var(--ds-accent);
  text-decoration: none;
}
.dd-contact-null { color: var(--text-tertiary); font-size: .78rem; }

/* ── 4. AVATAR COLOR CLASSES (shared) ───────────────────────────
   Reused across list + detail avatar chips.
   ─────────────────────────────────────────────────────────────── */
.av-color-blue   { background: #3b82f6 !important; }
.av-color-green  { background: #22c55e !important; }
.av-color-purple { background: #a855f7 !important; }
.av-color-orange { background: #f97316 !important; }
.av-color-pink   { background: #ec4899 !important; }
.av-color-teal   { background: #14b8a6 !important; }

/* ============================================================
   DMO Connect additions (merged)
   ============================================================ */

/* ============================================================
   district_additions.css  — DMO Connect additions
   Loaded after district_styles.css.

   Contains:
     • Refresh button (header strip + standalone empty-state variant)
     • Region user-count badge
     • District lock note
     • Spin animation for the refresh icon
   ============================================================ */


/* ── Refresh button — icon-only, sits next to the regions count pill ── */

.btn-refresh-regions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 30px;
  height: 30px;
  border-radius: var(--ds-radius-full);
  border: 1.5px solid transparent;
  background: rgba(0, 0, 0, 0.055);
  color: var(--text-secondary, #636366);
  cursor: pointer;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  transition:
    color .15s,
    background .15s,
    border-color .15s,
    transform .1s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.btn-refresh-regions:hover {
  color: var(--ds-accent);
  background: var(--ds-accent-light);
  border-color: var(--ds-accent);
}

.btn-refresh-regions:active {
  transform: scale(.88);
}

.theme-dark .btn-refresh-regions {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #8E8E93);
}

.theme-dark .btn-refresh-regions:hover {
  background: var(--ds-accent-light);
  border-color: var(--ds-accent);
  color: var(--ds-accent);
}


/* ── Standalone variant — shown inside the empty state ── */

.btn-refresh-regions--standalone {
  width: auto;
  height: auto;
  padding: 10px 20px;
  border-radius: var(--ds-radius-full);
  border: 1.5px solid var(--ds-accent);
  background: var(--ds-accent-light);
  color: var(--ds-accent);
  font-size: .85rem;
  margin-top: 4px;
}

.btn-refresh-regions--standalone:hover {
  background: var(--ds-accent);
  color: #fff;
}


/* ── Spin animation for the refresh SVG icon ── */

@keyframes dmo-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.btn-refresh-regions.is-spinning .refresh-icon {
  animation: dmo-spin .6s linear infinite;
  pointer-events: none;
}

/* Disable interaction while spinning */
.btn-refresh-regions.is-spinning {
  opacity: .6;
  pointer-events: none;
}


/* ── Region user-count badge — right side of region cards ── */

.region-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  border-radius: var(--ds-radius-full);
  background: var(--ds-accent-light);
  color: var(--ds-accent);
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  letter-spacing: .01em;
}

.region-user-badge svg {
  flex-shrink: 0;
  opacity: .85;
}

.theme-dark .region-user-badge {
  background: rgba(0, 122, 255, 0.15);
  color: #4da3ff;
}

/* When the region is full, tint the badge red */
.region-card--full .region-user-badge {
  background: var(--ds-full-bg);
  color: var(--ds-full-dot);
}

.theme-dark .region-card--full .region-user-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}


/* ── District lock note — shown below the disabled Apply button ── */

.district-lock-note {
  font-size: .76rem;
  color: var(--text-tertiary, #8E8E93);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--ds-radius-sm);
  padding: 8px 12px;
  line-height: 1.5;
  margin-top: 2px;
  width: 100%;
  text-align: center;
}

.theme-dark .district-lock-note {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}


/* ── ds-strip-left: allow the pill + refresh to sit flush on one line ── */

/* Make sure the left slot wraps at small screens instead of overflowing */
.ds-strip-left {
  flex-wrap: wrap;
  row-gap: 4px;
}


/* ── Responsive tweaks ── */

@media (max-width: 390px) {
  .btn-refresh-regions {
    width: 28px;
    height: 28px;
  }

  .region-user-badge {
    font-size: .66rem;
    padding: 2px 6px 2px 5px;
  }
}


/* ── District-occupied badge on region cards ─────────────────────────────── */
.region-district-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  background: color-mix(in srgb, var(--accent, #007AFF) 12%, transparent);
  color: var(--accent, #007AFF);
  border: 1px solid color-mix(in srgb, var(--accent, #007AFF) 22%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}
.theme-dark .region-district-badge {
  background: color-mix(in srgb, var(--accent, #007AFF) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent, #007AFF) 28%, transparent);
}

/* ── Switch button on district list row (L2) ─────────────────────────────── */
.dl-select-btn--switch {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #b45309;
  border: 1.5px solid color-mix(in srgb, #f59e0b 35%, transparent);
  font-weight: 700;
  transition: background .15s, transform .1s;
}
.dl-select-btn--switch:hover  { background: color-mix(in srgb, #f59e0b 20%, transparent); }
.dl-select-btn--switch:active { transform: scale(.93); }
.theme-dark .dl-select-btn--switch {
  color: #fbbf24;
  background: color-mix(in srgb, #f59e0b 14%, transparent);
  border-color: color-mix(in srgb, #f59e0b 30%, transparent);
}

/* ── Switch note on district detail (L3) ────────────────────────────────── */
.dd-switch-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, #f59e0b 10%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 28%, transparent);
  color: #92400e;
  font-size: .8rem;
  line-height: 1.5;
  margin-bottom: 10px;
}
.theme-dark .dd-switch-note {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  border-color: color-mix(in srgb, #f59e0b 24%, transparent);
  color: #fbbf24;
}
.dd-switch-note svg { flex-shrink: 0; margin-top: 2px; }

/* Switch button in detail view inherits dd-select-btn base + amber accent */
.dd-select-btn.btn-switch-district {
  background: #f59e0b;
  color: #fff;
  border: none;
}
.dd-select-btn.btn-switch-district:hover   { background: #d97706; }
.dd-select-btn.btn-switch-district:active  { transform: scale(.97); }
.dd-select-btn.btn-switch-district:disabled {
  background: rgba(0,0,0,.10);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
