/* ═══════════════════════════════════════════════════════════
   MDW 2026 — Main Application Styles
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text2: #888;
  --accent: #4ecdc4;
  --accent2: #ff6b6b;
  --free: #4ecdc4;
  --prereg: #ffd93d;
  --invite: #ff6b6b;
  --selected: #ffd700;

  /* Interest colors */
  --c-like: #ff6b6b;
  --c-bookmark: #ffd93d;
  --c-planned: #4ecdc4;
  --c-visited: #a78bfa;
}

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

body {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ─── Layout ─── */

.app {
  display: grid;
  grid-template-columns: 320px 1fr 380px;
  grid-template-rows: 56px 1fr;
  height: 100vh;
}

.header {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
}
.header h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.5px; }
.header h1 span { color: var(--accent); }
.header .stats { display: flex; gap: 16px; font-size: 11px; color: var(--text2); }
.header .stats b { color: var(--text); }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

/* ─── Filters ─── */

.filter-section { margin-bottom: 16px; }
.filter-section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 8px;
}

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 4px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

/* Day pills */
.day-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.day-pill {
  padding: 4px 8px;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.day-pill:hover { border-color: var(--accent); }
.day-pill.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* Chip list (district, category) */
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 3px 8px;
  font-size: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.chip .count { color: var(--text2); margin-left: 4px; }
.chip.active .count { color: rgba(0,0,0,0.5); }

/* Access pills */
.access-pills { display: flex; gap: 4px; }
.access-pill {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}
.access-pill:hover { border-color: var(--text2); }
.access-pill.active[data-access="free"] { background: var(--free); color: var(--bg); border-color: var(--free); }
.access-pill.active[data-access="pre-registration"] { background: var(--prereg); color: var(--bg); border-color: var(--prereg); }
.access-pill.active[data-access="invitation"] { background: var(--invite); color: var(--bg); border-color: var(--invite); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-top: 4px;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] { accent-color: var(--accent); }

/* Time range slider */
.time-range-wrap {
  position: relative;
  height: 36px;
  margin-top: 4px;
}
.time-range-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 36px;
  background: none;
  pointer-events: none;
  outline: none;
}
.time-range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}
.time-track {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
}
.time-track-fill {
  position: absolute;
  top: 16px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}
.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
}
.time-value {
  font-size: 12px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 4px;
  font-weight: 600;
}
.time-presets {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.time-preset {
  padding: 3px 8px;
  font-size: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text2);
}
.time-preset:hover { border-color: var(--accent); color: var(--text); }

/* ─── Map ─── */

.map-container { position: relative; overflow: hidden; background: var(--bg); }
#map { width: 100%; height: 100%; background: var(--bg); }

/* Override Leaflet defaults — empty tile slots during load flash gray/white.
   Force dark bg at every layer + on the <img> tiles themselves. */
.leaflet-container,
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-layer,
.leaflet-tile-container,
.leaflet-pane {
  background: #0a0a0a !important;
}
.leaflet-tile {
  background: #0a0a0a !important;
}
.map-count {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: rgba(10,10,10,0.85);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 4px;
  backdrop-filter: blur(8px);
}
.map-count b { color: var(--accent); }

/* Day legend (shown in Planning mode) */
.day-legend {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 999;
  background: rgba(10,10,10,0.85);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 10px;
  border-radius: 4px;
  backdrop-filter: blur(8px);
}
.day-legend.active { display: block; }
.day-legend h4 {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}
.day-legend .dl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.day-legend .dl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.4);
}
.day-legend .dl-label {
  color: var(--text);
  font-size: 10px;
}
.day-legend .dl-count {
  color: var(--text2);
  font-size: 9px;
  margin-left: auto;
}

/* ─── Timeline strip (bottom, Planning mode) ─── */

.timeline-strip {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 998;
  background: rgba(10,10,10,0.92);
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  backdrop-filter: blur(8px);
  font-size: 10px;
}
.timeline-strip.active { display: block; }

.tl-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.tl-day-chip {
  padding: 3px 10px;
  font-size: 10px;
  font-family: inherit;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 3px;
  cursor: pointer;
}
.tl-day-chip:hover { color: var(--text); }
.tl-day-chip.active { font-weight: 600; }

.tl-summary {
  margin-left: auto;
  color: var(--text2);
  font-size: 10px;
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text2);
  margin-bottom: 2px;
  padding: 0 2px;
}
.tl-tick { text-align: center; }

.tl-track {
  position: relative;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.tl-gap {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255,217,61,0.08),
    rgba(255,217,61,0.08) 6px,
    transparent 6px,
    transparent 12px
  );
  border-left: 1px dashed rgba(255,217,61,0.3);
  border-right: 1px dashed rgba(255,217,61,0.3);
  pointer-events: none;
}

.tl-block {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 4px;
  opacity: 0.9;
  transition: opacity 0.1s;
  z-index: 2;
}
.tl-block:hover { opacity: 1; }
.tl-block-label {
  font-size: 9px;
  color: #000;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ─── Event list panel ─── */

.panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.panel-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text2);
}

.event-list { flex: 1; overflow-y: auto; }

.event-card {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.event-card:hover { background: var(--surface2); }
.event-card.active { background: var(--surface2); border-left: 3px solid var(--accent); }
.ev-title { font-size: 12px; font-weight: 500; margin-bottom: 3px; line-height: 1.3; }
.ev-title .star { color: var(--selected); font-size: 10px; }
.ev-meta { font-size: 10px; color: var(--text2); }
.ev-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.ev-tag {
  font-size: 9px;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text2);
}

/* ─── Detail overlay ─── */

.detail-overlay {
  display: none;
  position: fixed;
  top: 0; right: 0;
  width: 420px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 1000;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}
.detail-overlay.open { display: block; }

.detail-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 28px; height: 28px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-content { padding: 16px; }
.detail-content h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-right: 40px;
  line-height: 1.4;
}
.det-desc { font-size: 12px; line-height: 1.6; color: var(--text2); margin-bottom: 16px; }
.det-row { display: flex; gap: 8px; font-size: 11px; margin-bottom: 6px; }
.det-label { color: var(--text2); min-width: 70px; }
.det-link { color: var(--accent); }

/* Schedule table in detail */
.sched-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
  margin-top: 12px;
}
.sched-table th {
  text-align: left;
  color: var(--text2);
  font-weight: normal;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.sched-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.abadge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
}
.abadge-free { background: var(--free); color: var(--bg); }
.abadge-prereg { background: var(--prereg); color: var(--bg); }
.abadge-invite { background: var(--invite); color: var(--bg); }

/* ─── Interest UI (in detail + sidebar) ─── */

.interest-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}
.int-btn {
  flex: 1;
  padding: 6px 0;
  font-family: inherit;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.int-btn:hover { border-color: var(--text); color: var(--text); }
.int-btn.active-like     { background: #ff6b6b22; border-color: var(--c-like);     color: var(--c-like); }
.int-btn.active-bookmark { background: #ffd93d22; border-color: var(--c-bookmark); color: var(--c-bookmark); }
.int-btn.active-planned  { background: #4ecdc422; border-color: var(--c-planned);  color: var(--c-planned); }
.int-btn.active-visited  { background: #a78bfa22; border-color: var(--c-visited);  color: var(--c-visited); }

/* Plan form */
.plan-form {
  display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 14px;
}
.plan-form.open { display: block; }
.plan-form label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 3px;
  margin-top: 8px;
}
.plan-form label:first-child { margin-top: 0; }
.plan-form select,
.plan-form input[type="time"],
.plan-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 3px;
  outline: none;
}
.plan-form textarea { height: 48px; resize: vertical; }
.plan-form .plan-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.plan-form .plan-save {
  flex: 1;
  padding: 6px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}
.plan-form .plan-cancel {
  padding: 6px 12px;
  background: var(--surface);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

/* Rating stars */
.rating-stars { display: inline-flex; gap: 2px; }
.rating-star {
  cursor: pointer;
  font-size: 14px;
  color: var(--border);
  transition: color 0.1s;
}
.rating-star.filled { color: var(--c-bookmark); }
.rating-star:hover { color: var(--c-bookmark); }

/* Interest indicator dot on event cards */
.ev-interest {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.ev-interest-like     { background: var(--c-like); }
.ev-interest-bookmark { background: var(--c-bookmark); }
.ev-interest-planned  { background: var(--c-planned); }
.ev-interest-visited  { background: var(--c-visited); }

/* Header interest counts */
.header-interests {
  display: flex;
  gap: 10px;
  font-size: 11px;
  margin-left: auto;
  align-items: center;
}
.header-interests a {
  color: var(--text2);
  text-decoration: none;
  transition: color 0.15s;
}
.header-interests a:hover { color: var(--text); }
.hi-like     { color: var(--c-like)     !important; }
.hi-bookmark { color: var(--c-bookmark) !important; }
.hi-planned  { color: var(--c-planned)  !important; }
.hi-visited  { color: var(--c-visited)  !important; }

/* Interest filter pills in sidebar */
.interest-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.interest-pill {
  padding: 3px 8px;
  font-size: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}
.interest-pill:hover { border-color: var(--text); }
.interest-pill.active-like     { background: #ff6b6b33; border-color: var(--c-like);     color: var(--c-like); }
.interest-pill.active-bookmark { background: #ffd93d33; border-color: var(--c-bookmark); color: var(--c-bookmark); }
.interest-pill.active-planned  { background: #4ecdc433; border-color: var(--c-planned);  color: var(--c-planned); }
.interest-pill.active-visited  { background: #a78bfa33; border-color: var(--c-visited);  color: var(--c-visited); }

.planner-link {
  display: block;
  text-align: center;
  padding: 8px;
  margin-top: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}
.planner-link:hover { border-color: var(--accent); }

/* ─── Leaflet overrides ─── */

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: 6px !important;
  border: 1px solid var(--border) !important;
  padding: 2px !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { font-family: inherit !important; font-size: 12px !important; margin: 10px 12px !important; min-width: 220px; }

/* Compact event popup */
.popup-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
  cursor: pointer;
}
.popup-title:hover { color: var(--accent); }
.popup-venue {
  font-size: 10px;
  color: var(--text2);
  margin-bottom: 8px;
  line-height: 1.3;
}
.popup-actions {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.popup-btn {
  flex: 1;
  padding: 4px 0;
  font-family: inherit;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
}
.popup-btn:hover { border-color: var(--text); color: var(--text); }
.popup-btn.active-like     { background: #ff6b6b22; border-color: var(--c-like);     color: var(--c-like); }
.popup-btn.active-bookmark { background: #ffd93d22; border-color: var(--c-bookmark); color: var(--c-bookmark); }
.popup-btn.active-planned  { background: #4ecdc422; border-color: var(--c-planned);  color: var(--c-planned); }
.popup-btn.active-visited  { background: #a78bfa22; border-color: var(--c-visited);  color: var(--c-visited); }

/* Inline plan form in popup */
.popup-plan {
  display: none;
  margin-top: 6px;
  padding: 8px;
  background: var(--surface2);
  border-radius: 3px;
  border: 1px solid var(--border);
}
.popup-plan.open { display: block; }
.popup-plan-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.popup-plan select, .popup-plan input[type="time"] {
  flex: 1;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  border-radius: 2px;
  outline: none;
}
.popup-plan-save {
  width: 100%;
  padding: 4px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 2px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.popup-sign-in {
  font-size: 10px;
  color: var(--text2);
  text-align: center;
  padding: 4px;
}
.popup-sign-in a { color: var(--accent); cursor: pointer; }

/* ─── Scrollbar ─── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Responsive ─── */

@media (max-width: 1100px) {
  .app { grid-template-columns: 260px 1fr 300px; }
}
