/* Owntracks GPS Tracking – Layout & Login */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f5f5;
}

/* ----- Login ----- */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

.login-box {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 340px;
}

.login-box h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.75rem;
    color: #2c3e50;
}

.login-subtitle {
    margin: 0 0 1.5rem 0;
    color: #7f8c8d;
    font-size: 0.95rem;
}

.login-error {
    background: #fee;
    color: #c0392b;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.login-form label {
    display: block;
    margin-bottom: 1rem;
}

.login-form label span {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.login-form button {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.7rem 1rem;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}

.login-form button:hover {
    background: #2980b9;
}

/* ----- Map Page ----- */
body.map-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: #e8e8e8;
    padding-top: env(safe-area-inset-top);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    padding-left: calc(1rem + env(safe-area-inset-left));
    padding-right: calc(1rem + env(safe-area-inset-right));
    background: #2c3e50;
    color: #fff;
    flex-shrink: 0;
}

.header h1 {
    margin: 0;
    font-size: 1.25rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header .user {
    color: #bdc3c7;
    font-size: 0.9rem;
}

.btn-refresh {
    height: 34px;
    padding: 0 0.75rem;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-refresh:hover,
.btn-refresh:focus {
    background: rgba(255,255,255,0.18);
    outline: none;
}
.btn-refresh:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Hamburger-Button */
.btn-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}
.btn-menu:hover, .btn-menu:focus {
    background: rgba(255,255,255,0.15);
    outline: none;
}
.btn-menu .hamburger {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}

/* Einstellungen-Panel (Drawer von rechts) */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    max-width: 320px;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    padding-right: env(safe-area-inset-right);
}
.settings-panel.is-open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 1rem 1.25rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.settings-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}
.btn-close-menu {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #666;
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}
.btn-close-menu:hover, .btn-close-menu:focus {
    background: #eee;
    color: #333;
    outline: none;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.settings-body .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
}
.settings-body .tid-checkboxes {
    flex-direction: column;
}
.settings-body .btn-apply {
    margin-top: 0.5rem;
    margin-left: 0;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.tid-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.tid-check {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

.tid-check input {
    margin-right: 0.35rem;
}

select, input[type="date"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.btn-apply {
    padding: 0.5rem 1rem;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    margin-left: auto;
}

.btn-apply:hover {
    background: #219a52;
}

.map {
    flex: 1 1 0;
    min-height: 300px;
    width: 100%;
    position: relative;
}

.map-quick-controls {
    position: fixed;
    top: calc(4.1rem + env(safe-area-inset-top));
    right: calc(0.75rem + env(safe-area-inset-right));
    z-index: 950;
}

.quick-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.95);
    color: #2c3e50;
    border: 1px solid rgba(44, 62, 80, 0.2);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
}

.quick-toggle input {
    margin: 0;
}

.last-points {
    flex-shrink: 0;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    background: #fff;
    border-top: 1px solid #eee;
}
.last-points:empty { display: none; }
.last-points .error { color: #c0392b; }

/* Gesamt-km Overlay unten rechts */
.summary-km {
    position: fixed;
    right: calc(0.75rem + env(safe-area-inset-right));
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: rgba(44, 62, 80, 0.92);
    color: #ecf0f1;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    z-index: 900;
    max-width: 260px;
}
.summary-km.hidden {
    display: none;
}
.summary-km-title {
    font-weight: 600;
    margin-bottom: 0.1rem;
}
.summary-km-total {
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.summary-km-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
}
.summary-km-item {
    white-space: nowrap;
}
.summary-km-tid {
    font-weight: 500;
}

/* Leaflet: Geschwindigkeit (Tooltip + Popup für Tippen) */
.speed-tooltip {
    font-size: 12px;
    padding: 2px 6px;
}
.speed-popup .leaflet-popup-content-wrapper {
    padding: 0.4em 0.6em;
    font-size: 14px;
    font-weight: 500;
}
.speed-popup .leaflet-popup-content { margin: 0; }

/* Letzter Standort: dauerhaft sichtbares Label am Marker */
.last-marker-label {
    font-size: 12px !important;
    padding: 4px 8px !important;
    white-space: nowrap;
    pointer-events: none;
}
.last-marker-label strong { font-weight: 600; }

.point-time-label {
    font-size: 10px !important;
    font-weight: 600;
    padding: 2px 5px !important;
    border-radius: 4px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(44, 62, 80, 0.25);
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.segment-speed-label {
    font-size: 10px !important;
    font-weight: 700;
    padding: 2px 5px !important;
    border-radius: 4px;
    white-space: nowrap;
    background: rgba(44, 62, 80, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ecf0f1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}
