/* === Global Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --bg-header: #1a5276;
    --text-light: #ffffff;
    --text-dark: #2c3e50;
    --shadow: 0 2px 8px rgba(0,0,0,0.15);
    --radius: 8px;
    --header-height: 52px;
    --filter-height: 48px;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    background: #f0f0f0;
}

/* === Header === */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.header-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

#app-header h1 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    text-decoration: none;
}

.header-btn:hover {
    background: rgba(255,255,255,0.25);
}

.header-btn.active {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
}

.header-btn svg {
    width: 18px;
    height: 18px;
}

/* === Map === */
#map {
    position: fixed;
    top: calc(var(--header-height) + var(--filter-height));
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* === Loading === */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 2000;
    transition: opacity 0.3s;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#loading span {
    font-size: 14px;
    color: var(--text-dark);
}

/* === Location Count Badge === */
#location-count {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-header);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: var(--shadow);
    pointer-events: none;
    transition: opacity 0.3s;
}

#location-count.hidden {
    opacity: 0;
}

/* === Leaflet overrides === */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
    border-radius: var(--radius) !important;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 18px !important;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(255,255,255,0.7) !important;
}

/* Gemeindegrenze Tooltip */
.grenze-tooltip {
    background: rgba(26, 82, 118, 0.9);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.grenze-tooltip::before {
    border-top-color: rgba(26, 82, 118, 0.9) !important;
}

/* === FAB (Floating Action Button) === */
#fab-add {
    position: fixed;
    bottom: 28px;
    right: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #e53935;
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(229,57,53,.5);
    transition: transform .15s, box-shadow .15s;
}
#fab-add:active { transform: scale(.92); }
#fab-add svg { width: 28px; height: 28px; }

/* === Quick-Add Overlay === */
#qa-overlay {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: none;
    align-items: flex-end;
    pointer-events: none;
}
#qa-overlay.active {
    display: flex;
    pointer-events: auto;
}
#qa-sheet {
    width: 100%;
    max-height: 75vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 0 16px 24px;
    overflow-y: auto;
    box-shadow: 0 -4px 32px rgba(0,0,0,.2);
    animation: slideUp .25s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity:0; transform:translate(-50%,12px); }
    to   { opacity:1; transform:translate(-50%,0); }
}
.qa-handle {
    width: 40px; height: 4px;
    background: #ddd; border-radius: 2px;
    margin: 10px auto 6px;
}
.qa-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0 12px;
    font-size: 17px; font-weight: 700; color: #1a5276;
    border-bottom: 1px solid #eee;
}
.qa-close {
    background: none; border: none; font-size: 20px;
    color: #999; cursor: pointer; padding: 4px 8px;
}
.qa-hint { font-size: 13px; color: #666; margin: 12px 0 8px; }
#qa-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}
.qa-cat-btn {
    display: flex; flex-direction: column; align-items: center;
    gap: 5px; padding: 12px 6px;
    border: 2px solid var(--cat-color, #ccc);
    border-radius: 12px; background: #fff;
    cursor: pointer; transition: background .15s;
}
.qa-cat-btn:active { background: #f5f5f5; }
.qa-cat-btn img { width: 28px; height: 28px; }
.qa-cat-btn span { font-size: 11px; font-weight: 600; color: #333; text-align: center; line-height: 1.2; }
.qa-label { display: block; font-size: 12px; font-weight: 600; color: #555; margin: 12px 0 4px; }
.qa-input {
    width: 100%; box-sizing: border-box;
    border: 1.5px solid #ddd; border-radius: 10px;
    padding: 11px 14px; font-size: 16px;
    outline: none; margin-bottom: 4px;
}
.qa-input:focus { border-color: #1a5276; }
.qa-coords {
    font-size: 13px; color: #1a5276; font-weight: 600;
    background: #eaf2fb; border-radius: 8px;
    padding: 8px 12px; margin: 4px 0 8px;
}
.qa-btn-secondary {
    width: 100%; padding: 10px; border: 1.5px solid #1a5276;
    border-radius: 10px; background: #fff; color: #1a5276;
    font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
}
.qa-actions { display: flex; gap: 8px; margin-top: 4px; }
.qa-btn-back {
    flex: 0 0 auto; padding: 13px 16px;
    border: 1.5px solid #ccc; border-radius: 12px;
    background: #fff; color: #666; font-size: 15px; cursor: pointer;
}
.qa-btn-save {
    flex: 1; padding: 13px;
    border: none; border-radius: 12px;
    background: #1a5276; color: #fff;
    font-size: 16px; font-weight: 700; cursor: pointer;
}
.qa-btn-save:disabled { background: #999; }

/* === Login Modal === */
#qa-login-modal {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0,0,0,.5);
    display: none; align-items: center; justify-content: center;
}
#qa-login-box {
    background: #fff; border-radius: 16px;
    padding: 24px 20px; width: 90%; max-width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
#qa-login-box h3 { margin: 0 0 16px; font-size: 18px; color: #1a5276; }
#qa-login-box .qa-input { margin-bottom: 10px; }
#qa-login-box .qa-btn-save { width: 100%; margin-top: 4px; }
