/* ================================================================
   Texas Coffee Map — styles.css
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --topbar-h: 52px;
  --panel-w:  380px;
  --color-green:  #2e7d32;
  --color-blue:   #1565c0;
  --color-gray:   #616161;
  --color-red:    #c62828;
  --color-bg:     #1a1a2e;
  --color-surface:#16213e;
  --color-border: #0f3460;
  --color-text:   #e0e0e0;
  --color-accent: #e94560;
}

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

/* ── Top bar ───────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  z-index: 1000;
}

#app-title {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  color: var(--color-accent);
}

#topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

#topbar-right {
  font-size: 0.8rem;
  color: #aaa;
  white-space: nowrap;
}

#city-jump {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.82rem;
  cursor: pointer;
}

#status-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}
.chip input[type="checkbox"] { display: none; }
.chip-green  { border-color: var(--color-green);  color: #81c784; }
.chip-blue   { border-color: var(--color-blue);   color: #64b5f6; }
.chip-gray   { border-color: var(--color-gray);   color: #bdbdbd; }
.chip-red    { border-color: var(--color-red);    color: #ef9a9a; }

.chip:has(input:checked) { background: rgba(255,255,255,0.08); }
.chip:has(input:not(:checked)) { opacity: 0.4; }

#search-box {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  width: 180px;
}
#search-box::placeholder { color: #888; }

#reload-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
#reload-btn:hover { background: rgba(255,255,255,0.08); }

/* ── Map ───────────────────────────────────────────────────── */
#map {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  transition: right 0.25s ease;
}
body.panel-open #map { right: var(--panel-w); }

/* ── Detail panel ──────────────────────────────────────────── */
#detail-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: var(--panel-w);
  bottom: 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 999;
}
#detail-panel:not(.panel-closed) { transform: translateX(0); }

#panel-close {
  position: sticky;
  top: 8px;
  left: calc(100% - 40px);
  background: transparent;
  color: #aaa;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 50%;
  transition: background 0.15s;
  z-index: 2;
}
#panel-close:hover { background: rgba(255,255,255,0.1); }

#panel-content {
  padding: 16px 18px 40px;
}

/* ── Panel internals ─────────────────────────────────────── */
.panel-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}
.panel-address {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 14px;
}
.panel-meta {
  font-size: 0.8rem;
  color: #bbb;
  margin-bottom: 4px;
}
.panel-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin: 18px 0 8px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
}
.panel-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}
.panel-field label {
  font-size: 0.72rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.panel-field input,
.panel-field select,
.panel-field textarea {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 0.83rem;
  font-family: inherit;
  resize: vertical;
}
.panel-field textarea { min-height: 70px; }

.status-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.current_customer { background: var(--color-green); }
.status-dot.contacted        { background: var(--color-blue);  }
.status-dot.not_contacted    { background: var(--color-gray);  }
.status-dot.denied           { background: var(--color-red);   }

.save-btn {
  width: 100%;
  margin-top: 18px;
  padding: 9px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.save-btn:hover { opacity: 0.85; }
.save-btn:disabled { opacity: 0.4; cursor: default; }

.panel-timestamp {
  margin-top: 12px;
  font-size: 0.7rem;
  color: #777;
  text-align: right;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

/* ── Filters panel ──────────────────────────────────────────── */
#filters-panel {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  z-index: 998;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
#filters-panel.filters-open {
  max-height: 200px; /* tall enough for two rows of controls */
}

#filters-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px 28px;
  padding: 12px 16px 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}
.filter-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  white-space: nowrap;
}
.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.filter-radio,
.filter-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
}
.filter-radio input,
.filter-check input {
  accent-color: var(--color-accent);
  cursor: pointer;
}

.filter-group-checks { min-width: 160px; }
.filter-checks { flex-direction: column; gap: 4px; }

/* Min/max location count row */
.filter-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-range-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.7rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.filter-range-label input[type="number"] {
  width: 68px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 0.82rem;
  font-family: inherit;
  -moz-appearance: textfield;
}
.filter-range-label input[type="number"]::-webkit-inner-spin-button,
.filter-range-label input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
}
.filter-range-sep {
  font-size: 0.9rem;
  color: #666;
  margin-top: 14px; /* align with input, not label */
}

#filters-reset {
  align-self: flex-end;
  margin-top: auto;
  background: transparent;
  color: #aaa;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
#filters-reset:hover { background: rgba(255,255,255,0.08); color: var(--color-text); }

/* Filters toggle button active state */
#filters-toggle.active {
  background: rgba(233, 69, 96, 0.15);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Push map + panel down when filters are open */
body.filters-visible #map,
body.filters-visible #detail-panel {
  top: calc(var(--topbar-h) + 132px);
}

/* Chain badge in detail panel */
.chain-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: rgba(233, 69, 96, 0.18);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 5px;
}

/* Leaflet overrides for dark theme */
.leaflet-container { background: #1a1a2e; }
.leaflet-control-zoom a {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}
