/**
 * Geo Finder — style frontendu.
 * Wszystkie selektory używają BEM (.geo-finder__element--modifier),
 * by minimalizować ryzyko konfliktów ze stylami motywu.
 */

.geo-finder { font-family: inherit; color: inherit; box-sizing: border-box; }
.geo-finder *, .geo-finder *::before, .geo-finder *::after { box-sizing: inherit; }

/* Pasek wyszukiwania i filtrów */
.geo-finder__controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.geo-finder__search {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.geo-finder__search-input {
    flex: 1 1 220px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.geo-finder__search-btn,
.geo-finder__geo-btn {
    padding: 8px 16px;
    background: #2271b1;
    color: #fff;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.geo-finder__geo-btn { background: #5a6470; }
.geo-finder__search-btn:hover { background: #135e96; }
.geo-finder__geo-btn:hover { background: #404a55; }
.geo-finder__radius {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 0 0 4px;
    font-size: 14px;
    white-space: nowrap;
}
.geo-finder__radius-select {
    min-width: 86px;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

.geo-finder__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.geo-finder__filter {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
}

/* Layout: mapa + lista */
.geo-finder__layout { display: flex; gap: 16px; align-items: stretch; width: 100%; }
.geo-finder__layout--both { flex-direction: column; }
.geo-finder__layout--both .geo-finder__map-wrap { width: 100%; min-width: 0; }
.geo-finder__layout--both .geo-finder__list { width: 100%; min-width: 0; overflow: visible; }
.geo-finder__layout--map .geo-finder__map-wrap { width: 100%; }
.geo-finder__layout--list .geo-finder__list { width: 100%; }
@media (max-width: 768px) {
    .geo-finder__layout { flex-direction: column; }
    .geo-finder__layout--both .geo-finder__map-wrap,
    .geo-finder__layout--both .geo-finder__list { flex: 1 1 auto; min-width: 0; }
}

/* Mapa */
.geo-finder__map { width: 100%; min-height: 560px; border-radius: 6px; overflow: hidden; }

.geo-finder-user-marker {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2271b1;
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.25);
}

/* Lista wyników */
.geo-finder__list-status { padding: 8px 0; color: #666; font-style: italic; }
.geo-finder__list-items { list-style: none; padding: 0; margin: 0; }
.geo-finder__list-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}
.geo-finder__list-item:hover { background: #f6f7f7; }
.geo-finder__list-item--active { background: #eef4fa; border-left: 3px solid #2271b1; padding-left: 9px; }
.geo-finder__list-item-title { font-weight: 600; margin: 0 0 4px; }
.geo-finder__list-item-distance { color: #2271b1; font-weight: 600; font-size: 13px; }
.geo-finder__list-item-meta { color: #666; font-size: 13px; line-height: 1.5; }

/* Popup mapy */
.geo-finder-popup-title { font-weight: 700; margin: 0 0 6px; font-size: 15px; }
.geo-finder-popup-meta { font-size: 13px; line-height: 1.5; margin: 0 0 6px; color: #444; }
.geo-finder-popup-meta strong { color: #222; }
.geo-finder-popup-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.geo-finder-popup-actions a {
    background: #2271b1;
    color: #fff !important;
    padding: 4px 10px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 12px;
}
.geo-finder-popup-actions a:hover { background: #135e96; }

/* ----- 0.4: Niestandardowe ikony markerów (emoji + kolor) ----- */
.geo-finder-marker-wrap { background: transparent !important; border: 0 !important; }
.geo-finder-marker {
    width: 34px;
    height: 42px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid rgba(0,0,0,0.25);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.geo-finder-marker > span {
    transform: rotate(45deg);
    font-size: 18px;
    line-height: 1;
}

/* Ikona obok tytułu na liście wyników */
.geo-finder__list-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 13px;
    margin-right: 6px;
    vertical-align: middle;
}

/* ============================================================
 *  0.5 — Toolbar mapy (share, fullscreen, print)
 * ============================================================ */

.geo-finder__map-wrap {
    position: relative;
}

.geo-finder__toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1000; /* powyżej kafelków Leaflet, poniżej popupów */
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.95);
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.geo-finder__tool {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}
.geo-finder__tool:hover {
    background: #f5f5f5;
    border-color: #b0b0b0;
}
.geo-finder__tool:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}
.geo-finder__tool--done {
    background: #d1e7dd;
    border-color: #198754;
}

/* ============================================================
 *  0.5 — Tryb pełnoekranowy
 * ============================================================ */

.geo-finder--fullscreen,
.geo-finder:fullscreen,
.geo-finder:-webkit-full-screen {
    background: #fff;
    width: 100vw;
    height: 100vh;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.geo-finder--fullscreen .geo-finder__layout,
.geo-finder:fullscreen .geo-finder__layout {
    flex: 1;
    min-height: 0;
}

.geo-finder--fullscreen .geo-finder__map,
.geo-finder:fullscreen .geo-finder__map {
    height: 100% !important;
}

.geo-finder--fullscreen .geo-finder__map-wrap,
.geo-finder:fullscreen .geo-finder__map-wrap {
    height: 100%;
}

/* ============================================================
 *  0.5 — Historia wyszukiwań (dropdown pod inputem)
 * ============================================================ */

.geo-finder__search {
    position: relative; /* anchor dla dropdownu */
}

.geo-finder__history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1500;
    max-height: 280px;
    overflow-y: auto;
}
.geo-finder__history-head {
    padding: 6px 12px;
    background: #f6f7f7;
    color: #666;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
}
.geo-finder__history-item,
.geo-finder__history-clear {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #1a1a1a;
}
.geo-finder__history-item:hover,
.geo-finder__history-clear:hover {
    background: #f0f6fc;
}
.geo-finder__history-clear {
    border-top: 1px solid #eee;
    color: #b32d2e;
    font-size: 12px;
}

/* ============================================================
 *  0.5 — Wydruk: ukrywamy UI, zostaje mapa + lista
 * ============================================================ */

@media print {
    /* Strona drukowana ma marginesy zarządzane przez przeglądarkę. */
    @page {
        margin: 1cm;
    }

    /* Ukryj wszystko poza wtyczką. */
    body * {
        visibility: hidden;
    }
    .geo-finder, .geo-finder * {
        visibility: visible;
    }
    .geo-finder {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #fff;
    }

    /* Ukryj kontrolki interaktywne — w wydruku nie mają sensu. */
    .geo-finder__controls,
    .geo-finder__toolbar,
    .leaflet-control-zoom,
    .leaflet-control-attribution {
        display: none !important;
    }

    /* Mapa: zachowaj rozmiar, list pod nią. */
    .geo-finder__layout--both {
        display: block !important;
    }
    .geo-finder__map-wrap,
    .geo-finder__map {
        width: 100% !important;
    }
    .geo-finder__map {
        height: 50vh !important;
        page-break-after: avoid;
        margin-bottom: 12px;
    }
    .geo-finder__list {
        max-height: none !important;
        overflow: visible !important;
        page-break-inside: auto;
    }
    .geo-finder__list-item {
        page-break-inside: avoid;
        border-bottom: 1px solid #ddd;
        padding: 8px 0;
    }

    /* Markery — kolor tła może nie być drukowany domyślnie; wymuszamy. */
    .geo-finder-marker,
    .geo-finder__list-item-icon {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* 1.0: Accessibility — widoczne focus indicators (WCAG 2.1 AA: 2.4.7 Focus Visible) */
.geo-finder button:focus-visible,
.geo-finder input:focus-visible,
.geo-finder select:focus-visible,
.geo-finder a:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Tryb wysokiego kontrastu (Windows High Contrast Mode) */
@media (prefers-contrast: more) {
    .geo-finder__tool { border: 1px solid currentColor; }
    .geo-finder__list-item { border-left: 3px solid currentColor; }
}

/* Reduce motion (respektuj preferencje systemu) */
@media (prefers-reduced-motion: reduce) {
    .geo-finder * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Skip-link dla keyboard users — pojawia się gdy mapa otrzymuje focus */
.geo-finder__skip-to-list {
    position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.geo-finder__skip-to-list:focus {
    position: static; width: auto; height: auto; padding: 4px 8px; background: #2271b1; color: #fff;
}

/* Screen reader only — wzorzec WordPress */
.geo-finder .screen-reader-text {
    border: 0; clip: rect(1px, 1px, 1px, 1px); -webkit-clip-path: inset(50%); clip-path: inset(50%);
    height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal !important;
}
