/* ========================================================
   COCA-COLA SSD INTELLIGENCE PLATFORM — STORE MAP PAGE
   ======================================================== */

/* Override content padding for optimal screen fitting */
.content-area {
  padding: 16px 20px !important;
}

/* KPI STRIP LAYOUT */
.store-kpi-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.store-kpi-card {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.store-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.sk-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sk-icon-wrap.grey { background: var(--surface-2); color: var(--text-2); }
.sk-icon-wrap.green { background: rgba(16, 185, 129, 0.1); color: var(--green); }
.sk-icon-wrap.yellow { background: rgba(245, 158, 11, 0.1); color: var(--amber); }
.sk-icon-wrap.red { background: rgba(230, 27, 35, 0.1); color: var(--red); }
.sk-icon-wrap.pink { background: rgba(230, 27, 35, 0.06); color: var(--red); }

.sk-details {
  display: flex;
  flex-direction: column;
}

.sk-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.2;
}

.sk-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
}

.sk-val-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}
.sk-val-badge.green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

/* TRENDING BAR */
.trending-ticker-bar {
  background: var(--text-1);    /* dark strip uses theme text color */
  color: var(--surface); 
  height: 32px;
  display: flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.trending-label {
  background: var(--red);
  color: #fff;
  height: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.trending-marquee {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  height: 100%;
  padding-left: 12px;
}

.marquee-content {
  display: flex;
  gap: 24px;
  white-space: nowrap;
  animation: marquee 30s linear infinite;
}

@keyframes marquee {
  0% { transform: translateX(0%); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ticker-item .ti-name {
  color: var(--text-3);         /* use theme tertiary/muted text */
  text-transform: uppercase;
}

.ticker-item .ti-change {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ticker-item .ti-change.up { color: var(--green); }
.ticker-item .ti-change.down { color: var(--red); }

/* MAP GRID */
.store-map-grid {
  display: grid;
  /* map takes remaining space, right side uses fixed width to keep consistent layout */
  grid-template-columns: 1fr 360px; 
  gap: 20px;
  margin-bottom: 16px;
  align-items: start;
}

@media (max-width: 1200px) {
  .store-map-grid {
    grid-template-columns: 1fr;
  }
}

.map-wrapper {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 14px;
  height: 520px;           /* larger visual map area */
  min-height: 420px;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-container-el {
  width: 100%;
  height: 100%;
  background: #0d0d0d;
}

.map-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  top: auto;
  z-index: 1000;
  background: #ffffff;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  width: 220px;
  pointer-events: auto;
}

.legend-title {
  font-size: 11px;
  font-weight: 800;
  color: #6B7280;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot.green { background: #10b981; }
.legend-dot.yellow { background: #f59e0b; }
.legend-dot.red { background: #ef4444; }

.legend-footer {
  font-size: 9px;
  color: #9CA3AF;
  margin-top: 10px;
  border-top: 1px solid #E5E7EB;
  padding-top: 8px;
  font-style: italic;
}

/* SIDE PANELS */
.map-side-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;                              /* matches the grid's right column */
  box-sizing: border-box;
  align-self: start;                              /* keep panels aligned to top of grid */
  position: sticky;
  top: calc(var(--topbar-h) + 20px);              /* keeps side panels visible while scrolling */
}

.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  text-decoration: none !important;
}

.sc-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.region-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.region-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

.region-row:last-child {
  border-bottom: none;
}

.rr-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-1);
}

.rr-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rr-stat-item {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
}

.rr-stat-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}
.rr-stat-dot.green { background: var(--green); }
.rr-stat-dot.yellow { background: var(--amber); }
.rr-stat-dot.red { background: var(--red); }

.rr-total {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-1);
  min-width: 20px;
  text-align: right;
}

/* CATEGORY MIX */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cat-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
}

.cat-name {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.cat-val {
  color: var(--text-1);
}

.cat-bar-bg {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 3px;
}

/* TABLES GRID */
.tables-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* left table wider, right table narrower */
  gap: 20px;
  margin-top: 18px;
  align-items: start;
}

@media (max-width: 768px) {
  .tables-grid {
    grid-template-columns: 1fr;
  }
  
  .tables-grid .table-card {
    display: none;
  }
  
  .tables-grid.show-under .table-card.underperforming {
    display: block;
  }
  
  .tables-grid.show-over .table-card.overperforming {
    display: block;
  }
}

/* RESPONSIVE TABLE COLUMNS */
@media (max-width: 1200px) {
  .col-hide-md {
    display: none !important;
  }
}

@media (max-width: 992px) {
  .col-hide-sm {
    display: none !important;
  }
}

/* MOBILE TABLES TABS */
.mobile-tables-tabs {
  display: none;
}

@media (max-width: 768px) {
  .mobile-tables-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--surface-2);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
  }
  
  .mtt-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;             /* Reduced padding for more horizontal space */
    border: none;
    background: transparent;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;               /* Reduced font size slightly */
    font-weight: 700;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    white-space: nowrap;          /* Prevents text from breaking into 2 rows */
  }
  
  .mtt-btn:hover {
    color: var(--text-1);
    background: var(--surface-3);
  }
  
  .mtt-btn.active {
    background: var(--surface);
    color: var(--text-1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  }
  
  .mtt-icon {
    font-size: 14px;
  }
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

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

.tc-icon {
  font-size: 14px;
}

.tc-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.table-card.underperforming .tc-title { color: var(--red); }
.table-card.overperforming .tc-title { color: var(--green); }

.tc-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  color: #fff;
}
.table-card.underperforming .tc-badge { background: var(--red); }
.table-card.overperforming .tc-badge { background: var(--green); }

.tc-desc {
  font-size: 10.5px;
  color: var(--text-2);
  line-height: 1.35;
  margin-bottom: 10px;
}

.tc-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tc-search {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  outline: none;
  transition: all 0.2s;
}
.tc-search:focus {
  border-color: var(--red);
  background: var(--surface);
}

.tc-select {
  width: 110px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' fill='none' stroke='%234B5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1.5 2.5 2.5 2.5 2.5-2.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 8px;
  padding-right: 22px;
}

/* STORE TABLE */
.store-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.store-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.st-th {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.st-td {
  padding: 8px;
  font-size: 11px;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  vertical-align: middle;
}

.store-table tbody tr:last-child .st-td {
  border-bottom: none;
}

.st-store-cell {
  max-width: 140px;
}

.st-store-name {
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-store-sub {
  font-size: 9.5px;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 1px;
}

.st-region {
  font-weight: 600;
  color: var(--text-2);
}

.st-sales {
  font-weight: 700;
  color: var(--text-1);
}

.change-val {
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.change-pct {
  font-size: 10.5px;
}

.change-diff {
  font-size: 9px;
}

.change-val.up .change-pct { color: var(--green); }
.change-val.up .change-diff { color: rgba(16, 185, 129, 0.75); }
.change-val.down .change-pct { color: var(--red); }
.change-val.down .change-diff { color: rgba(230, 27, 35, 0.75); }

.sparkline-cell {
  width: 60px;
  text-align: center;
  padding: 4px 6px;
}

.sparkline-svg {
  width: 50px;
  height: 20px;
}

/* CUSTOM POPUP DESIGN */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text-1) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
  border: 1px solid var(--border) !important;
  font-family: 'Inter', sans-serif !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: 11px !important;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

.popup-title {
  font-weight: 800;
  font-size: 11.5px;
  margin-bottom: 4px;
  color: var(--text-1);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  font-size: 10.5px;
}

.popup-row span:first-child {
  color: var(--text-2);
}

.popup-row span:last-child {
  font-weight: 700;
  color: var(--text-1);
}

.popup-badge {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}
.popup-badge.up { background: rgba(16, 185, 129, 0.1); color: var(--green); }
.popup-badge.down { background: rgba(230, 27, 35, 0.1); color: var(--red); }

/* Layout overrides to prevent flexbox content from stretching the page width */
.main-wrap {
  min-width: 0;
}
.content-area {
  min-width: 0;
}

@media (min-width: 769px) {
  .tables-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}
.store-table-container {
  height: 450px !important;
  overflow-y: auto !important;
}
.store-table-container thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.status-dot.green {
  background-color: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.status-dot.amber {
  background-color: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}
.status-dot.red {
  background-color: var(--red);
  box-shadow: 0 0 6px var(--red);
}

@media (max-width: 768px) {
  .map-wrapper {
    height: 320px !important;
    min-height: 280px !important;
  }
  
  /* Convert the map legend to a thin bar at the bottom of the map */
  .map-legend {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 0 14px 14px !important;
    padding: 6px 12px !important;
    box-shadow: none !important;
    border: none !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    z-index: 1000 !important;
  }

  /* Hide the header and footer text to save vertical space */
  .legend-title,
  .legend-footer {
    display: none !important;
  }

  /* Display legend items in a single horizontal row */
  .legend-list {
    flex-direction: row !important;
    justify-content: space-around !important;
    gap: 4px !important;
  }

  .legend-row {
    font-size: 9.5px !important;
    font-weight: 700 !important;
    color: #374151 !important;
  }
  
  .store-kpi-strip { 
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .store-kpi-card {
    min-width: 0;
    padding: 8px;
  }
  .sk-val {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .store-kpi-strip {
    grid-template-columns: 1fr;
  }
}
