:root {
  --bg: #0f1320;
  --panel: #171c2e;
  --panel-2: #1f2640;
  --text: #e8ebf5;
  --muted: #9aa3bd;
  --accent: #4f7cff;
  --accent-2: #6c4fff;
  --danger: #ff5c72;
  --border: #2a3252;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* Pasek przewijania w kolorach strony */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--panel-2);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 8px; }
::-webkit-scrollbar-thumb {
  background-image: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 8px;
  border: 2px solid var(--panel-2);
}
::-webkit-scrollbar-thumb:hover { background-image: linear-gradient(var(--accent-2), var(--accent)); }
::-webkit-scrollbar-corner { background: var(--panel-2); }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 0.2px; }
.hint { margin: 0; font-size: 13px; opacity: 0.92; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-light {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-light:hover { background: rgba(255, 255, 255, 0.3); }
.hidden { display: none !important; }

/* Layout */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 340px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow-x: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-head h2 { margin: 0; font-size: 16px; }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

.filters { display: flex; flex-direction: column; gap: 8px; }
.date-filter { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* Zakres dat (od–do) */
.date-range { display: flex; flex-direction: column; gap: 5px; }
.date-range-label { font-size: 12px; color: var(--muted); }
.date-range-inputs { display: flex; gap: 8px; }
.date-range-inputs label {
  flex: 1 1 0;
  min-width: 0;            /* pozwala polom kurczyć się poniżej zawartości (iOS Safari) */
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}
/* Natywne pola daty na iOS nie kurczą się same — wymuszamy dopasowanie */
.date-range-inputs input[type="date"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding-left: 9px;
  padding-right: 6px;
}
.date-range-inputs input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

/* Legenda */
.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 2px 4px;
  flex-wrap: wrap;
}
.legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-today { background: #2ecc71; }
.dot-future { background: #f1c40f; }
.dot-past { background: #95a5a6; }
.dot-nodate { background: #fff; border: 1px solid #777; }

.btn-ghost.small { padding: 7px 10px; font-size: 12px; }

/* Status tag */
.status-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}
.status-today { background: #2ecc71; color: #06351a; }
.status-future { background: #f1c40f; color: #4a3b00; }
.status-past { background: #95a5a6; color: #1f2630; }
.status-nodate { background: #fff; color: #1f2630; border: 1px solid #999; }

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Event list */
.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.event-item:hover { transform: translateX(2px); border-color: var(--accent); }
.event-item .ev-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.event-item .ev-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
.event-item .ev-cat { font-size: 12px; }

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 8px;
}

/* Map */
.map-wrap { flex: 1; min-width: 0; }
#map { width: 100%; height: 100%; }

/* Logo w panelu bocznym (u góry) */
.sidebar-logo {
  display: flex;
  justify-content: center;
  padding-bottom: 12px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.site-logo {
  width: 100%;
  max-width: 200px;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Stopka */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.footer-left { opacity: 0.85; display: inline-flex; align-items: center; gap: 8px; }
.footer-logo { height: 22px; width: auto; vertical-align: middle; }
.footer-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  padding: 0;
}
.footer-link:hover { color: var(--text); }
.footer-login { text-decoration: underline; }
.admin-hint { color: var(--accent); }

/* Buttons */
.btn-primary, .btn-ghost {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f6cf0; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-card h3 { margin: 0 0 16px; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-card .row { display: flex; gap: 12px; }
.modal-card .row label { flex: 1; }
.coords { font-size: 13px; color: var(--muted); margin: 2px 0; }
.hint-small { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* Checkbox „Dodaj oceny" */
.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
  font-size: 14px !important;
  cursor: pointer;
}
.check-row input { width: auto; }

/* Widżet ocen w formularzu */
.ratings-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.rating-row { display: flex; align-items: center; gap: 10px; }
.rating-label { flex: 1; font-size: 13px; }
.stars { display: flex; gap: 2px; }
.stars .star {
  font-size: 22px;
  line-height: 1;
  color: #5a627e;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.stars .star.on { color: #f1c40f; }
.stars .star:hover { transform: scale(1.2); }
.star-count { font-size: 12px; color: var(--muted); width: 30px; text-align: right; }

/* Wyświetlanie ocen (dymek / lista) */
.ratings-view { margin-bottom: 8px; }
.rating-view {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #444;
}
.stars-static { color: #f1c40f; letter-spacing: 1px; }
.rating-num { color: #777; }

/* Cena */
.price-tag { letter-spacing: 1px; }

/* Menedżer kategorii */
.cat-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.cat-icon-cell { width: 26px; text-align: center; flex: 0 0 auto; }
.cat-name-cell { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; word-break: break-word; }
.cat-actions { display: flex; gap: 6px; }
.btn-mini {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}
.btn-mini:hover { border-color: var(--accent); }
.btn-mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.modal-card h4 { margin: 6px 0 10px; font-size: 14px; color: var(--muted); }

/* Wybierak emotek */
.emoji-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.emoji-preview {
  font-size: 26px;
  line-height: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.emoji-opt {
  font-size: 20px;
  text-align: center;
  padding: 4px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.08s ease;
}
.emoji-opt:hover { background: rgba(255, 255, 255, 0.08); transform: scale(1.15); }
.emoji-opt.on { background: var(--accent); }

@media (max-width: 760px) {
  .emoji-picker { grid-template-columns: repeat(8, 1fr); }
}

/* Wybór koloru tła kategorii */
.color-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.color-auto {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.color-auto input { width: auto; }
.color-pick { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.color-pick input[type="color"] {
  width: 46px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.color-pick input[type="color"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* Próbka koloru w liście kategorii */
.cat-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #888;
  flex: 0 0 auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ============================================================
   POPUP „IDZIEMY W MIASTO" — własny komponent-karta (Leaflet reset)
   ============================================================ */

/* Reset domyślnego wyglądu Leaflet */
.app-popup .leaflet-popup-content-wrapper {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  padding: 0;
  border-radius: 18px;
}
.app-popup .leaflet-popup-content {
  margin: 0;
  width: clamp(260px, 82vw, 340px) !important;
  line-height: 1.45;
}
.app-popup .leaflet-popup-tip {
  background: #141b2d;
  border: none;
  box-shadow: -2px 2px 10px rgba(108, 79, 255, 0.18);
}
.app-popup a.leaflet-popup-close-button {
  color: rgba(232, 235, 245, 0.55);
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  font-size: 20px;
  font-weight: 400;
}
.app-popup a.leaflet-popup-close-button:hover { color: #fff; background: transparent; }

/* Karta */
.ip-card {
  background: #141b2d;
  border: 1px solid rgba(108, 79, 255, 0.35);
  border-radius: 18px;
  box-shadow: 0 0 15px rgba(79, 124, 255, 0.15), 0 0 35px rgba(108, 79, 255, 0.15);
  padding: 14px 16px 16px;
  color: #e8ebf5;
  animation: ipIn 0.24s ease both;
}
@keyframes ipIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sekcja 1 — ikona po lewej, treść po prawej */
.ip-top {
  display: flex;
  align-items: stretch; /* ikona rozciąga się na wysokość kolumny tekstu */
  gap: 12px;
  margin-bottom: 12px;
  padding-right: 22px; /* miejsce na przycisk zamknięcia */
}
.ip-main { flex: 1 1 auto; min-width: 0; }
.ip-cat {
  width: 54px;
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(79, 124, 255, 0.25), rgba(108, 79, 255, 0.25));
  border: 1px solid rgba(108, 79, 255, 0.35);
}
.ip-cat-img { width: 34px; height: 34px; border-radius: 12px; object-fit: cover; }

/* Ocena — własny wiersz pod kategorią (nie koliduje z przyciskiem zamknięcia) */
.ip-rating { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #f1c40f; margin: 4px 0 0; }
.ip-rating .ip-stars { letter-spacing: 1px; }
.ip-rating b { color: #e8ebf5; font-weight: 700; }

/* Sekcja 2 — informacje */
.ip-title { margin: 0 0 2px; font-size: 18px; font-weight: 800; line-height: 1.2; color: #fff; }
.ip-sub { font-size: 11px; color: #9aa3bd; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.ip-desc-wrap { margin: 0 0 11px; }
.ip-desc {
  margin: 0;
  font-size: 13px;
  color: #c7cde0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ip-desc.open {
  display: block;
  -webkit-line-clamp: unset;
  overflow-y: auto;
  padding-right: 4px;
}
.ip-more {
  margin-top: 4px;
  padding: 0;
  background: none;
  border: none;
  color: #8aa0ff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ip-more:hover { text-decoration: underline; }
.ip-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ip-row { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.ip-row-label { color: #9aa3bd; }
.ip-row-label::after { content: ":"; }
.ip-row-val { color: #e8ebf5; font-weight: 600; }
.ip-muted { color: #9aa3bd; }

/* Sekcja 3 — przyciski akcji */
.ip-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ip-btn {
  flex: 1 1 auto;
  min-width: 116px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff !important;
  text-decoration: none;
  background: linear-gradient(135deg, #4f7cff, #6c4fff);
  box-shadow: 0 4px 14px rgba(79, 124, 255, 0.25);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.ip-btn:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 22px rgba(108, 79, 255, 0.45);
  filter: brightness(1.06);
}

/* Akcje administratora */
.ip-admin { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.ip-admin-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #c7cde0;
  border-radius: 10px;
  padding: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.ip-admin-btn:hover { border-color: #4f7cff; color: #fff; }
.ip-admin-btn.danger:hover { border-color: #ff5c72; color: #ff5c72; }

/* ---------- WARIANT 2: Premium Travel ---------- */
.app-popup.theme-premium .leaflet-popup-tip { background: #16203a; }
.app-popup.theme-premium .ip-card {
  background: #16203a;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}
.app-popup.theme-premium .ip-cat {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.22), rgba(79, 124, 255, 0.22));
  border-color: rgba(45, 212, 191, 0.35);
}
.app-popup.theme-premium .ip-rating { color: #f5c56b; }
.app-popup.theme-premium .ip-btn {
  background: linear-gradient(135deg, #2dd4bf, #4f7cff);
  box-shadow: 0 6px 18px rgba(45, 212, 191, 0.22);
}
.app-popup.theme-premium .ip-btn:hover { box-shadow: 0 8px 24px rgba(45, 212, 191, 0.38); }

/* ---------- WARIANT 3: Neon City ---------- */
.app-popup.theme-neon .leaflet-popup-tip { background: #0e1322; box-shadow: -2px 2px 14px rgba(108, 79, 255, 0.5); }
.app-popup.theme-neon .ip-card {
  background: #0e1322;
  border: 1px solid rgba(108, 79, 255, 0.65);
  box-shadow: 0 0 18px rgba(79, 124, 255, 0.45), 0 0 48px rgba(108, 79, 255, 0.45);
}
.app-popup.theme-neon .ip-title { text-shadow: 0 0 12px rgba(108, 79, 255, 0.6); }
.app-popup.theme-neon .ip-sub { color: #8a93ff; }
.app-popup.theme-neon .ip-cat {
  border-color: rgba(79, 124, 255, 0.8);
  box-shadow: inset 0 0 12px rgba(79, 124, 255, 0.5);
}
.app-popup.theme-neon .ip-btn {
  background: linear-gradient(135deg, #5b8cff, #8a5bff);
  box-shadow: 0 0 16px rgba(108, 79, 255, 0.6);
}
.app-popup.theme-neon .ip-btn:hover { box-shadow: 0 0 24px rgba(108, 79, 255, 0.85); }

/* Błąd / modal małej karty */
.error { color: var(--danger); font-size: 13px; margin: 0; }
.small-card { width: 340px; }

/* Pulsująca pinezka „dziś" */
.pin-pulse { animation: pinpulse 1.6s ease-in-out infinite; }
@keyframes pinpulse {
  0%, 100% { box-shadow: 0 3px 8px rgba(0,0,0,.4); }
  50% { box-shadow: 0 3px 8px rgba(0,0,0,.4), 0 0 0 8px rgba(46, 204, 113, 0.35); }
}

/* Responsywność — telefony */
@media (max-width: 760px) {
  /* Cała strona przewija się pionowo zamiast sztywnego 100vh */
  html, body { height: auto; }
  body { min-height: 100vh; }
  .layout { flex-direction: column; min-height: 0; }

  /* Pasek górny: zwarty, przyciski mogą się zawijać */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }
  .btn-light { padding: 6px 10px; font-size: 12px; }
  .hint { display: none; }

  /* Logo w panelu: nieco mniejsze na telefonie */
  .site-logo { max-width: 160px; }

  /* Mapa na górze, stała wysokość */
  .map-wrap { order: -1; height: 50vh; min-height: 280px; flex: none; }
  #map { height: 100%; }

  /* Panel pod mapą — rośnie z treścią, strona się przewija */
  .sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .event-list { overflow: visible; flex: none; }

  /* Formularze: data i godzina jedna pod drugą */
  .modal-card .row { flex-direction: column; gap: 12px; }
  .modal-card { padding: 18px; }

  .emoji-picker { grid-template-columns: repeat(8, 1fr); }
}

/* Bardzo wąskie ekrany */
@media (max-width: 380px) {
  .legend { gap: 8px; font-size: 11px; }
  .emoji-picker { grid-template-columns: repeat(7, 1fr); }
}
