/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2e3247;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #3b82f6;
  --danger: #dc2626;

  --sev-extreme:  #dc2626;
  --sev-severe:   #ea580c;
  --sev-moderate: #ca8a04;
  --sev-minor:    #6b7280;

  --state-pending:      #94a3b8;
  --state-sent:         #3b82f6;
  --state-broadcasting: #22c55e;
  --state-ended:        #6b7280;
  --state-failed:       #dc2626;

  --header-h: 44px;
  --alerts-w: 340px;
  --right-w:  400px;
}

html, body { height: 100%; overflow: hidden; font-family: system-ui, sans-serif; font-size: 13px; background: var(--bg); color: var(--text); }

/* ── Header ── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}
.logo { font-weight: 700; font-size: 15px; letter-spacing: .03em; }
.cbc-url { margin-left: auto; color: var(--text-muted); font-size: 11px; }

/* ── Layout ── */
.layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Panels ── */
.panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.panel-alerts { width: var(--alerts-w); flex-shrink: 0; }
.panel-map    { flex: 1; border-right: none; }
.panel-right  { width: var(--right-w); flex-shrink: 0; border-left: 1px solid var(--border); border-right: none; overflow-y: auto; }

.panel-header {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* ── Scroll lists ── */
.scroll-list { flex: 1; overflow-y: auto; }
.empty-hint  { padding: 20px 14px; color: var(--text-muted); font-style: italic; }

/* ── Alert items ── */
.alert-item {
  padding: 10px 12px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.alert-item:hover, .alert-item.selected { background: #23273a; }
.alert-item .a-headline { font-weight: 600; line-height: 1.3; }
.alert-item .a-meta     { color: var(--text-muted); margin-top: 2px; font-size: 11px; }
.alert-item .a-expires  { color: var(--text-muted); font-size: 11px; margin-top: 1px; }

/* ── Map ── */
#map { width: 100%; height: 100%; }

/* ── Leaflet polygon colours ── */
.layer-extreme  { stroke: var(--sev-extreme);  fill: var(--sev-extreme);  }
.layer-severe   { stroke: var(--sev-severe);   fill: var(--sev-severe);   }
.layer-moderate { stroke: var(--sev-moderate); fill: var(--sev-moderate); }
.layer-minor    { stroke: var(--sev-minor);    fill: var(--sev-minor);    }
.layer-sent     { stroke: #a855f7; fill: #a855f7; stroke-dasharray: 6,4; }

/* ── Composer ── */
.composer {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.composer.disabled { opacity: .45; pointer-events: none; }

.composer-alert-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 24px;
}
.c-headline { font-weight: 600; line-height: 1.3; }

.severity-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.form-row label { color: var(--text-muted); width: 90px; flex-shrink: 0; font-size: 11px; }
.form-row input[type="datetime-local"],
.form-row input[type="number"] {
  background: #23273a; border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 4px 7px; font-size: 12px;
}
.form-row input[type="datetime-local"] { flex: 1; }

.form-row-col { flex-direction: column; align-items: flex-start; }
.form-row-col label { width: auto; display: flex; width: 100%; justify-content: space-between; }

textarea#c-text {
  width: 100%; resize: vertical;
  background: #23273a; border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 6px 8px; font-size: 12px; font-family: inherit;
}

select#sel-level {
  flex: 1; background: #23273a; border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 4px 7px; font-size: 12px;
}

.c-channel-display { font-weight: 600; color: var(--accent); }
.char-count { font-size: 11px; color: var(--text-muted); }
.char-count.over-limit { color: var(--danger); }

.targeting-info { font-size: 11px; color: var(--text-muted); flex: 1; }

/* ── Draw toolbar ── */
.draw-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.draw-btn {
  padding: 3px 9px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer; font-size: 11px;
  transition: background .1s, color .1s, border-color .1s;
}
.draw-btn:hover:not(:disabled) { background: #23273a; color: var(--text); }
.draw-btn.active { background: #1e3a5f; border-color: var(--accent); color: #93c5fd; }
.draw-btn-clear { color: var(--danger); }
.draw-btn-clear:hover:not(:disabled) { background: #2d1010; color: #f87171; border-color: var(--danger); }
.draw-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Leaflet.draw toolbar dark theme */
.leaflet-draw-toolbar a { background-color: #1a1d27 !important; color: #e2e8f0 !important; border-color: #2e3247 !important; }
.leaflet-draw-toolbar a:hover { background-color: #23273a !important; }

.toggle-group { display: flex; gap: 4px; }
.toggle-btn {
  padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12px;
}
.toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-send {
  width: 100%; margin-top: 6px;
  padding: 9px 0; border-radius: 5px; border: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: background .12s;
}
.btn-send:hover:not(:disabled) { background: #2563eb; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

.send-error { margin-top: 6px; color: var(--danger); font-size: 11px; min-height: 16px; }

/* ── Sent messages ── */
.sent-section {
  display: flex;
  flex-direction: column;
  min-height: 220px;
}
.sent-section .scroll-list { flex: 1; }

.sent-item {
  padding: 9px 12px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sent-item .si-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.sent-item .si-text { font-size: 11px; color: var(--text-muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sent-item .si-meta { font-size: 11px; color: var(--text-muted); }

.state-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px; white-space: nowrap;
}
.state-Pending      { background: #334155; color: var(--state-pending); }
.state-Sent         { background: #1e3a5f; color: var(--state-sent); }
.state-Broadcasting { background: #14532d; color: var(--state-broadcasting); }
.state-Ended        { background: #1f2937; color: var(--state-ended); }
.state-Failed       { background: #450a0a; color: var(--state-failed); }

.btn-cancel {
  font-size: 10px; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--border);
  background: transparent; color: var(--danger); cursor: pointer;
}
.btn-cancel:hover { background: #2d1010; }

/* ── Badges ── */
.badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.badge-gray  { background: #334155; color: #94a3b8; }
.badge-green { background: #14532d; color: #22c55e; }
.badge-red   { background: #450a0a; color: #f87171; }

/* ── Auth modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 9999; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 24px; width: 300px; display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { font-size: 16px; }
.modal input {
  flex: 1; background: #23273a; border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 6px 9px; font-size: 13px;
}
.modal button {
  padding: 8px; border-radius: 5px; border: none;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}

/* ── Leaflet dark theme tweak ── */
.leaflet-container { background: #181b26; }
.leaflet-tile-pane { filter: brightness(.85) saturate(.7) hue-rotate(200deg); }
