/* ═══════════════════════════════════════════════════════
   CortexStores – Frontend CSS
   Astra theme CSS variable bridge:
     --ast-global-color-0  = Brand / Primary accent (orange)
     --ast-global-color-1  = Secondary accent
     --ast-global-color-2  = Headings
     --ast-global-color-3  = Body text
     --ast-global-color-4  = Muted text
     --ast-global-color-5  = Light text / border
     --ast-global-color-6  = Subtle background
     --ast-global-color-7  = Background (white)
   ═══════════════════════════════════════════════════════ */

/* ── Theme-bridge variables ────────────────────────────── */
.cxst-container {
  /* ——— Primary accent – Astra color-0 (brand orange) */
  --cxst-primary: var(--ast-global-color-0, #eb721f);
  --cxst-primary-hover: color-mix(in srgb, var(--cxst-primary) 82%, #000);

  /* ——— Headings – Astra color-2 */
  --cxst-secondary: var(--ast-global-color-2, #1a1a1a);

  /* ——— Body text – Astra color-3 */
  --cxst-text: var(--ast-global-color-3, #3a3a3a);

  /* ——— Muted / light text */
  --cxst-text-muted: var(--ast-global-color-4, #6b7280);
  --cxst-text-light: var(--ast-global-color-5, #9ca3af);

  /* ——— Backgrounds: always white/near-white */
  --cxst-bg: #ffffff;
  --cxst-bg-alt: #f5f5f5;

  /* ——— Borders */
  --cxst-border: var(--ast-global-color-5, #dde1e7);

  /* ——— Border radius – 0 = sharp corners */
  --cxst-radius: 0px;

  /* ——— Font family – Astra body/heading font */
  --cxst-font: var(--ast-body-font-family, inherit);
  --cxst-heading-font: var(--ast-heading-font-family, var(--cxst-font));

  --cxst-font-size-sm: 13px;
  --cxst-font-size-base: 15px;

  /* ——— Shadow */
  --cxst-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ── Container ─────────────────────────────────────────── */
.cxst-container {
  font-family: var(--cxst-font);
  max-width: 1200px;
  margin: 0 auto;
  color: var(--cxst-text);
}

.cxst-container *,
.cxst-container *::before,
.cxst-container *::after {
  box-sizing: border-box;
}

/* ── Search Bar ────────────────────────────────────────── */
.cxst-search-bar {
  background: transparent;
  border: none;
  padding: 0 0 16px;
  margin-bottom: 16px;
}

.cxst-search-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
}

.cxst-search-field {
  position: relative;
}

.cxst-search-text {
  flex: 2;
  min-width: 200px;
}

.cxst-search-select {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}

.cxst-search-bar input[type='text'] {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 1px solid #dde1e7;
  border-radius: 0;
  font-size: var(--cxst-font-size-base);
  font-family: var(--cxst-font);
  color: #1a1a1a;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  background: #ffffff;
}

.cxst-search-bar input[type='text']:focus {
  border-color: var(--cxst-primary) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cxst-primary) 15%, transparent) !important;
  outline: none !important;
  background: #ffffff;
}

.cxst-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
}

.cxst-search-bar select {
  width: 100%;
  flex: 1;
  padding: 0 16px;
  min-height: 44px;
  border: 1px solid #dde1e7;
  border-radius: 0;
  font-size: 14px;
  font-family: var(--cxst-font);
  color: #1a1a1a;
  outline: none;
  background: #ffffff;
  cursor: pointer;
  appearance: auto;
  transition: border-color 0.2s;
}

.cxst-search-bar select:focus {
  border-color: var(--cxst-primary) !important;
  outline: none !important;
}

.cxst-btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 1px solid #dde1e7 !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  cursor: pointer;
  color: #3a3a3a !important;
  transition: all 0.2s;
  align-self: center;
  flex-shrink: 0;
  padding: 0 !important;
}

.cxst-btn-reset svg {
  display: block;
  width: 16px;
  height: 16px;
  stroke: #3a3a3a !important;
  fill: none !important;
  pointer-events: none;
}

.cxst-btn-reset:hover {
  border-color: var(--cxst-primary) !important;
  color: var(--cxst-primary) !important;
  background: #ffffff !important;
}

.cxst-btn-reset:hover svg {
  stroke: var(--cxst-primary) !important;
}

.cxst-results-count {
  font-size: var(--cxst-font-size-sm);
  color: var(--cxst-text-muted);
  margin-top: 8px;
  min-height: 16px;
}

/* ── Map ───────────────────────────────────────────────── */
.cxst-map-wrapper {
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
  border: 1px solid var(--cxst-border);
}

#cxst-map {
  width: 100%;
  min-height: 400px;
  z-index: 1;
}

/* Custom map marker popup */
.cxst-popup {
  font-family: var(--cxst-font);
  min-width: 200px;
}

.cxst-popup-name {
  font-family: var(--cxst-heading-font);
  font-weight: 700;
  font-size: var(--cxst-font-size-base);
  color: var(--cxst-secondary);
  margin-bottom: 8px;
  border-bottom: 2px solid var(--cxst-bg-light);
  padding-bottom: 8px;
}

.cxst-popup-detail {
  font-size: var(--cxst-font-size-sm);
  color: var(--cxst-text);
  margin: 4px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.cxst-popup-detail svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.cxst-popup-directions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--cxst-primary);
  color: #fff !important;
  border-radius: 0;
  font-family: var(--cxst-font);
  font-size: var(--cxst-font-size-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.cxst-popup-directions:hover {
  background: var(--cxst-primary-hover);
  color: #fff !important;
}

/* ── Store List ────────────────────────────────────────── */
.cxst-stores-list {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ── Collapsible groups ────────────────────────────────── */
.cxst-group {
  border: 1px solid var(--cxst-border);
  background: #ffffff;
  overflow: hidden;
}

.cxst-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid var(--cxst-primary);
  transition: background 0.15s;
}

.cxst-group-header:hover {
  background: color-mix(in srgb, var(--cxst-primary) 6%, #ffffff);
}

.cxst-group-name {
  font-family: var(--cxst-heading-font);
  font-weight: 700;
  font-size: 15px;
  color: var(--cxst-secondary);
  flex: 1;
}

.cxst-group-count {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background: var(--cxst-primary);
  padding: 4px 8px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.cxst-group-chevron {
  flex-shrink: 0;
  color: var(--cxst-primary);
  transition: transform 0.2s ease;
}

/* Collapsed body: hidden by default */
.cxst-group-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  max-height: 0;
  overflow: hidden;
  padding: 0 16px;
  transition:
    max-height 0.28s ease,
    padding 0.28s ease;
}

/* Open state */
.cxst-group-open .cxst-group-body {
  max-height: 3000px;
  padding: 16px;
}

.cxst-group-open .cxst-group-chevron {
  transform: rotate(180deg);
}

.cxst-store-card {
  background: #ffffff;
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.cxst-store-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--cxst-primary);
  transform: scaleY(0);
  transition: transform 0.2s;
}

.cxst-store-card:hover,
.cxst-store-card.cxst-active {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.cxst-store-card:hover::before,
.cxst-store-card.cxst-active::before {
  transform: scaleY(1);
}

/* h4 and p inside cards – compact spacing */
.cxst-store-card h4 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.3;
}

.cxst-store-card p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cxst-store-card p svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.cxst-store-directions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 12px;
  background: transparent;
  color: var(--cxst-primary);
  border-radius: 0;
  font-family: var(--cxst-font);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--cxst-primary);
  transition: all 0.2s;
}

.cxst-store-directions:hover {
  background: var(--cxst-primary);
  color: #fff;
}

/* ── No results ────────────────────────────────────────── */
.cxst-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 24px;
  color: var(--cxst-text-light);
  font-size: 16px;
}

.cxst-no-results svg {
  display: block;
  margin: 0 auto 16px;
  color: var(--cxst-border);
}

/* ── MarkerCluster customization ───────────────────────── */
.marker-cluster-small {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 20%,
    transparent
  ) !important;
}
.marker-cluster-small div {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 60%,
    transparent
  ) !important;
  color: #fff !important;
  font-weight: 700;
}
.marker-cluster-medium {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 30%,
    transparent
  ) !important;
}
.marker-cluster-medium div {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 70%,
    transparent
  ) !important;
  color: #fff !important;
  font-weight: 700;
}
.marker-cluster-large {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 40%,
    transparent
  ) !important;
}
.marker-cluster-large div {
  background-color: color-mix(
    in srgb,
    var(--cxst-primary, #2563eb) 80%,
    transparent
  ) !important;
  color: #fff !important;
  font-weight: 700;
}

/* ── Custom Marker ─────────────────────────────────────── */
.cxst-marker-icon {
  background: none;
  border: none;
}

/* ── Section-level collapsible (E-parduotuvės / Fizinės) ── */
.cxst-section-group > .cxst-section-header {
  border-left: 4px solid var(--cxst-primary);
  font-size: 15px;
}

.cxst-section-group > .cxst-section-header .cxst-group-name {
  font-size: 15px;
}

.cxst-section-group > .cxst-group-body {
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Sections (E-parduotuvės / Fizinės parduotuvės) ────── */
.cxst-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cxst-section-title {
  margin: 0 0 4px;
  padding: 8px 0 8px 12px;
  font-family: var(--cxst-heading-font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cxst-secondary);
  border-left: 3px solid var(--cxst-primary);
  line-height: 1.3;
}

/* ── E-shop cards ──────────────────────────────────────── */
.cxst-eshop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--cxst-border);
  border-left: 3px solid var(--cxst-primary);
}

.cxst-eshop-card--sub {
  border-left-width: 1px;
  padding-left: 16px;
}

.cxst-eshop-name {
  font-family: var(--cxst-heading-font);
  font-size: 15px;
  font-weight: 700;
  color: var(--cxst-secondary);
  flex: 1;
}

.cxst-eshop-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--cxst-font);
  color: var(--cxst-primary);
  border: 1px solid var(--cxst-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.cxst-eshop-link:hover {
  background: var(--cxst-primary);
  color: #ffffff;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .cxst-search-row {
    flex-direction: column;
  }

  .cxst-search-text,
  .cxst-search-select {
    min-width: 100%;
  }

  .cxst-btn-reset {
    width: 100%;
  }

  .cxst-stores-list {
    grid-template-columns: 1fr;
  }

  #cxst-map {
    min-height: 300px;
  }
}

@media (max-width: 480px) {
  .cxst-store-card {
    padding: 12px 16px;
  }
}
