/* ============================================================
   style.css - Meine Zeitachse (FINAL - Hamburger Menü horizontal)
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%; font-family: 'Montserrat', sans-serif;
    background: #f5f7fa; color: #1a1a2e; overflow: hidden;
    touch-action: manipulation;
}
a { text-decoration: none; color: inherit; }

/* LOGIN */
#login-screen {
    display: flex; justify-content: center; align-items: center;
    height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-container {
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
    border-radius: 24px; padding: 40px 32px; max-width: 400px; width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); text-align: center;
}
.login-header { margin-bottom: 24px; }
.login-logo { max-width: 80px; height: auto; margin: 0 auto 12px; border-radius: 16px; }
.login-container h1 { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.login-container .subtitle { font-size: 14px; color: #6b7280; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.form-group input {
    width: 100%; padding: 12px 16px; border: 2px solid #e5e7eb; border-radius: 12px;
    font-size: 15px; font-family: inherit; background: #f9fafb; transition: all 0.2s ease;
}
.form-group input:focus { outline: none; border-color: #667eea; background: #fff; box-shadow: 0 0 0 4px rgba(102,126,234,0.1); }

.btn-primary {
    display: block; width: 100%; padding: 14px 24px; background: #667eea; color: #fff;
    border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer;
    transition: all 0.2s ease; box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(102,126,234,0.4); }
.btn-primary:active { transform: scale(0.98); }

.btn-outline {
    display: inline-block; padding: 8px 16px; background: transparent; color: #374151;
    border: 2px solid #e5e7eb; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.2s ease; white-space: nowrap;
}
.btn-outline:hover { background: #f9fafb; border-color: #d1d5db; }

.btn-danger {
    display: inline-block; padding: 8px 16px; background: #ef4444; color: #fff;
    border: none; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.2s ease;
}
.btn-danger:hover { background: #dc2626; transform: scale(0.98); }

.switch-form { margin-top: 16px; font-size: 14px; color: #6b7280; }
.switch-form a { color: #667eea; font-weight: 600; cursor: pointer; }
.error-msg { margin-top: 12px; font-size: 14px; color: #ef4444; font-weight: 500; min-height: 20px; }
.footer-credit { margin-top: 24px; font-size: 12px; color: #9ca3af; border-top: 1px solid #e5e7eb; padding-top: 16px; }

/* HAUPTANSICHT */
#main-app { display: flex; flex-direction: column; height: 100vh; width: 100vw; background: #fff; }

/* HEADER */
#app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: #fff; border-bottom: 1px solid #e5e7eb;
    min-height: 72px; flex-shrink: 0; z-index: 1000; flex-wrap: wrap; gap: 6px;
}
.header-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-logo { height: 64px; width: auto; border-radius: 8px; }
.header-intro { font-size: 16px; color: #6b7280; font-weight: 400; margin-right: 8px; white-space: nowrap; }
.user-badge {
    font-size: 16px; font-weight: 700; color: #1a1a2e;
    background: #f3f4f6; padding: 6px 14px; border-radius: 20px; white-space: nowrap;
}
.header-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.header-right .btn-outline { font-size: 12px; padding: 6px 12px; }
.header-right .btn-danger { font-size: 12px; padding: 6px 12px; }

/* LIVE BUTTON - NUR GRÜN-WEISS, KEIN ROT */
.btn-live { 
    padding: 6px 14px; border: none; border-radius: 20px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.3s ease; background: #e5e7eb; color: #374151; 
}
.btn-live.aus { background: #6b7280; color: #fff; }
.btn-live.aktiv { background: #27ae60; color: #fff; }
.btn-live.offline { background: #3498db; color: #fff; box-shadow: 0 2px 8px rgba(52,152,219,0.3); animation: none; }

.btn-live.recording { animation: blink-green-white 1.2s ease-in-out infinite; }
@keyframes blink-green-white {
    0% { background-color: #27ae60; color: #ffffff; box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.5); }
    50% { background-color: #ffffff; color: #27ae60; box-shadow: 0 0 15px 5px rgba(39, 174, 96, 0.7); }
    100% { background-color: #27ae60; color: #ffffff; box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.5); }
}

/* MAIN CONTENT */
#main-content { display: flex; flex: 1; overflow: hidden; }
#map-container { flex: 1; position: relative; min-width: 0; height: 100%; }
#map { width: 100%; height: 100%; background: #e8ecf1; }
#geocoding-status {
    position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.75); color: #fff; padding: 8px 20px; border-radius: 20px;
    font-size: 14px; font-weight: 500; z-index: 1000; pointer-events: none; backdrop-filter: blur(4px);
}

/* SIDEBAR */
#sidebar {
    width: 380px; background: #f9fafb; border-left: 1px solid #e5e7eb;
    overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; flex-shrink: 0;
}
.panel { background: #fff; border-radius: 16px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #f3f4f6; }
.panel h3 { font-size: 15px; font-weight: 700; color: #1a1a2e; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel .hint { font-size: 13px; color: #6b7280; margin: 4px 0; }

/* KALENDER */
#calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#calendar-header button { background: #f3f4f6; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; transition: all 0.2s ease; }
#calendar-header button:hover { background: #e5e7eb; }
#calendar-header span { font-size: 14px; font-weight: 600; }
#calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 500; border-radius: 8px; cursor: pointer; transition: all 0.15s ease; color: #1a1a2e; position: relative;
}
.cal-day:hover { background: #f3f4f6; }
.cal-day.other-month { color: #d1d5db; }
.cal-day.has-entry { font-weight: 700; color: #667eea; }
.cal-day.has-entry::after { content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: #667eea; }
.cal-day.today { background: #f3f4f6; font-weight: 700; }
.cal-day.selected { background: #667eea; color: #fff; }
.cal-day.selected.has-entry::after { background: #fff; }

/* LISTE */
#standorte-liste { max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.standort-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; background: #f9fafb; border-radius: 10px; transition: all 0.15s ease; cursor: pointer; gap: 8px;
}
.standort-item:hover { background: #f3f4f6; }
.standort-item .info { flex: 1; min-width: 0; }
.standort-item .addr { font-size: 13px; font-weight: 600; color: #1a1a2e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standort-item .meta { font-size: 11px; color: #6b7280; margin-top: 2px; }
.standort-item .distance { font-size: 12px; font-weight: 600; color: #667eea; white-space: nowrap; }
.standort-item .delete-btn { background: transparent; border: none; color: #9ca3af; font-size: 14px; cursor: pointer; padding: 4px; border-radius: 4px; transition: all 0.15s ease; }
.standort-item .delete-btn:hover { color: #ef4444; background: #fee2e2; }
.log-button-panel .btn-outline { width: 100%; text-align: center; padding: 10px; }

/* MARKER & TOOLTIPS */
.home-marker { font-size: 24px; text-align: center; line-height: 30px; }
.live-marker { font-size: 24px; text-align: center; line-height: 30px; filter: drop-shadow(0 0 8px rgba(74,144,217,0.6)); animation: pulse-live 2s ease-in-out infinite; }
@keyframes pulse-live { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.live-marker-accuracy { animation: pulse-accuracy 3s ease-in-out infinite; }
@keyframes pulse-accuracy { 0%,100% { opacity: 0.3; } 50% { opacity: 0.6; } }
.custom-tooltip .leaflet-tooltip-content-wrapper { border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); border: none; }
.custom-tooltip .leaflet-tooltip-tip { display: none; }

/* STRECKEN-LEGENDE */
.strecken-legend {
    position: fixed; background: rgba(255,255,255,0.98); backdrop-filter: blur(8px);
    padding: 12px 16px; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.3); z-index: 800; width: auto; max-width: 90%; min-width: 180px;
    right: 20px; bottom: 20px; cursor: grab; user-select: none; touch-action: none; pointer-events: auto;
}
.strecken-legend:active { cursor: grabbing; }
.legend-title { font-size: 13px; font-weight: 700; color: #1a1a2e; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6; }
.legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; color: #374151; white-space: nowrap; }
.legend-color { flex-shrink: 0; display: block; }
.legend-text { white-space: nowrap; }

/* MODAL */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 9999;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
    background: #fff; border-radius: 24px; padding: 32px; max-width: 480px; width: 100%;
    max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
}
.modal-close {
    position: absolute; top: 16px; right: 20px; font-size: 28px; color: #6b7280; cursor: pointer;
    transition: all 0.2s ease; line-height: 1;
}
.modal-close:hover { color: #1a1a2e; transform: rotate(90deg); }
.modal-content h2 { font-size: 24px; font-weight: 800; margin-bottom: 20px; color: #1a1a2e; }
.modal-content hr { border: none; border-top: 1px solid #e5e7eb; margin: 20px 0; }
.danger-zone { padding: 16px; background: #fef2f2; border-radius: 12px; border: 1px solid #fee2e2; }
.danger-zone h4 { color: #dc2626; font-size: 14px; margin-bottom: 12px; }
.danger-zone .btn-outline, .danger-zone .btn-danger { width: 100%; margin-top: 6px; }
.status-msg { margin-top: 12px; font-size: 14px; font-weight: 500; min-height: 20px; }

/* ============================================================
   HAMBURGER MENÜ (Nur Handy) - HORIZONTAL!
   ============================================================ */

/* Standard: Auf PC sind alle Buttons sichtbar */
#btn-toggle-sidebar {
    display: none;
}
.dropdown-menu {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Hamburger-Menü nur für Mobile */
@media (max-width: 768px) {
    #btn-toggle-sidebar {
        display: block;
        background: #f3f4f6;
        border: none;
        border-radius: 8px;
        padding: 8px 12px;
        font-size: 20px;
        cursor: pointer;
    }
    
    #btn-toggle-sidebar:hover {
        background: #e5e7eb;
    }
    
    /* Alle Buttons horizontal anordnen, wenn das Menü geöffnet ist */
    .dropdown-menu {
        display: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        margin-top: 8px;
        gap: 4px;
    }
    
    /* Wenn das Menü geöffnet ist (Klasse wird per JS gesetzt) */
    .dropdown-menu.open {
        display: flex;
    }
    
    .dropdown-menu .btn-outline,
    .dropdown-menu .btn-live,
    .dropdown-menu .btn-danger,
    .dropdown-menu a {
        width: auto;
        margin-bottom: 0;
    }
    
    /* PC-ONLY Buttons auf dem Handy ausblenden */
    .pc-only {
        display: none !important;
    }
    
    /* LIVE-Button bleibt im Header sichtbar */
    .header-left .btn-live {
        display: inline-block !important;
    }
}

/* ============================================================
   PC ONLY (Standard)
   ============================================================ */

.pc-only {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pc-only input {
    width: 50px;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

/* ============================================================
   SIDEBAR ABSCHALTEN (Ein-/Ausklappen)
   ============================================================ */

/* Standard: Sidebar ist offen */
#main-content #sidebar {
    display: flex;
}

/* Wenn die Klasse 'sidebar-closed' gesetzt ist, wird die Sidebar versteckt */
#main-content.sidebar-closed #sidebar {
    display: none;
}

/* Karte dehnt sich aus, wenn Sidebar zu ist */
#main-content.sidebar-closed #map-container {
    width: 100%;
}

/* ============================================================
   DUNKELMODUS (NUR FARBEN! KEINE ANDEREN ÄNDERUNGEN!)
   ============================================================ */

body.dark-mode {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .login-container,
body.dark-mode #main-app,
body.dark-mode #app-header,
body.dark-mode .panel,
body.dark-mode .modal-content {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
    box-shadow: none !important;
}

body.dark-mode #sidebar {
    background: #1a1a1a !important;
    border-left-color: #333 !important;
}

body.dark-mode .header-intro,
body.dark-mode .subtitle,
body.dark-mode .login-container h1,
body.dark-mode .modal-content h2,
body.dark-mode .panel h3,
body.dark-mode .legend-title {
    color: #f0f0f0 !important;
}
body.dark-mode .user-badge {
    background: #333 !important;
    color: #fff !important;
}

body.dark-mode input, 
body.dark-mode textarea,
body.dark-mode select {
    background-color: #2c2c2c !important;
    color: #ffffff !important;
    border-color: #555 !important;
}
body.dark-mode .form-group label {
    color: #ccc !important;
}

body.dark-mode .btn-outline {
    border-color: #555 !important;
    color: #ccc !important;
    background: transparent !important;
}
body.dark-mode .btn-outline:hover {
    background: #2c2c2c !important;
}

body.dark-mode .cal-day {
    color: #e0e0e0 !important;
}
body.dark-mode .cal-day:hover {
    background: #2c2c2c !important;
}
body.dark-mode .cal-day.today {
    background: #2c2c2c !important;
}
body.dark-mode .cal-day.other-month {
    color: #666 !important;
}
body.dark-mode .cal-day.selected {
    background: #4a90d9 !important;
}

body.dark-mode .standort-item {
    background: #2c2c2c !important;
}
body.dark-mode .standort-item:hover {
    background: #383838 !important;
}
body.dark-mode .standort-item .addr {
    color: #f0f0f0 !important;
}
body.dark-mode .standort-item .meta {
    color: #999 !important;
}

body.dark-mode .danger-zone {
    background: #2c1a1a !important;
    border-color: #5c2b2b !important;
}

/* Legende im Dunkelmodus hell und lesbar */
body.dark-mode .strecken-legend {
    background-color: #2a2a2a !important;
    border: 1px solid #555 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
}
body.dark-mode .legend-title {
    color: #ffffff !important;
    border-bottom-color: #555 !important;
}
body.dark-mode .legend-item {
    color: #e0e0e0 !important;
}
body.dark-mode .legend-text {
    color: #e0e0e0 !important;
}

body.dark-mode .custom-tooltip {
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
    border: 1px solid #444 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6) !important;
}
body.dark-mode .custom-tooltip div {
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
}