/* =============================================================================
   Cyrcle Vereinsfinder – Frontend Styles
   ============================================================================= */

/* CRITICAL: enforce HTML [hidden] attribute against display overrides below.
   Without this, rules like .crm-vf-filter-dropdown { display: grid } silently
   win over the browser's [hidden]{display:none} user-agent rule, leaving the
   filter dropdown AND the loading overlay permanently visible. */
.crm-vf [hidden] { display: none !important; }

.crm-vf {
    --crm-border: #e5e7eb;
    --crm-text: #0f172a;
    --crm-muted: #64748b;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--crm-text);
    max-width: 100%;
    box-sizing: border-box;
}
.crm-vf *, .crm-vf *::before, .crm-vf *::after { box-sizing: border-box; }

/* -------- Header -------- */
.crm-vf-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 12px;
    /*background: #fff;*/
    /*border: 1px solid var(--crm-border);*/
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}
.crm-vf-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}
.crm-vf-back {
    background: #f1f5f9;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
}
.crm-vf-back:hover { background: #e2e8f0; }
.crm-vf-crumb { color:  #FFF; font-weight: 500; }

.crm-vf-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}
.crm-vf-filter-sportart { position: relative; }
.crm-vf-filter-toggle {
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.crm-vf-filter-toggle:hover { background: #f8fafc; }
.crm-vf-filter-count {
    background: var(--crm-popup-accent);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
}
.crm-vf-filter-chevron {
    display: inline-block;
    font-size: 11px;
    line-height: 1;
    transition: transform 0.15s ease;
    color: var(--crm-muted);
}
.crm-vf-filter-toggle-open .crm-vf-filter-chevron {
    transform: rotate(180deg);
}
.crm-vf-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    padding: 8px;
    min-width: 240px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    display: grid;
    gap: 2px;
}
.crm-vf-filter-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.crm-vf-filter-opt:hover { background: #f1f5f9; }
.crm-vf-filter-opt input { margin: 0; }
.crm-vf-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.crm-vf-reset {
    background: transparent;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--crm-muted);
}
.crm-vf-reset:hover { background: #f1f5f9; color: var(--crm-text); }

.crm-vf-counter {
    font-size: 14px;
    color: var(--crm-muted);
    padding: 8px 14px;
    background: #f8fafc;
    border-radius: 6px;
}
.crm-vf-counter-num { color: var(--crm-text); font-size: 16px; }

/* -------- Tabs (mobile only) -------- */
.crm-vf-tabs {
    display: none;
    width: 100%;
    border-top: 1px solid var(--crm-border);
    padding-top: 10px;
    margin-top: 6px;
    gap: 6px;
}
.crm-vf-tab {
    flex: 1;
    padding: 10px;
    background: #f1f5f9;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.crm-vf-tab-active {
    background: var(--crm-popup-accent);
    color: #fff;
    border-color: var(--crm-popup-accent);
}

/* -------- Body layout -------- */
.crm-vf-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 0;
    /*border: 1px solid var(--crm-border);*/
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    background: #fff;
	max-height:640px;
}
.crm-vf-map-wrap {
    position: relative;
    background: var(--crm-map-bg, #2E7D72);
}
.crm-vf-map {
    width: 100%;
    background: var(--crm-map-bg, #2E7D72);
}
.crm-vf-map .leaflet-container {
    background: var(--crm-map-bg, #2E7D72);
}

/* Permanent region labels */
.crm-vf-region-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    font-weight: 600;
    font-size: 11px;
    color: #1e293b;
    text-shadow:
        0 0 2px #fff,
        0 0 4px #fff,
        1px 1px 2px rgba(255,255,255,0.9);
    letter-spacing: 0.02em;
    transform: translate(-50%, -50%);
}
.crm-vf-region-label > span {
    display: inline-block;
}
.crm-vf-region-label-city {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #0f172a;
}

/* -------- Sidebar list --------
   min-height: 0 is the grid-child trick that lets overflow-y: auto actually
   scroll — without it, grid children default to min-height:auto and refuse
   to shrink below their content height. */
.crm-vf-sidebar {
    border-left: 1px solid var(--crm-border);
    background: #fff;
    overflow-y: auto;
    min-height: 0;
    height: 640px;
}
.crm-vf-list {
    display: flex;
    flex-direction: column;
}
.crm-vf-list-item {
    text-align: left;
    background: #fff;
    border: none;
    border-bottom: 1px solid var(--crm-border);
    padding: 12px 16px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background 0.1s;
}
.crm-vf-list-item:hover,
.crm-vf-list-item-hover {
    background: var(--crm-sidebar-hover);
}
.crm-vf-list-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}
.crm-vf-list-ort {
    font-size: 12px;
    color: var(--crm-muted);
    margin-bottom: 6px;
}
.crm-vf-list-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.crm-vf-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--crm-marker-default);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
}
.crm-vf-badge-more { background: #94a3b8; }

.crm-vf-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--crm-muted);
    font-size: 14px;
}

/* -------- Loading / error -------- */
.crm-vf-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255,255,255,0.85);
    z-index: 500;
    font-size: 14px;
}
.crm-vf-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--crm-popup-accent);
    border-radius: 50%;
    animation: crm-vf-spin 0.8s linear infinite;
}
@keyframes crm-vf-spin { to { transform: rotate(360deg); } }
.crm-vf-error {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    z-index: 600;
    font-size: 13px;
}

/* -------- Leaflet tooltips (region + marker hover) -------- */
.leaflet-tooltip.crm-vf-region-tooltip,
.leaflet-tooltip.crm-vf-marker-tooltip {
    background: var(--crm-popup-bg);
    color: var(--crm-popup-text);
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    white-space: nowrap;
}
.leaflet-tooltip.crm-vf-region-tooltip {
    font-weight: 600;
}
.leaflet-tooltip.crm-vf-marker-tooltip {
    line-height: 1.35;
}
.leaflet-tooltip.crm-vf-marker-tooltip strong {
    color: var(--crm-popup-accent);
}

/* -------- Leaflet popup (verein detail) -------- */
.leaflet-popup.crm-vf-verein-popup .leaflet-popup-content-wrapper {
    background: var(--crm-popup-bg);
    color: var(--crm-popup-text);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}
.leaflet-popup.crm-vf-verein-popup .leaflet-popup-content {
    margin: 12px 16px;
    font-size: 13px;
    line-height: 1.5;
}
.crm-vf-popup-title {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.25;
    color: var(--crm-popup-accent);
    font-weight: 600;
}
.crm-vf-popup-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}
.crm-vf-popup-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--crm-border);
}
.crm-vf-popup-section:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}
.crm-vf-popup-section a {
    color: var(--crm-popup-accent);
    text-decoration: none;
}
.crm-vf-popup-section a:hover { text-decoration: underline; }

/* -------- Mobile breakpoint -------- */
@media (max-width: 767px) {
    .crm-vf-body {
        grid-template-columns: 1fr;
    }
    .crm-vf-sidebar {
        border-left: none;
        border-top: 1px solid var(--crm-border);
        height: auto;
        max-height: 60vh;
    }
    .crm-vf-tabs {
        display: flex;
    }
    .crm-vf-filters {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
    .crm-vf-counter { display: none; }
    .crm-vf-map { height: 50vh !important; min-height: 340px; }
	.crm-vf-filter-dropdown{
		left:0;
	}
}

/* Region polygon focus outline */
.crm-vf .leaflet-interactive:focus {
    outline: 2px solid var(--crm-popup-accent);
    outline-offset: 2px;
}

/* Quellenangabe (basemap.de / OpenStreetMap) – Pflicht, aber dezent */
.crm-vf .leaflet-control-attribution {
    font-size: 10px;
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.75);
}
