/* ── Variabler ───────────────────────────────────────────────────────────── */
:root {
  --color-primary:   #0057A8;
  --color-accent:    #FECC02;
  --color-bg:        #F5F5F0;
  --color-surface:   #FFFFFF;
  --color-border:    #DDD;
  --color-text:      #1A1A1A;
  --color-muted:     #6B7280;
  --radius:          10px;
  --shadow:          0 2px 8px rgba(0,0,0,0.10);
  --header-h:        64px;
  --filter-h:        60px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  height: var(--header-h);
  background: #1a1f36;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.logo {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.logo span { color: var(--color-accent); }

.location-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}

#location-input {
  flex: 1;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  transition: background 0.15s, box-shadow 0.15s;
}
#location-input::placeholder { color: rgba(255,255,255,0.5); }
#location-input:focus {
  background: rgba(255,255,255,0.22);
  box-shadow: 0 0 0 2px rgba(254,204,2,0.5);
}

#locate-btn {
  background: var(--color-accent);
  color: #1a1f36;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
#locate-btn:hover { opacity: 0.85; }

#location-label {
  color: rgba(255,255,255,0.75);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Filterrad ───────────────────────────────────────────────────────────── */
#filter-bar {
  height: auto;
  min-height: var(--filter-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 99;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 0.78rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.filter-group select,
.filter-group input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-group select:focus,
.filter-group input[type="date"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,87,168,0.12);
}

#category-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cat-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
  color: var(--color-muted);
}
.cat-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cat-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.obscure-btn { border-style: dashed !important; }
.obscure-btn.active {
  background: #2c1a4e !important;
  border-color: #2c1a4e !important;
  color: #e0c8ff !important;
}
.cat-obscure { background: #ede0ff; color: #2c1a4e; }

.filter-sep {
  width: 1px;
  height: 24px;
  background: var(--color-border);
}

.poi-btn {
  padding: 6px 14px;
  border: 1.5px solid #A5D6A7;
  border-radius: 6px;
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: inherit;
}
.poi-btn.active { background: #2E7D32; color: #fff; border-color: #2E7D32; }
.poi-btn:hover:not(.active) { background: #C8E6C9; }

.filter-group--wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.poi-type-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid #A5D6A7;
  background: var(--color-bg);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
  font-family: inherit;
}

#natur-toggle-btn               { color: #43A047; border-color: #A5D6A7; }
#natur-toggle-btn.active        { background: #43A047; border-color: #43A047; color: #fff; }
#upplevelser-toggle-btn         { color: #F4511E; border-color: #FFCCBC; }
#upplevelser-toggle-btn.active  { background: #F4511E; border-color: #F4511E; color: #fff; }
#sevardigheter-toggle-btn        { color: #FB8C00; border-color: #FFE082; }
#sevardigheter-toggle-btn.active { background: #FB8C00; border-color: #FB8C00; color: #fff; }
#barn-toggle-btn                { color: #E67E00; border-color: #FFE0B2; }
#barn-toggle-btn.active         { background: #F39C12; border-color: #F39C12; color: #fff; }

#result-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--color-muted);
  white-space: nowrap;
}

#sort-select { display: none; }

/* ── Huvudinnehåll ───────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 24px 16px;
  gap: 12px;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
#panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: visible;   /* visible så date-range-dropdown inte klipps */
  border: 1px solid rgba(0,0,0,0.09);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.04),
    0 8px 32px rgba(0,0,0,0.08);
}

#panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border-radius: 0 0 15px 15px;
}

#panel #filter-bar {
  border-bottom: 1px solid rgba(0,0,0,0.09);
  border-radius: 16px 16px 0 0;
  background: #fafafa;
  padding: 7px 12px;
  gap: 8px;
  min-height: 0;
  position: relative;
  z-index: 1000;
}

#panel #filter-bar select,
#panel #filter-bar input[type="date"] {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  padding: 5px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
#panel #filter-bar select:hover,
#panel #filter-bar input[type="date"]:hover {
  border-color: var(--color-primary);
}

/* ── Datumväljare ────────────────────────────────────────────────────────── */
.date-range-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.date-range-picker:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(58,87,232,0.08);
}
.date-range-picker-icon { font-size: 0.95rem; opacity: 0.7; }

.date-range-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 560px;
}
.date-range-dropdown.hidden { display: none; }

.drp-calendars { display: flex; gap: 16px; }
.drp-month { flex: 1; min-width: 0; }
.drp-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.drp-month-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  text-transform: capitalize;
}
.drp-nav-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-muted);
  border-radius: 4px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.drp-nav-btn:hover { background: #f0f0f0; color: var(--color-text); }

.drp-grid { width: 100%; border-collapse: collapse; }
.drp-grid th {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--color-muted);
  text-align: center;
  padding: 2px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.drp-grid td { text-align: center; padding: 1px; }
.drp-day {
  width: 30px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--color-text);
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.drp-day:hover:not(:disabled) {
  background: rgba(58,87,232,0.1);
  color: var(--color-primary);
}
.drp-day:disabled { color: #ccc; cursor: default; }
.drp-day.drp-start,
.drp-day.drp-end {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}
.drp-day.drp-in-range {
  background: rgba(58,87,232,0.1);
  color: var(--color-primary);
  border-radius: 0;
}
.drp-day.drp-start { border-radius: 6px 0 0 6px; }
.drp-day.drp-end   { border-radius: 0 6px 6px 0; }
.drp-day.drp-start.drp-end { border-radius: 6px; }
.drp-day.drp-today { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.drp-day.drp-hover-range {
  background: rgba(58,87,232,0.08);
  color: var(--color-primary);
  border-radius: 0;
}
.drp-day.drp-hover-end:not(:disabled) {
  background: rgba(58,87,232,0.18);
  color: var(--color-primary);
  font-weight: 600;
  border-radius: 0 6px 6px 0;
}

.drp-divider { width: 1px; background: rgba(0,0,0,0.08); flex-shrink: 0; }

.drp-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(0,0,0,0.07);
  padding-top: 10px;
}
.drp-clear-btn {
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--color-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.drp-clear-btn:hover { border-color: #c00; color: #c00; }

/* ── Suggestion-panel ────────────────────────────────────────────────────── */
#suggestion-panel {
  flex-shrink: 0;
  border-radius: 12px;
}

/* ── Listrubrik ──────────────────────────────────────────────────────────── */
#list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  flex-shrink: 0;
}
.list-heading {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
#list-header #result-count {
  font-size: 0.72rem;
  color: var(--color-muted);
  margin-left: auto;
}

/* ── Lista ───────────────────────────────────────────────────────────────── */
#list-section {
  flex: 1;
  min-width: 0;
  flex-shrink: 0;
  order: -1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-right: 1px solid rgba(0,0,0,0.07);
}

#list-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ddd transparent;
}

#event-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* Laddar-spinner */
#loading {
  display: none;
  text-align: center;
  padding: 40px;
  color: var(--color-muted);
  font-size: 0.9rem;
}
#loading.active { display: block; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tomt tillstånd */
#empty-state {
  display: none;
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}
#empty-state.active { display: block; }
#empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--color-text); }

/* ── Karta ───────────────────────────────────────────────────────────────── */
#map-section {
  flex: 1;
  min-width: 0;
  height: auto;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  border: none;
}

#map {
  width: 100%;
  height: 100%;
  background: #e8e8e8;
}

/* Mobil-toggle */
#view-toggle {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 500;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--color-border);
}
#view-toggle button {
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--color-muted);
}
#view-toggle button.active {
  background: var(--color-primary);
  color: #fff;
}

/* ── Evenemangskort (kompakta, horisontella) ─────────────────────────────── */
.event-card {
  flex-direction: row;
  align-items: center;
  padding: 7px 12px;
  gap: 10px;
  border-bottom: 1px solid #f2f0ec;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
  display: flex;
  overflow: hidden;
}
.event-card:last-child { border-bottom: none; }
.event-card:hover { background: #f8f7f4; }
.event-card.highlighted {
  background: #eef3ff;
  border-left-color: var(--color-primary);
}

.card-thumb {
  width: 52px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #ede9e4;
}
.card-thumb-placeholder {
  width: 52px;
  height: 46px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #ede9e4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.card-top {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 1px;
}
.card-date {
  font-size: 0.68rem;
  color: var(--color-muted);
  margin-left: auto;
  white-space: nowrap;
}
.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-venue {
  font-size: 0.72rem;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-description {
  font-size: 0.72rem;
  color: #777;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 1px;
}
.card-link {
  font-size: 0.68rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-top: 2px;
  align-self: flex-start;
  opacity: 0.8;
}
.card-link:hover { opacity: 1; text-decoration: underline; }

/* Kategoribadge – dold i listvy, synlig i popup */
.category-badge {
  display: none;
  font-size: 0.63rem;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
}
.cat-konsert    { background: #FFE5E5; color: #C0392B; }
.cat-teater     { background: #F0E6FF; color: #6C3483; }
.cat-utställning{ background: #FFF3E0; color: #D35400; }
.cat-festival   { background: #E8F8E8; color: #1E8449; }
.cat-dans       { background: #E8F0FF; color: #154360; }
.cat-barn       { background: #FEF9E7; color: #7D6608; }
.cat-helgedom   { background: #E0F7FA; color: #006064; }
.cat-övrigt     { background: #F0F0F0; color: #555; }

.date-more {
  font-size: 0.65rem;
  font-weight: 600;
  background: #e8edf5;
  color: var(--color-primary);
  border-radius: 6px;
  padding: 1px 4px;
  vertical-align: middle;
}

.obscure-badge {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}

/* Osynliga kortelement (finnes i DOM men används ej i aktuell layout) */
.card-image, .card-image-placeholder { display: none; }
.card-body { padding: 0; }
.card-footer { display: none; }

.btn-ticket {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  border-radius: 7px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-ticket:hover { background: #004291; }

/* ── Ortväljare ──────────────────────────────────────────────────────────── */
.city-picker-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  font-family: inherit;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-left: auto;
}
.city-picker-pill:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(58,87,232,0.08);
}
.city-picker-icon { font-size: 0.95rem; opacity: 0.7; }

.locate-btn-icon {
  padding: 5px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.locate-btn-icon:hover:not(:disabled) { border-color: var(--color-primary); }
.locate-btn-icon:disabled { opacity: 0.6; cursor: wait; }

.city-picker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ddd transparent;
}
.city-picker-dropdown.hidden { display: none; }

.city-section-label {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  padding: 10px 14px 4px;
}
.city-divider { height: 1px; background: rgba(0,0,0,0.07); margin: 6px 0; }
.city-option {
  padding: 7px 14px;
  font-size: 0.83rem;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.1s;
}
.city-option:hover, .city-option.active {
  background: rgba(58,87,232,0.08);
  color: var(--color-primary);
}

/* ── Leaflet popup ───────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  min-width: 220px;
}
.popup-content { padding: 4px; }
.popup-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.popup-date  { font-size: 0.8rem; color: var(--color-muted); margin-bottom: 2px; }
.popup-dates {
  max-height: 100px;
  overflow-y: auto;
  margin-bottom: 4px;
  scrollbar-width: thin;
}
.popup-venue { font-size: 0.8rem; color: var(--color-muted); margin-bottom: 8px; }
.popup-badge { display: inline-block; margin-bottom: 8px; }
.popup-btn {
  display: block;
  padding: 7px 14px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}
.popup-btn:hover { background: #004291; }

/* ── Responsiv ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { overflow: auto; }

  .logo { font-size: 1.1rem; }
  header { padding: 0 12px; gap: 10px; }
  #location-label { display: none; }

  #filter-bar { gap: 8px; padding: 8px 12px; }

  #main-content { padding: 0; gap: 0; }

  #panel {
    flex-direction: column;
    border-radius: 0;
    border: none;
    box-shadow: none;
    flex: 1;
  }
  #panel-body {
    flex-direction: column;
    flex: 1;
    border-radius: 0;
  }

  .date-range-dropdown { min-width: 280px; left: 0; right: 0; }
  .drp-calendars { flex-direction: column; }

  #map-section {
    height: 52vw;
    min-height: 200px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }
  #map-section.hidden { display: none; }

  #list-section {
    width: auto;
    order: 0;
    border-right: none;
    flex: 1;
  }
  #list-section.hidden { display: none; }

  #suggestion-panel { border-radius: 0; margin: 0; }

  #view-toggle { display: flex; }

  .city-picker-dropdown { right: 0; left: auto; min-width: 180px; }
}
