
/* #######################   MAP   ########################## */

:root {
  --accent: #E85A2B;
  --accent-dim: #c44820;
  --accent-soft: #FDF0EB;
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface2: #F0EFE9;
  --border: #E2E0D8;
  --border-dark: #C8C5BA;
  --text-1: #1A1917;
  --text-2: #6B6860;
  --text-3: #9B9890;
  --success-bg: #EBF7EE;
  --success-text: #1A6B32;
  --danger-bg: #FDECEA;
  --danger-text: #A8290E;
  --warn-bg: #FEF6E4;
  --warn-text: #8A5C0A;
  --drawer-w: 380px;
  --header-h: 56px;
  --tabs-h: 44px;
  --font: 'Lato', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .10), 0 1px 4px rgba(0, 0, 0, .06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .14), 0 4px 12px rgba(0, 0, 0, .08);
  --transition: all .18s cubic-bezier(.4, 0, .2, 1);
}

/* ── Tabs ────────────────────────────────────────── */
.tabs-bar {
  /* height: var(--tabs-h); */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  margin-top: 30px;
  text-align: center;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 15px;
  font-weight: 400;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  position: relative;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  user-select: none;
  border-radius: 0;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text-1);
}

.tab.active {
  color: var(--primary-color);
  font-weight: 500;
  border-bottom-color: var(--primary-color);
}

.tab-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text-3);
  font-family: var(--mono);
  transition: background .15s, color .15s;
  min-width: 20px;
  text-align: center;
}

.tab.active .tab-count {
  background: var(--primary-color);
  color: #fff;
}

/* ── Main Area ───────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Map Container ───────────────────────────────── */
.map-container {
  flex: 1;
  overflow: auto;
  padding: 30px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #fff;
  position: relative;
  max-width: 100%;
  width: 100vw;
}

/* ─── SVG PLACEHOLDER ─────────────────────────────
     Drop your SVG here. Replace the comment block.
     The SVG will be styled via the rules below.
  ─────────────────────────────────────────────────── */
#map-svg-wrapper {
  width: 100%;
  /* background: var(--surface); */
  /* border: 1px solid var(--border); */
  border-radius: var(--radius-lg);
  overflow: hidden;
  /* box-shadow: var(--shadow-sm); */
  /* padding: 50px 0; */
  position: relative;
}

/* Your SVG goes inside this wrapper */
#map-svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 768px;
  max-height: 95vh;
  max-width: 100%;
}

/* District path hover styling — works on any SVG path with class "slice-*" or data-district */
#map-svg-wrapper svg path[id^="slice-"] {
  cursor: pointer;
  transition: fill .18s, opacity .18s;
}

#map-svg-wrapper svg path[id^="slice-"]:hover {
  fill: #C7D8C0 !important;
  opacity: .9;
}

#map-svg-wrapper svg path[id^="slice-"].active-district {
  fill: #AECBA4 !important;
}

/* Badge number circles in SVG */
#map-svg-wrapper svg .count_pointer circle {
  transition: r .15s, fill .15s;
  cursor: pointer;
}

#map-svg-wrapper svg .count_pointer:hover circle {
  r: 25;
}

#map-svg-wrapper svg .count_pointer {
  cursor: pointer;
}

/* ── Tooltip ─────────────────────────────────────── */
.tooltip {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  box-shadow: var(--shadow-md);
  min-width: 150px;
  max-width: 220px;
  font-family: var(--font);
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-district {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 5px;
  line-height: 1.3;
}

.tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
}

.tooltip-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--primary-color);
  background: var(--primary-light-color);
  padding: 1px 7px;
  border-radius: 4px;
}

/* ── Drawer Overlay ──────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, .25);
  backdrop-filter: blur(1px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Drawer ──────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: calc(-1 * var(--drawer-w) - 20px);
  width: var(--drawer-w);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: right .24s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--shadow-lg);
}

.drawer.open {
  right: 0;
}

/* Drawer Header */
.drawer-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.drawer-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.drawer-district-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.02em;
  line-height: 1.25;
}

.drawer-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  transition: var(--transition);
  flex-shrink: 0;
  margin-left: 8px;
}

.drawer-close:hover {
  background: var(--surface2);
  color: var(--text-1);
  border-color: var(--border-dark);
}

.drawer-tab-label {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-color);
  background: var(--primary-light-color);
  border: 1px solid var(--primary-color);
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Drawer Body */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.drawer-body::-webkit-scrollbar {
  width: 4px;
}

.drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Drawer Footer */
.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-secondary {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface2);
  color: var(--text-1);
  border-color: var(--border-dark);
}

/* ── Empty / Loading States ──────────────────────── */
.state-empty,
.state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-3);
  font-size: 13px;
  gap: 10px;
  text-align: center;
}

.state-empty-icon,
.state-loading-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}

.state-empty p,
.state-loading p {
  line-height: 1.5;
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Entity List (Breweries / Wholesalers / Retails) */
.entity-list {
  padding: 6px 0;
}

.entity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  transition: background .12s;
  cursor: default;
}

.entity-item:hover {
  background: var(--surface2);
}

.entity-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-3);
  flex-shrink: 0;
}

.entity-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.4;
}

.status-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.status-active {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-inactive {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.status-pending {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.entity-action {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
  text-decoration: none;
}

.entity-action:hover {
  background: var(--surface2);
  color: var(--text-1);
  border-color: var(--border-dark);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 4px;
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Bottlings Accordion ─────────────────────────── */
.bottling-item {
  border-bottom: 1px solid var(--border);
}

.bottling-item:last-child {
  border-bottom: none;
}

.bottling-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
}

.bottling-header:hover {
  background: var(--surface2);
}

.bottling-header.expanded {
  background: var(--surface2);
}

.bottling-chevron {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 10px;
  transition: transform .15s;
  flex-shrink: 0;
}

.bottling-header.expanded .bottling-chevron {
  transform: rotate(90deg);
}

.bottling-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-1);
  font-weight: 500;
}

.bottling-detail {
  display: none;
  padding: 0 18px 14px 46px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}

.bottling-detail.open {
  display: block;
}

.lines-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 14px;
}

.line-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.line-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.line-value {
  font-size: 20px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.2;
}

.line-value.active-val {
  color: var(--success-text);
}

.line-value.inactive-val {
  color: var(--danger-text);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-btn {
  height: 30px;
  padding: 0 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
  text-decoration: none;
}

.detail-btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.detail-btn-primary:hover {
  background: var(--accent-dim);
}

.detail-btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.detail-btn-ghost:hover {
  background: var(--surface);
  color: var(--text-1);
}

/* ── Officer Cards ───────────────────────────────── */
.officers-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 0;
}

.officer-card {
  margin: 0 18px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.officer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.officer-avatar.vacant {
  background: var(--surface);
  color: var(--text-3);
  border: 1px dashed var(--border-dark);
  font-size: 18px;
}

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

.officer-role-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
}

.officer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.officer-name.vacant-name {
  color: var(--text-3);
  font-weight: 400;
  font-style: italic;
}

.officer-contact {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  font-family: var(--mono);
}

.officer-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  background: var(--primary-light-color);
  color: var(--primary-color);
  flex-shrink: 0;
  border: 1px solid rgba(232, 90, 43, .12);
  align-self: flex-start;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ── Stats Bar in Drawer ─────────────────────────── */
.drawer-stats {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.stat-item {
  flex: 1;
  padding: 10px 18px 10px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-item:last-child {
  border-right: none;
}

.stat-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-value {
  font-size: 18px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.2;
}

.stat-value.green {
  color: var(--success-text);
}

.stat-value.red {
  color: var(--danger-text);
}

/* ── Map Legend ──────────────────────────────────── */
.map-legend {
  position: absolute;
  bottom: 20px;
  left: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 130px;
}

.legend-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 2px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-2);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.count_pointer text {
  font-size: 1.8rem !important;
}

/* ════════════════════════════════════════════════════
   DRAWER HEADER META ROW
   Tab label + total count pill on one line
════════════════════════════════════════════════════ */
.drawer-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* Total count pill — sits next to the tab label */
.drawer-total-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary-light-color);
  color: var(--primary-color);
  border: 1px solid rgba(232, 90, 43, .15);
  line-height: 1;
}

/* ════════════════════════════════════════════════════
   BOTTLING LINE STATUS PILL
   "Running" (green with pulsing dot) / "Stopped" (red)
   Replaces the old active/inactive status-pill for lines
════════════════════════════════════════════════════ */
.lines-summary {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
  margin-right: 4px;
  white-space: nowrap;
}

.line-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 10px;
}

.line-status-pill.running {
  background: var(--success-bg);
  color: var(--success-text);
}

.line-status-pill.stopped {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.line-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.line-status-pill.running .line-status-dot {
  background: var(--success-text);
  /* subtle pulse only on running — draws eye to active lines */
  animation: dotPulse 2s ease-in-out infinite;
}

.line-status-pill.stopped .line-status-dot {
  background: var(--danger-text);
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.75);
  }
}

/* ════════════════════════════════════════════════════
   ENTITY LIST — no status pill, cleaner row
════════════════════════════════════════════════════ */
.entity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  transition: background .12s;
}

.entity-item:hover {
  background: var(--surface2);
}

/* ── Scrollbar Utility ───────────────────────────── */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --drawer-w: 100vw;
  }

  .tab {
    padding: 0 10px;
  }

  .map-container {
    padding: 8px;
  }

  .header-meta {
    display: none;
  }
}

/* ════════════════════════════════════════════════════
   TELANGANA MAP — SVG OVERRIDES
   Convention in this SVG:
     Slice paths  →  [id$="_slice"] path
     Count badges →  [id$="_count"]
     Pointer icon →  [id$="_pointer"]
════════════════════════════════════════════════════ */

/* District path hover — targets every path inside a *_slice group */
#map-svg-wrapper svg [id$="_slice"] path {
    cursor: pointer;
    transition: fill .18s, opacity .18s;
}

#map-svg-wrapper svg [id$="_slice"] path:hover {
    fill: #C7D8C0 !important;
    opacity: .9;
}

/* Active district (drawer open) */
#map-svg-wrapper svg [id$="_slice"] path.active-district {
    fill: #AECBA4 !important;
}

/* ── Count badge groups ── */
#map-svg-wrapper svg [id$="_count"] {
    cursor: pointer;
    transition: opacity .28s;
}

/* Pointer icon hover — slightly enlarge */
#map-svg-wrapper svg [id$="_pointer"] {
    cursor: pointer;
}

#map-svg-wrapper svg [id$="_pointer"] use {
    transition: transform .15s;
}

/* Count text sizing (the SVG uses .t3 at 16px internally;
   if you need to override scale for readability, do it here) */
#map-svg-wrapper svg [id$="_count"] text {
    pointer-events: none;  /* clicks bubble to parent <g> */
}

/* ────────────────────────────────────────────────────
   All rules below are IDENTICAL to the original system.
   Copy them in alongside your existing stylesheet or
   include them after it — no changes needed.
──────────────────────────────────────────────────── */

/* (The rest of the component CSS — .tooltip, .drawer,
   .entity-list, .bottling-item, .officer-card, etc. —
   is unchanged from the original map.css.
   Only the SVG selector block above needed updating.) */

#map-svg [id$="_slice"] {
  cursor: pointer;
}

#map-svg [id$="_text"], 
#map-svg [id$="_pointer"],
#map-svg [id$="_count"] {
  pointer-events: none;
}

@media (min-width: 1930px) {
   .drawer {
    padding-right: 30px;
  }
}