/* ============================================================
   RESET & GRUNDLAGEN
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1a6b3c;
    --primary-dark: #134d2b;
    --primary-light: #2d9e5a;
    --secondary: #4a90d9;
    --danger: #e53935;
    --success: #43a047;
    --warning: #fb8c00;
    --bg: #f5f7f5;
    --card-bg: #ffffff;
    --text: #2c3e2d;
    --text-light: #6b7c6b;
    --border: #d0dbd0;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
    --header-h: 60px;
    --radius: 10px;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--primary);
    color: white;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.header-logo {
    font-size: 28px;
    flex-shrink: 0;
}

.header-text {
    flex: 1;
}

.header-text h1 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.header-text p {
    font-size: 12px;
    opacity: 0.8;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-locate {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-locate:hover { background: rgba(255,255,255,0.35); }

.btn-admin {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-secondary {
    background: var(--secondary);
    color: white;
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-full { width: 100%; justify-content: center; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   KARTE
   ============================================================ */
#map {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* ============================================================
   INFO PANEL (Klick auf Track)
   ============================================================ */
.info-panel {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 16px;
    z-index: 900;
    min-width: 280px;
    max-width: min(90vw, 480px);
    transition: all 0.3s ease;
}

.info-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

.info-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.info-panel-header h3 {
    font-size: 16px;
    color: var(--primary);
    padding-left: 10px;
    border-left: 4px solid var(--primary);
    flex: 1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-light);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}
.close-btn:hover { background: var(--bg); }

#infoDesc {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

/* ============================================================
   STANDORT STATUS
   ============================================================ */
.location-status {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 900;
    transition: opacity 0.5s;
    white-space: nowrap;
    box-shadow: var(--shadow);
}
.location-status.info    { background: #e3f2fd; color: #1565c0; }
.location-status.success { background: #e8f5e9; color: #2e7d32; }
.location-status.error   { background: #ffebee; color: #c62828; }
.location-status.hidden  { display: none; }

/* ============================================================
   STANDORT MARKER (GPS Punkt)
   ============================================================ */
.location-dot {
    width: 18px;
    height: 18px;
    background: #2196F3;
    border: 3px solid white;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 2px 6px rgba(33,150,243,0.5);
}

.location-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid #2196F3;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { opacity: 1; transform: translate(-50%,-50%) scale(0.5); }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(1.5); }
}

/* ============================================================
   ADMIN BEREICH
   ============================================================ */
.admin-body {
    background: var(--bg);
    min-height: 100vh;
}

.admin-container {
    max-width: 860px;
    margin: calc(var(--header-h) + 24px) auto 40px;
    padding: 0 16px;
}

.admin-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.admin-card h2 {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Login */
.login-box {
    max-width: 380px;
    margin: 60px auto 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 32px;
    text-align: center;
}

.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-box h2 { color: var(--primary); margin-bottom: 8px; }
.login-box p  { color: var(--text-light); font-size: 14px; margin-bottom: 24px; }

.login-form .form-group {
    margin-bottom: 16px;
    text-align: left;
}
.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.login-form input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.alert-error   { background: #ffebee; color: #c62828; border-left: 4px solid #e53935; }
.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #43a047; }

/* Upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 28px;
    text-align: center;
    margin-bottom: 14px;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: var(--primary);
    background: #f0faf3;
}
.upload-icon { font-size: 40px; margin-bottom: 10px; }
.upload-area p { color: var(--text-light); font-size: 14px; margin-bottom: 12px; }
.file-input { display: none; }
.file-name  { display: block; font-size: 13px; color: var(--text-light); margin-top: 10px; }

/* GPX Liste */
.gpx-list { display: flex; flex-direction: column; gap: 12px; }

.gpx-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    transition: box-shadow 0.2s;
}
.gpx-item:hover { box-shadow: var(--shadow); }

.gpx-item-icon { font-size: 28px; flex-shrink: 0; padding-top: 2px; }

.gpx-item-info { flex: 1; min-width: 0; }

.gpx-item-filename {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    word-break: break-all;
}
.gpx-item-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 3px;
    line-height: 1.4;
}
.gpx-item-desc {
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gpx-item-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* Rename Form */
.rename-form {
    padding: 12px 14px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    margin-top: -6px;
}
.rename-form.hidden { display: none; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rename-input {
    flex: 1;
    min-width: 160px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 13px;
}

/* Badge */
.badge {
    background: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}
.empty-state p { font-size: 15px; margin-bottom: 8px; }

/* ============================================================
   RESPONSIVE - MOBILE
   ============================================================ */
@media (max-width: 600px) {
    .header-text h1 { font-size: 15px; }
    .header-text p  { font-size: 11px; }
    .btn { padding: 7px 10px; font-size: 12px; }

    .info-panel {
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        border-radius: var(--radius) var(--radius) 0 0;
        max-width: 100%;
    }
    .info-panel.hidden {
        transform: translateY(100%);
    }

    .gpx-item { flex-direction: column; }
    .gpx-item-actions {
        flex-direction: row;
        width: 100%;
    }
    .gpx-item-actions .btn { flex: 1; justify-content: center; }

    .admin-container { padding: 0 10px; }
}

@media (max-width: 400px) {
    :root { --header-h: 56px; }
    .header-logo { font-size: 22px; }
}

/* ============================================================
   SIDEBAR TOGGLE BUTTON (im Header)
   ============================================================ */
.sidebar-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.sidebar-toggle:hover,
.sidebar-toggle.active {
    background: rgba(255,255,255,0.3);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 300px;
    background: var(--card-bg);
    z-index: 800;
    display: flex;
    flex-direction: column;
    box-shadow: 3px 0 16px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

/* Karte auf Desktop verschieben wenn Sidebar offen */
#map.map-shifted {
    left: 300px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#map {
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--primary);
    color: white;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}

.sidebar-count {
    background: rgba(255,255,255,0.25);
    color: white;
    border-radius: 12px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.sidebar-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.2s;
}
.sidebar-close:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Suche */
.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    background: white;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,107,60,0.12);
}

/* Liste */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Scrollbar schmal */
.sidebar-list::-webkit-scrollbar { width: 5px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.sidebar-list::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* Einzelner Eintrag */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.sidebar-item:hover {
    background: #f0faf3;
}

.sidebar-item.active {
    background: #e6f4ec;
    border-right: 3px solid var(--primary);
}

.sidebar-item-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.sidebar-item-body {
    flex: 1;
    min-width: 0;
}

.sidebar-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-desc {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-arrow {
    color: var(--text-light);
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
}

/* Lade-Spinner */
.sidebar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-light);
    gap: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Leer-Zustand */
.sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    gap: 10px;
    text-align: center;
    color: var(--text-light);
}
.sidebar-empty-icon { font-size: 40px; }
.sidebar-empty p    { font-size: 14px; }

/* Kein Suchergebnis */
.sidebar-no-result {
    padding: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   OVERLAY (Mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 799;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
    /* Auf Mobile liegt Sidebar über der Karte */
    .sidebar {
        width: min(85vw, 300px);
    }
    #map.map-shifted {
        left: 0; /* Karte nicht verschieben auf Mobile */
    }
    .btn-label {
        display: none; /* Button-Text auf kleinen Screens verstecken */
    }
}

@media (min-width: 768px) {
    .sidebar-overlay {
        display: none !important; /* Kein Overlay auf Desktop */
    }
}

