/* ===== LAYOUT ===== */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.karte-body {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.karte-body main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.karte-wrap {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
    /* Anker für absolute Sidebar + Backdrop */
}

#map {
    flex: 1;
    height: auto;
    min-height: 500px;
    background: #e8ecef;
}

/* ===== SIDEBAR ===== */
.karte-sidebar {
    width: 320px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.07);
    z-index: 10;
}

.karte-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    background: #1e3a5f;
    color: #fff;
}

.karte-sidebar-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.karte-sidebar-count {
    font-size: 1.2rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 12px;
    border-radius: 20px;
    min-width: 40px;
    text-align: center;
}

/* ===== SUCHE ===== */
.karte-search {
    position: relative;
    padding: 10px 12px 6px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.karte-search-icon {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-30%);
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}

.karte-search input {
    width: 100%;
    padding: 8px 10px 8px 30px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.85rem;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.karte-search input:focus {
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.karte-search input::placeholder {
    color: #94a3b8;
}

/* ===== FILTER ===== */
.karte-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.karte-pill {
    font-size: 0.74rem;
    padding: 4px 11px;
    border-radius: 20px;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-weight: 500;
}

.karte-pill:hover {
    border-color: #1e3a5f;
    color: #1e3a5f;
}

.karte-pill.is-active {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #fff;
}

.karte-filter-select {
    font-size: 0.74rem;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
    outline: none;
    flex: 1;
    min-width: 0;
    transition: border-color 0.15s;
}

.karte-filter-select:focus {
    border-color: #1e3a5f;
}

/* ===== DOJO LIST ===== */
.dojo-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.dojo-list::-webkit-scrollbar {
    width: 4px;
}

.dojo-list::-webkit-scrollbar-track {
    background: transparent;
}

.dojo-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.dojo-item {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s;
}

.dojo-item:hover {
    background: #f0f6ff;
}

.dojo-item.active {
    background: #eff6ff;
    border-left: 3px solid #1e3a5f;
    padding-left: 11px;
}

.dojo-item h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 2px;
    line-height: 1.3;
}

.dojo-item-loc {
    font-size: 0.74rem;
    color: #64748b;
    margin: 0 0 5px;
}

.dojo-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.karte-badge {
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 500;
}

.karte-badge-verband {
    background: #fef9c3;
    color: #854d0e;
}

.karte-badge-jug {
    background: #fff7ed;
    color: #c2410c;
}

.dojo-empty,
.dojo-loading,
.dojo-error {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.dojo-error {
    color: #dc2626;
}

/* ===== FOOTER ===== */
.karte-footer {
    padding: 7px 14px;
    font-size: 0.68rem;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    text-align: center;
}

/* ===== POPUP ===== */
.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14) !important;
    padding: 0 !important;
    overflow: hidden;
    border-left: 4px solid #1e3a5f !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
}

.leaflet-popup-tip-container {
    margin-left: 2px;
}

/* Versatz durch border-left ausgleichen */

.custom-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 12px 14px 10px;
    min-width: 200px;
    max-width: 270px;
}

.popup-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    line-height: 1.3;
    margin-bottom: 4px;
}

.popup-addr {
    font-size: 0.77rem;
    color: #64748b;
    margin-bottom: 8px;
}

.popup-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.popup-tag {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.popup-tag-verband {
    background: #fef9c3;
    color: #854d0e;
}

.popup-tag-jugend {
    background: #fff7ed;
    color: #c2410c;
}

.popup-links {
    display: flex;
    gap: 14px;
    padding-top: 7px;
    border-top: 1px solid #f1f5f9;
}

.popup-links a {
    font-size: 0.75rem;
    color: #1e3a5f;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.popup-links a:hover {
    text-decoration: underline;
}

/* Popup – Logo */
.popup-logo-wrap {
    text-align: center;
    margin-bottom: 8px;
}

.popup-logo {
    max-height: 52px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Popup – Trainingszeiten */
.popup-times-wrap {
    margin: 6px 0 8px;
    padding: 6px 8px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.popup-times-wrap strong {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 4px;
}

.popup-times {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.77rem;
    color: #1e293b;
}

.popup-times td {
    padding: 1px 4px 1px 0;
    vertical-align: top;
}

.pp-day {
    font-weight: 600;
    white-space: nowrap;
    color: #475569;
    min-width: 26px;
}

/* ===== MARKER ===== */
.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

/* ===== CLUSTER ===== */
.marker-cluster-small {
    background-color: rgba(30, 58, 95, 0.18);
}

.marker-cluster-small div {
    background-color: rgba(30, 58, 95, 0.75);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.marker-cluster-medium {
    background-color: rgba(30, 58, 95, 0.25);
}

.marker-cluster-medium div {
    background-color: rgba(30, 58, 95, 0.82);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.marker-cluster-large {
    background-color: rgba(30, 58, 95, 0.30);
}

.marker-cluster-large div {
    background-color: rgba(30, 58, 95, 0.9);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

/* ===== STANDORT-BUTTON ===== */
.leaflet-control-locate {
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    color: #1e3a5f;
    user-select: none;
    -webkit-user-select: none;
}
.leaflet-control-locate.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ===== CLOSE-BUTTON im Sidebar-Header ===== */
.karte-sidebar-close {
    display: none;
    /* Desktop: versteckt */
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
    margin-left: auto;
}

.karte-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== FLOATING BUTTON ===== */
.karte-fab {
    display: none;
    /* Desktop: versteckt */
    position: absolute;
    bottom: 28px;
    right: 16px;
    z-index: 800;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 28px;
    padding: 11px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    gap: 8px;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.karte-fab:active {
    transform: scale(0.94);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.karte-fab-count {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 0.8rem;
    min-width: 24px;
    text-align: center;
}

/* ===== BACKDROP ===== */
.karte-backdrop {
    /* Immer im DOM, aber unsichtbar + nicht klickbar auf Desktop */
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.karte-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Sidebar: off-canvas rechts, überlagert die Karte */
    .karte-sidebar {
        position: absolute;
        top: 0;
        right: 0;
        height: 100%;
        width: min(85vw, 320px);
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(.4, 0, .2, 1);
        box-shadow: -6px 0 28px rgba(0, 0, 0, 0.2);
        border-left: none;
    }

    .karte-sidebar.is-open {
        transform: translateX(0);
    }

    .karte-sidebar-close {
        display: flex;
    }

    .karte-fab {
        display: flex;
    }

    /* Sidebar-Header: Close-Button rechtsbündig */
    .karte-sidebar-header {
        gap: 8px;
    }

    /* Footer auf Karten-Seite ausblenden – Karte braucht den Platz */
    .karte-body .site-footer {
        display: none;
    }
}