:root {
  --sidebar-width: 280px;

  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;

  --text: #172033;
  --muted: #64748b;
  --border: #e2e8f0;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.17);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --transition: 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Vazir, Tahoma, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.collection-item:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.34);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* -------------------------------------------------------------------------- */
/*                                Main layout                                 */
/* -------------------------------------------------------------------------- */

.map-page {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  z-index: 1000;

  display: flex;
  flex-direction: column;

  background: rgba(255, 255, 255, 0.97);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-md);

  overflow: hidden;

  transition:
    width var(--transition),
    min-width var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

.map-area {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

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

/* -------------------------------------------------------------------------- */
/*                                Sidebar header                              */
/* -------------------------------------------------------------------------- */

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;

  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  direction: ltr;
  text-transform: uppercase;
}

.sidebar-header h1 {
  margin: 0;

  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.4px;
}

.sidebar-subtitle {
  margin: 6px 0 0;

  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);

  transition:
    color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
  transform: translateX(2px);
}

.icon-button svg,
.open-sidebar-button svg,
.map-button svg {
  width: 20px;
  height: 20px;

  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

/* -------------------------------------------------------------------------- */
/*                                  Filters                                   */
/* -------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 16px 18px;
  border-bottom: 1px solid var(--border);

  background: linear-gradient(180deg,
      rgba(248, 250, 252, 0.85),
      rgba(255, 255, 255, 0.92));
}

.search-box {
  position: relative;

  display: flex;
  align-items: center;

  height: 44px;
  padding: 0 12px;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;

  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.search-box:focus-within {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.search-icon {
  width: 18px;
  height: 18px;
  margin-left: 9px;

  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.search-box input {
  width: 100%;
  min-width: 0;

  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;

  font-size: 13px;
}

.search-box input::placeholder {
  color: #94a3b8;
}

.clear-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 24px;
  height: 24px;
  margin-right: 4px;

  color: var(--muted);
  background: #f1f5f9;
  border: 0;
  border-radius: 50%;

  font-size: 18px;
  line-height: 1;

  transition:
    background 160ms ease,
    color 160ms ease;
}

.clear-search:hover {
  color: var(--danger);
  background: #fee2e2;
}

.select-field {
  display: flex;
  flex-direction: column;
  gap: 6px;

  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.select-field select {
  height: 40px;
  padding: 0 11px;

  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;

  font-size: 12px;

  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.select-field select:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;

  color: var(--muted);
  font-size: 12px;
}

.text-button {
  padding: 4px 0;

  color: var(--primary);
  background: transparent;
  border: 0;

  font-size: 12px;
  font-weight: 800;
}

.text-button:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* -------------------------------------------------------------------------- */
/*                                Collection list                             */
/* -------------------------------------------------------------------------- */

.collection-list {
  flex: 1;
  min-height: 0;
  padding: 12px;

  overflow-y: auto;
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}

.collection-list::-webkit-scrollbar {
  width: 7px;
}

.collection-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.collection-list::-webkit-scrollbar-track {
  background: transparent;
}

.collection-item {
  display: flex;
  align-items: center;
  gap: 11px;

  width: 100%;
  margin-bottom: 9px;
  padding: 11px;

  background: var(--surface);
  border: 1px solid #edf1f6;
  border-radius: 14px;

  transition:
    transform 170ms ease,
    border-color 170ms ease,
    box-shadow 170ms ease,
    background 170ms ease;
}

.collection-item:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.collection-item.active {
  background: linear-gradient(135deg, #eef2ff, #ffffff);
  border-color: #818cf8;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.12);
}

.collection-logo,
.selected-card-logo,
.map-popup-logo {
  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  color: #475569;
  background: #eef2f7;
  font-size: 15px;
  font-weight: 900;
}

.collection-logo {
  width: 43px;
  min-width: 43px;
  height: 43px;
  border-radius: 12px;
}

.collection-logo img,
.selected-card-logo img,
.map-popup-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-info {
  flex: 1;
  min-width: 0;
}

.collection-name {
  display: block;

  overflow: hidden;

  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.collection-description {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;

  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.collection-meta {
  display: flex;
  align-items: center;
  gap: 7px;

  margin-top: 7px;

  color: #94a3b8;
  font-size: 10px;
}

.collection-arrow {
  color: #cbd5e1;
  font-size: 24px;
  line-height: 1;

  transition:
    color 160ms ease,
    transform 160ms ease;
}

.collection-item:hover .collection-arrow,
.collection-item.active .collection-arrow {
  color: var(--primary);
  transform: translateX(-2px);
}

.verification-badge {
  display: inline-flex;
  align-items: center;

  padding: 3px 7px;
  border-radius: 999px;

  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.verification-badge.official {
  color: #1d4ed8;
  background: #dbeafe;
}

.verification-badge.premium {
  color: #b45309;
  background: #fef3c7;
}

.verification-badge.basic {
  color: #15803d;
  background: #dcfce7;
}

.verification-badge.none {
  color: #64748b;
  background: #f1f5f9;
}

.empty-state,
.list-loading,
.list-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 230px;
  padding: 30px 18px;

  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.list-error strong {
  color: var(--text);
  font-size: 14px;
}

.empty-state span,
.list-error span,
.list-loading span {
  font-size: 12px;
  line-height: 1.8;
}

.empty-state-icon {
  display: grid;
  place-items: center;

  width: 52px;
  height: 52px;

  color: #94a3b8;
  background: #f1f5f9;
  border-radius: 50%;

  font-size: 30px;
}

.list-error {
  color: #b91c1c;
}

.loading-spinner {
  width: 26px;
  height: 26px;

  border: 3px solid #e0e7ff;
  border-top-color: var(--primary);
  border-radius: 50%;

  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------------------------------------------------- */
/*                               Map controls                                 */
/* -------------------------------------------------------------------------- */

.map-topbar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 900;
}

.map-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  min-height: 40px;
  padding: 8px 14px;

  color: #334155;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);

  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;

  background: #94a3b8;
  border-radius: 50%;
}

.status-dot.is-loading {
  background: var(--primary);
  animation: pulse 900ms ease-in-out infinite;
}

.status-dot.is-success {
  background: var(--success);
}

.status-dot.is-warning {
  background: var(--warning);
}

.status-dot.is-error {
  background: var(--danger);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.75);
  }
}

.map-controls {
  position: absolute;
  right: 16px;
  bottom: 22px;
  z-index: 900;

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-button,
.open-sidebar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: #334155;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);

  transition:
    transform 160ms ease,
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.map-button {
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.map-button:hover,
.open-sidebar-button:hover {
  color: var(--primary);
  background: #ffffff;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.open-sidebar-button {
  position: absolute;
  top: 66px;
  right: 16px;
  z-index: 950;

  display: none;
  gap: 7px;

  height: 42px;
  padding: 0 13px;

  border-radius: 13px;

  font-size: 12px;
  font-weight: 800;
}

.open-sidebar-button.visible {
  display: inline-flex;
}

/* -------------------------------------------------------------------------- */
/*                               Selected card                                */
/* -------------------------------------------------------------------------- */

.selected-card {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 910;

  width: min(350px, calc(100% - 44px));
  padding: 16px;

  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);

  animation: card-in 220ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.selected-card-close {
  position: absolute;
  top: 9px;
  left: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 28px;
  height: 28px;

  color: var(--muted);
  background: #f8fafc;
  border: 0;
  border-radius: 50%;

  font-size: 19px;
  line-height: 1;
}

.selected-card-close:hover {
  color: var(--danger);
  background: #fee2e2;
}

.selected-card-content {
  display: flex;
  gap: 12px;
  padding-left: 22px;
}

.selected-card-logo {
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: 14px;
}

.selected-card-main {
  flex: 1;
  min-width: 0;
}

.selected-card-topline {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 2px;
}

.selected-card-title {
  overflow: hidden;

  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.selected-card-location {
  display: block;
  margin-top: 4px;

  color: var(--muted);
  font-size: 11px;
}

.selected-card-description {
  margin: 8px 0 0;

  color: #475569;
  font-size: 11px;
  line-height: 1.8;
}

.selected-card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  margin-top: 10px;

  color: var(--primary);
  text-decoration: none;

  font-size: 11px;
  font-weight: 900;
}

.selected-card-link:hover {
  color: var(--primary-hover);
}

/* -------------------------------------------------------------------------- */
/*                              Leaflet marker                                */
/* -------------------------------------------------------------------------- */

.custom-marker-wrapper {
  background: transparent;
  border: 0;
}

.marker-pin {
  position: relative;

  display: flex;
  align-items: flex-start;
  justify-content: center;

  width: 42px;
  height: 52px;

  transform-origin: bottom center;
  transition: transform 160ms ease;
}

.marker-pin svg {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  fill: #64748b;
  filter: drop-shadow(0 4px 5px rgba(15, 23, 42, 0.25));
}

.marker-pin.official svg {
  fill: #2563eb;
}

.marker-pin.premium svg {
  fill: #f59e0b;
}

.marker-pin.basic svg {
  fill: #16a34a;
}

.marker-pin.none svg {
  fill: #64748b;
}

.marker-pin.selected {
  transform: scale(1.18);
}

.marker-logo {
  position: relative;
  z-index: 2;
  top: 6px;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 26px;
  height: 26px;

  overflow: hidden;

  color: #475569;
  background: #ffffff;
  border-radius: 50%;

  font-size: 10px;
  font-weight: 900;
}

.marker-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -------------------------------------------------------------------------- */
/*                             Leaflet popup                                  */
/* -------------------------------------------------------------------------- */

.leaflet-popup-content-wrapper {
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  width: 270px !important;
  margin: 14px 16px;
}

.leaflet-popup-tip {
  box-shadow: 2px 2px 4px rgba(15, 23, 42, 0.08);
}

.map-popup {
  color: var(--text);
  font-family: Vazir, Tahoma, Arial, sans-serif;
}

.map-popup-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-popup-logo {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 11px;
}

.map-popup-title-wrap {
  min-width: 0;
}

.map-popup-title {
  display: block;

  overflow: hidden;

  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.map-popup-location {
  display: block;
  margin-top: 4px;

  color: var(--muted);
  font-size: 10px;
}

.map-popup-description {
  margin: 10px 0 0;

  color: #475569;
  font-size: 11px;
  line-height: 1.8;
}

.map-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  margin-top: 12px;
}

.map-popup-link {
  color: var(--primary);
  text-decoration: none;

  font-size: 11px;
  font-weight: 900;
}

.map-popup-link:hover {
  color: var(--primary-hover);
}

/* -------------------------------------------------------------------------- */
/*                              Cluster styling                               */
/* -------------------------------------------------------------------------- */

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(79, 70, 229, 0.2);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  display: flex;
  align-items: center;
  justify-content: center;

  color: #ffffff;
  background: var(--primary);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;

  font-family: Vazir, Tahoma, Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
}

/* -------------------------------------------------------------------------- */
/*                                Responsive                                  */
/* -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .map-page {
    position: relative;
    display: block;
  }

  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;

    width: min(var(--sidebar-width), 88vw);
    min-width: min(var(--sidebar-width), 88vw);

    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: min(var(--sidebar-width), 88vw);
    min-width: min(var(--sidebar-width), 88vw);

    opacity: 1;
    transform: translateX(105%);
    pointer-events: none;
  }

  .sidebar-header {
    padding-top: 18px;
  }

  .sidebar-subtitle {
    display: none;
  }

  .map-topbar {
    right: 12px;
    top: 12px;
  }

  .map-status {
    max-width: calc(100vw - 120px);
    font-size: 11px;
  }

  .open-sidebar-button {
    top: 12px;
    left: 12px;
  }

  .map-controls {
    right: 12px;
    bottom: 14px;
  }

  .selected-card {
    right: 12px;
    bottom: 14px;
    left: 12px;

    width: auto;
    max-width: none;
  }
}

.leaflet-fade-animated .leaflet-tile,
.leaflet-tile {
  transition: none !important;
  opacity: 1 !important;
}