/* ============================================================
   VetMapa Warsaw — complete stylesheet
   Stack: Vanilla CSS, CSS custom properties, no framework
   ============================================================ */

/* ── Custom properties ─────────────────────────────────────── */
:root {
  --color-primary:      oklch(36% 0.118 155);
  --color-primary-bg:   oklch(94% 0.055 152);
  --color-primary-dark: oklch(30% 0.1 155);
  --color-accent:       oklch(58% 0.155 67);
  --color-emergency:    #dc2626;
  --color-neutral-bg:   #f8fafc;
  --color-card-bg:      #ffffff;
  --color-border:       #e2e8f0;
  --color-text:         #1e293b;
  --color-muted:        #64748b;
  --color-muted-light:  #94a3b8;
  --color-hover-bg:     #f1f5f9;

  --font-base: system-ui, -apple-system, 'Segoe UI', sans-serif;

  --header-height: 3.25rem;
  --footer-height: 2.5rem;
  --filter-width:  280px;

  --radius-sm:  0.25rem;
  --radius-md:  0.375rem;
  --radius-lg:  0.5rem;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* ── Reset / base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-base);
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-neutral-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ─────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-height);
  background: var(--color-card-bg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
}

.app-layout {
  display: grid;
  grid-template-columns: var(--filter-width) minmax(360px, 460px) 1fr;
  height: calc(100dvh - var(--header-height) - var(--footer-height));
  overflow: hidden;
}

.app-footer {
  height: var(--footer-height);
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-card-bg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Header brand & search ─────────────────────────────────── */
.header-brand {
  flex-shrink: 0;
}

.header-brand h1 {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  white-space: nowrap;
}

.brand-dot {
  color: oklch(58% 0.155 67);
}

.location-bar {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  position: relative;
  align-items: center;
}

#search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-base);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-neutral-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search-input::placeholder {
  color: var(--color-muted-light);
}

#search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: var(--color-card-bg);
}

.suggestions-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  list-style: none;
  z-index: 100;
  overflow: hidden;
}

.suggestions-list li {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.1s;
}

.suggestions-list li:hover,
.suggestions-list li:focus {
  background: var(--color-hover-bg);
}

.btn-gps {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}

.btn-gps:hover {
  background: var(--color-primary-dark);
}

.btn-gps:active {
  transform: scale(0.96);
}

.inapp-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: oklch(32% 0.08 50);
  color: oklch(96% 0.01 50);
  font-size: 0.8rem;
  padding: 0.625rem 1rem;
  position: sticky;
  top: 0;
  z-index: 300;
}

.inapp-btn {
  flex-shrink: 0;
  background: oklch(62% 0.18 145);
  color: #fff;
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
}

.location-notice {
  flex: 0 0 100%;
  font-size: 0.8rem;
  color: oklch(48% 0.18 25);
  padding: 0.25rem 0;
  line-height: 1.4;
}

.btn-gps.gps-loading {
  opacity: 0.6;
  cursor: wait;
}

.btn-gps.gps-loading svg {
  animation: spin 1s linear infinite;
}

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

/* ── Filter panel ──────────────────────────────────────────── */
.filter-panel {
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-card-bg);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  position: sticky;
  top: 0;
  background: var(--color-card-bg);
  z-index: 10;
}

.filter-header button {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
}

.filter-header button:hover {
  background: var(--color-primary-bg);
}

.filter-group {
  padding: 0.5rem 0.75rem;
}

.filter-group + .filter-group {
  border-top: 1px solid var(--color-border);
}

.filter-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.filter-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.35rem 0.6rem;
  margin: 0.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card-bg);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-base);
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  color: var(--color-text);
}

.filter-chip:hover:not(.chip-disabled) {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
}

.filter-chip.active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.filter-chip.chip-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chip-name {
  font-weight: 500;
}

.chip-body {
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-top: 0.1rem;
}

.chip-count {
  font-size: 0.7rem;
  color: var(--color-muted-light);
  margin-top: 0.1rem;
}

.chip-count::before {
  content: "(";
}

.chip-count::after {
  content: ")";
}

/* ── Results panel ─────────────────────────────────────────── */
.results-panel {
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-neutral-bg);
}

.results-header {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-card-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.results-count {
  font-weight: 500;
  color: var(--color-text);
}

/* ── Clinic cards ──────────────────────────────────────────── */
.clinic-card {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-card-bg);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-left-color 0.12s;
}

.clinic-card:hover,
.clinic-card.active {
  background: var(--color-primary-bg);
  border-left-color: var(--color-primary);
}

.clinic-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.clinic-address,
.clinic-hours {
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.clinic-distance {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
}

.clinic-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
}

.clinic-phone,
.clinic-website {
  font-size: 0.8rem;
  color: var(--color-primary);
  text-decoration: none;
  transition: text-decoration 0.1s;
}

.clinic-phone:hover,
.clinic-website:hover {
  text-decoration: underline;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge-emergency,
.badge-open,
.badge-closed {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
  color: #fff;
}

.badge-emergency {
  background: var(--color-emergency);
}

.badge-open {
  background: var(--color-accent);
}

.badge-closed {
  background: var(--color-muted);
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.empty-state p + p {
  margin-top: 0.5rem;
}

/* ── Map panel ─────────────────────────────────────────────── */
.map-panel {
  position: relative;
  overflow: hidden;
}

.map-container {
  width: 100%;
  height: 100%;
}

/* ── Map markers ─────────────────────────────────────────────── */
.map-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background 0.15s, width 0.15s, height 0.15s;
  position: absolute;
  transform: translate(-50%, -50%);
}

.map-marker.active {
  background: var(--color-emergency);
  width: 30px;
  height: 30px;
  z-index: 1;
}

/* ── Footer links ─────────────────────────────────────────── */
.footer-asmapps {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-asmapps:hover {
  text-decoration: underline;
}

/* ── Scrollbar styling (webkit) ──────────────────────────── */
.filter-panel::-webkit-scrollbar,
.results-panel::-webkit-scrollbar {
  width: 5px;
}

.filter-panel::-webkit-scrollbar-track,
.results-panel::-webkit-scrollbar-track {
  background: transparent;
}

.filter-panel::-webkit-scrollbar-thumb,
.results-panel::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 9999px;
}

/* ── Mobile (<768px) ─────────────────────────────────────── */
@media (max-width: 767px) {
  :root {
    --header-height: 6.25rem;
    --footer-height: 2.25rem;
  }

  /* 2-row header: row1 = brand + GPS btn, row2 = search bar full width */
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 1rem;
    row-gap: 0.375rem;
    column-gap: 0.5rem;
    align-items: center;
  }

  .header-brand {
    flex: 1;
  }

  .header-brand h1 {
    font-size: 1rem;
  }

  /* GPS button stays on row 1 (right of brand) */
  .btn-gps {
    flex-shrink: 0;
  }

  /* search bar wraps to full-width row 2 */
  .location-bar {
    flex: 0 0 100%;
  }

  /* flex column: filter → map → handle → list */
  .app-layout {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--header-height) - var(--footer-height));
    overflow: hidden;
  }

  .filter-panel {
    order: 1;
    flex-shrink: 0;
    overflow-y: hidden;
    overflow-x: auto;
    touch-action: pan-x;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.375rem 0.5rem;
    gap: 0;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .filter-panel::-webkit-scrollbar { display: none; }
  .filter-header                    { display: none; }
  .filter-group-title               { display: none; }

  .filter-group {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    padding: 0;
    border: none;
  }

  .filter-group + .filter-group {
    border-top: none;
    margin-left: 0.25rem;
  }

  .filter-chip {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    margin: 0.15rem 0.2rem;
  }

  .chip-body  { margin-top: 0; }
  .chip-count { margin-top: 0; }

  .map-panel {
    order: 2;
    flex-shrink: 0;
    height: 42dvh;
    min-height: 100px;
  }

  .resize-handle {
    order: 3;
    flex-shrink: 0;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface, oklch(99% 0.005 155));
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
    z-index: 10;
  }

  .resize-handle::before {
    content: '';
    width: 2rem;
    height: 3px;
    border-radius: 2px;
    background: var(--color-border);
  }

  .results-panel {
    order: 4;
    flex: 1;
    min-height: 80px;
    overflow-y: auto;
    border-right: none;
  }
}

/* ── Focus-visible accessibility ─────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
.filter-chip:focus-visible,
.clinic-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* resize-handle hidden on desktop */
.resize-handle { display: none; }

@media (max-width: 767px) {
  .resize-handle { display: flex; }
}

/* ── FAQ section ──────────────────────────────────────────── */
.faq-section {
  background: #f8fafc;
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.25rem;
}

.faq-inner {
  max-width: 680px;
  margin: 0 auto;
}

.faq-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.875rem;
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 0.625rem 0;
}

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

.faq-item summary {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1rem;
  color: var(--color-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  font-size: 0.8125rem;
  color: var(--color-muted);
  line-height: 1.6;
  margin-top: 0.5rem;
  padding-bottom: 0.25rem;
  max-inline-size: 100%;
}

.faq-item a {
  color: var(--color-primary);
  text-decoration: none;
}

.faq-item a:hover {
  text-decoration: underline;
}

/* ── Map marker popup ──────────────────────────────────────── */
.clinic-popup .mapboxgl-popup-content {
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  font-family: var(--font-base);
}

.clinic-popup .mapboxgl-popup-tip {
  border-top-color: var(--color-card-bg);
}

.marker-popup {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 9rem;
  max-width: 15rem;
}

.marker-popup .mp-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
}

.marker-popup .mp-addr {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.marker-popup .mp-dist {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 0.125rem;
}

.marker-popup .mp-tel {
  font-size: 0.8rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-top: 0.125rem;
}

.marker-popup .mp-tel:hover {
  text-decoration: underline;
}
