/*
 * Fishub Directory — Map Stylesheet
 *
 * Covers:
 *  - View toggle buttons (List / Map / Near Me)
 *  - View panel show/hide
 *  - Leaflet map container and sidebar layout
 *  - Custom marker SVG styles
 *  - Marker cluster icons
 *  - User location pulse marker
 *  - Map popup and sidebar panel
 *  - Nearby status bar
 *  - Responsive adjustments
 *
 * @package FishubDirectory
 */

/* ── View toggle ───────────────────────────────────────────────────────────── */

.fishub-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.fishub-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: #ffffff;
    border: 1px solid var(--fishub-border, #e4e7ec);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fishub-text-muted, #667085);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.fishub-view-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.fishub-view-btn:hover {
    border-color: var(--fishub-accent, #1a3a5c);
    color: var(--fishub-accent, #1a3a5c);
    background: rgba(26,58,92,.04);
}

.fishub-view-btn--active {
    background: var(--fishub-accent, #1a3a5c);
    border-color: var(--fishub-accent, #1a3a5c);
    color: #ffffff !important;
}

.fishub-view-btn--nearby.fishub-view-btn--active {
    background: #2e7d32;
    border-color: #2e7d32;
}

/* ── View panels ───────────────────────────────────────────────────────────── */

.fishub-view-panel {
    display: none;
}

.fishub-view-panel--active {
    display: block;
}

/* Filter bar hidden in nearby view */
.fishub-filter-bar--hidden {
    display: none !important;
}

/* ── Map container ─────────────────────────────────────────────────────────── */

/* .fishub-map-wrap: flex column so the hint bar stacks above the map/sidebar row */
.fishub-map-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

/* .fishub-map-row: the actual side-by-side grid of map + sidebar */
.fishub-map-row {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 16px;
    align-items: start;
    width: 100%;
}

.fishub-map {
    width: 100%;
    height: 630px;
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.08);
    overflow: hidden;
    background: #e8eaed;
    z-index: 0;
}

.fishub-map--nearby {
    height: 580px;
    margin-bottom: 24px;
}

@media (max-width: 860px) {
    .fishub-map-row {
        grid-template-columns: 1fr;
    }
    .fishub-map {
        height: 380px;
    }
}

/* ── Map sidebar ───────────────────────────────────────────────────────────── */

.fishub-map-sidebar {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
    min-height: 200px;
    /* No max-height or overflow — sidebar grows to fit content */
    padding: 0;
    overflow: hidden; /* clip popup card corners to sidebar border-radius */
}

.fishub-map-sidebar__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--fishub-text-muted, #667085);
    gap: 12px;
}

.fishub-map-sidebar__placeholder svg {
    width: 40px;
    height: 40px;
    opacity: 0.35;
}

.fishub-map-sidebar__placeholder p {
    font-size: 13px;
    margin: 0;
}

/* ── Marker styles ─────────────────────────────────────────────────────────── */

.fishub-marker {
    background: none !important;
    border: none !important;
}

.fishub-marker svg {
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
    transition: transform 0.15s ease;
}

.fishub-marker:hover svg,
.fishub-marker:focus svg {
    transform: scale(1.15) translateY(-2px);
}

/* ── Cluster icons ─────────────────────────────────────────────────────────── */

.fishub-cluster-wrap {
    background: none !important;
    border: none !important;
}

.fishub-cluster {
    width: 40px;
    height: 40px;
    background: var(--fishub-accent, #1a3a5c);
    border: 3px solid rgba(255,255,255,.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    transition: transform 0.15s ease;
}

.fishub-cluster:hover {
    transform: scale(1.1);
}

.fishub-cluster span {
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
}

/* ── User location marker ──────────────────────────────────────────────────── */

.fishub-user-marker {
    width: 20px;
    height: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fishub-user-marker::after {
    content: '';
    width: 12px;
    height: 12px;
    background: #2e7d32;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    position: absolute;
    z-index: 2;
}

.fishub-user-marker__pulse {
    position: absolute;
    width: 36px;
    height: 36px;
    background: rgba(46,125,50,.25);
    border-radius: 50%;
    animation: fishub-pulse 2s ease-out infinite;
    z-index: 1;
}

@keyframes fishub-pulse {
    0%   { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* ── Map tooltip ───────────────────────────────────────────────────────────── */

.fishub-map-tooltip.leaflet-tooltip {
    background: var(--fishub-accent, #1a3a5c);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    font-family: inherit;
    white-space: nowrap;
}

.fishub-map-tooltip.leaflet-tooltip::before {
    border-top-color: var(--fishub-accent, #1a3a5c);
}

/* ── Map popup ─────────────────────────────────────────────────────────────── */

.fishub-map-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

.fishub-map-popup .leaflet-popup-content {
    margin: 0;
    width: 380px !important;
}

@media (max-width: 480px) {
    .fishub-map-popup .leaflet-popup-content {
        width: calc(100vw - 60px) !important;
    }
}

.fishub-map-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

/* ── Theme paragraph margin reset (Salient sets p { margin: 1.5em 0 }) ────── */
.fishub-popup p,
.fishub-nearby-grid p,
.fishub-tier-section p {
    margin: 0 !important;
    padding: 0 !important;
}

/* ── Popup / sidebar card ──────────────────────────────────────────────────── */

.fishub-popup {
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

/* Sidebar content wrapper must also be full width */
.fishub-map-sidebar__content {
    width: 100%;
    box-sizing: border-box;
}

.fishub-popup__image {
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.fishub-popup__image img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 150px;
    object-fit: contain;
    object-position: center;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.07);
    background: #ffffff;
}

.fishub-popup__body {
    padding: 8px 12px 12px;
    /* No max-height — sidebar grows to fit content */
}

.fishub-popup__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.fishub-popup__title {
    font-size: 14px;
    font-weight: 700;
    color: #0f0f10;
    line-height: 1.2;
    font-family: inherit;
    margin-bottom: 6px !important;
}

/* Item 10: tier badge hidden in popup — admin-only concept */
.fishub-popup__tier { display: none; }

.fishub-popup__cats {
    font-size: 12px;
    color: var(--fishub-text-muted, #667085);
    margin-bottom: 4px !important;
}

.fishub-popup__location,
.fishub-popup__distance {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--fishub-text-muted, #667085);
    margin-bottom: 4px !important;
}

.fishub-popup__location svg,
.fishub-popup__distance svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.fishub-popup__distance {
    color: #2e7d32;
    font-weight: 600;
}

.fishub-popup__desc {
    font-size: 12px;
    color: var(--fishub-text-muted, #667085);
    line-height: 1.4;
    margin-top: 6px !important;
}

/* Premium sidebar: slightly larger text */
.fishub-popup__desc--full {
    font-size: 12px;
    line-height: 1.45;
}

.fishub-popup__actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.fishub-popup__actions .fishub-btn-primary,
.fishub-popup__actions .fishub-btn-secondary {
    font-size: 12px;
    padding: 6px 14px;
    min-height: 34px;
}

.fishub-popup__actions .fishub-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fishub-popup__actions .fishub-btn-secondary svg {
    width: 12px;
    height: 12px;
}

.fishub-popup__actions .fishub-btn-phone svg,
.fishub-nearby-grid .fishub-btn-phone svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    flex-shrink: 0;
}

/* ── Nearby status bar ─────────────────────────────────────────────────────── */

.fishub-nearby-status {
    background: #f0f4f8;
    border: 1px solid var(--fishub-border, #e4e7ec);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    transition: background 0.2s ease;
}

.fishub-nearby-status.is-loading {
    background: #e8f0fe;
    border-color: #b3c9f7;
}

.fishub-nearby-status.is-success {
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.fishub-nearby-status.is-error {
    background: #fdecea;
    border-color: #f5c6c6;
}

.fishub-nearby-status.is-empty {
    background: #fff8e1;
    border-color: #ffe082;
}

.fishub-nearby-status__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fishub-text, #2d3748);
}

.fishub-nearby-status__inner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--fishub-accent, #1a3a5c);
}

.fishub-nearby-status.is-success .fishub-nearby-status__inner svg { color: #2e7d32; }
.fishub-nearby-status.is-error   .fishub-nearby-status__inner svg { color: #c62828; }

/* ── Distance badge on nearby cards ───────────────────────────────────────── */

.fishub-card__meta-item--distance {
    color: #2e7d32 !important;
    font-weight: 600;
}

.fishub-card__meta-item--distance svg {
    color: #2e7d32 !important;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .fishub-view-toggle {
        gap: 6px;
    }
    .fishub-view-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    .fishub-map {
        height: 300px;
    }
    .fishub-map--nearby {
        height: 260px;
    }
}

/* ── Nearby results grid ───────────────────────────────────────────────────── */

/* Nearby results: tier sections reuse the same CSS classes as the list view
   (.fishub-tier-section--premium, --enhanced, --basic) so no extra grid rules
   are needed here. We just add spacing for the results wrapper. */
.fishub-nearby-results {
    margin-top: 24px;
}

/* Nearby tier sections are shown/hidden by JS.
   The display type (flex / grid) is defined by the tier-section class in frontend.css.
   No additional display rules needed here. */

/* ── Popup: premium badge row above image ───────────────────────────────── */
.fishub-popup__badge-row {
    display: flex;
    justify-content: flex-end;
    padding: 6px 8px 0;
    background: #fff;
}

/* Ensure the shared tier badge style works inside the popup context */
.fishub-popup .fishub-tier-badge--premium {
    position: static;   /* override absolute from list-view context */
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7a5200;
    background: linear-gradient(135deg, #ffe066 0%, #ffc107 100%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    pointer-events: none;
}

/* Discount tag inside popup: small breathing room above it */
.fishub-popup .fishub-discount-tag {
    margin-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.07);
    border-radius: 0 0 12px 12px;
}

/* ── Map postcode proximity hint bar ─────────────────────────────────────── */
/* Sits above .fishub-map-row as a flex child of .fishub-map-wrap */

.fishub-map-postcode-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
}

.fishub-map-postcode-hint.is-loading {
    background: #eef4fb;
    color: #1a6fa8;
    border: 1px solid #c2daf0;
}

.fishub-map-postcode-hint.is-success {
    background: #edf7f0;
    color: #1a5a3c;
    border: 1px solid #b8dfc8;
}

.fishub-map-postcode-hint.is-error {
    background: #fdf2f2;
    color: #b91c1c;
    border: 1px solid #f5c6c6;
}

.fishub-map-postcode-hint__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.7;
}

.fishub-map-postcode-hint__clear {
    background: none;
    border: none;
    padding: 0;
    margin-left: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    color: inherit;
    opacity: 0.8;
}

.fishub-map-postcode-hint__clear:hover {
    opacity: 1;
}
