/* =========================================================================
   Crop Map — public drill-down map (publicmap app)
   Region → District → Upazila. Namespaced `pm-` so it never collides with the
   app-shell (custom.css) or the auth screens (auth.css). Reuses the canonical
   palette variables defined in custom.css.
   ========================================================================= */

* { box-sizing: border-box; }

html, body.pm-body {
  height: 100%;
  margin: 0;
}

.pm-body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-body, system-ui, sans-serif);
  color: var(--color-text, #1c2321);
  background: var(--color-bg, #f6f4ee);
}

/* ---------- header ---------- */
.pm-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  color: #eafaef;
  background: linear-gradient(135deg, var(--color-primary, #1f4d3a), var(--color-primary-dark, #163a2b));
  box-shadow: var(--shadow-md, 0 6px 20px rgba(28, 35, 33, 0.08));
  z-index: 500;
}

.pm-header__brand { display: flex; align-items: center; gap: 12px; }
.pm-header__logo { width: 42px; height: 42px; display: block; }
.pm-header__title { font-size: 19px; font-weight: 700; }
.pm-header__sub { font-size: 12.5px; color: rgba(234, 250, 239, 0.8); margin-top: 2px; }

.pm-header__login {
  color: #eafaef;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.pm-header__login:hover { background: rgba(255, 255, 255, 0.14); }

/* Which cropping season today falls in. Seasons carry a month+day window with
   no year, so this chip is resolved server-side on every request. It sits
   between the brand and the login link and folds away on narrow screens, where
   the header has no room to spare. */
.pm-header__season {
  margin-left: auto;
  margin-right: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  line-height: 1.25;
}
.pm-header__season-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(234, 250, 239, 0.75);
}
.pm-header__season-names { font-size: 14px; font-weight: 700; }
.pm-header__season-names small { font-weight: 500; opacity: 0.8; }

@media (max-width: 720px) {
  .pm-header__season { display: none; }
}


/* ---------- layout ---------- */
.pm-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

/* ---------- sidebar ---------- */
.pm-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  background: var(--color-surface, #fff);
  border-right: 1px solid var(--color-border, #e1ddcd);
  overflow: hidden;
}

.pm-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 20px;
}
.pm-breadcrumb button {
  border: none;
  background: none;
  color: var(--color-primary, #1f4d3a);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.pm-breadcrumb button:hover { background: var(--color-surface-muted, #eef1ea); }
.pm-breadcrumb .pm-crumb-sep { color: var(--color-text-muted, #5b6660); }
.pm-breadcrumb .pm-crumb-current { font-weight: 700; padding: 2px 4px; }

.pm-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted, #5b6660);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.pm-list-count { font-weight: 600; }

.pm-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}
.pm-list li {
  padding: 9px 12px;
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.12s ease;
}
.pm-list li:hover { background: var(--color-surface-muted, #eef1ea); }
.pm-list li.is-active {
  background: var(--color-primary, #1f4d3a);
  color: #fff;
}
.pm-list li .pm-list__code {
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  opacity: 0.7;
}

.pm-selected {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md, 10px);
  background: var(--color-warning-bg, #fbf1de);
  border: 1px solid var(--color-accent, #d4a017);
}
.pm-selected__label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--color-accent-dark, #b8860b);
}
.pm-selected__name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.pm-selected__code { font-family: var(--font-mono, monospace); font-size: 12px; color: var(--color-text-muted, #5b6660); }

/* ---------- map ---------- */
.pm-map-wrap { position: relative; min-height: 0; }
.pm-map { position: absolute; inset: 0; }

.pm-loading, .pm-empty {
  position: absolute;
  z-index: 600;
}
.pm-loading {
  top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(22, 58, 43, 0.9); color: #fff;
  padding: 6px 16px; border-radius: 999px; font-size: 13px;
}
.pm-empty {
  inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(246, 244, 238, 0.75); padding: 24px;
}
.pm-empty__card {
  max-width: 420px; text-align: center;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e1ddcd);
  border-radius: var(--radius-lg, 18px);
  padding: 28px; box-shadow: var(--shadow-lg, 0 20px 48px rgba(22, 58, 43, 0.18));
}
.pm-empty__card h3 { margin: 0 0 8px; color: var(--color-primary-dark, #163a2b); }
.pm-empty__card p { margin: 0; font-size: 14px; color: var(--color-text-muted, #5b6660); line-height: 1.6; }
.pm-empty__card code {
  font-family: var(--font-mono, monospace); font-size: 12.5px;
  background: var(--color-surface-muted, #eef1ea); padding: 1px 5px; border-radius: 4px;
}

/* ---------- polygon tooltip label ---------- */
.pm-label {
  background: rgba(22, 58, 43, 0.92);
  color: #fff; border: none; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; padding: 3px 8px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(28, 35, 33, 0.06));
}
.pm-label::before { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 800px) {
  .pm-layout { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
  .pm-sidebar { border-right: none; border-bottom: 1px solid var(--color-border, #e1ddcd); }
}
