/* Express-Brötchen Look + App-Layout */
:root {
    --eb-brown: #5a2d16;
    --eb-brown-2: #6b3b1f;
    --eb-orange: #f48a04;

    --app-bg: #f4f5f7;
    --app-surface: #ffffff;
    --app-text: #111;
    --app-muted: #6c757d;

    --app-header-bg: var(--eb-brown-2);
    --app-header-fg: #fff;

    --app-footer-bg: var(--eb-brown-2);
    --app-footer-fg: rgba(255,255,255,.85);
    --app-footer-active: #fff;
}

html[data-theme="dark"] {
    --app-bg: #0f0f10;
    --app-surface: #17181a;
    --app-text: #f2f2f2;
    --app-muted: #b7bcc3;

    --app-header-bg: #3b2214;
    --app-footer-bg: #3b2214;
}

.app-body {
    background: var(--app-bg);
    color: var(--app-text);
}

/* Platz für fixed header/footer */
.app-main {
    padding-top: calc(64px + env(safe-area-inset-top));
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

/* Header */
.app-header {
    height: 56px;
    padding-top: env(safe-area-inset-top);
    background: var(--app-header-bg);
    color: var(--app-header-fg);
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}

.app-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    font-size: .7rem;
}

/* Status-Switch etwas "App-like" */
.app-status-switch .form-check-input {
    width: 48px;
    height: 26px;
    cursor: pointer;
}
.app-status-switch .form-check-input:not(:checked) {
    background-color: #dc3545;
    border-color: #dc3545;
}
.app-status-switch .form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}

/* Footer Tabs */
.app-footer {
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--app-footer-bg);
    display: flex;
    box-shadow: 0 -2px 10px rgba(0,0,0,.12);
}

.app-tab {
    flex: 1;
    text-decoration: none;
    color: var(--app-footer-fg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
}

.app-tab i {
    font-size: 18px;
}

.app-tab.active {
    color: var(--app-footer-active);
}

/* Dashboard */
.app-card {
    background: var(--app-surface);
    border: 0;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

.app-quick {
    background: var(--eb-brown-2);
    color: #fff;
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
}

html[data-theme="dark"] .app-quick {
    background: #2a180f;
}

.app-quick .value {
    font-weight: 800;
    font-size: 16px;
    margin-top: 6px;
}

.app-quick .label {
    opacity: .9;
    font-size: 13px;
}

.section-title {
    font-weight: 800;
    font-size: 22px;
    margin-top: 18px;
}

.msg-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

html[data-theme="dark"] .msg-row {
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.msg-row .icon {
    width: 26px;
    text-align: center;
    font-size: 18px;
}

.msg-row.priority {
    color: #dc3545;
    font-weight: 800;
}

.small-muted {
    color: var(--app-muted);
}

/* Status-Label im Header (Auslieferung AN/AUS) */
.app-status-meta{
    line-height: 1.05;
    text-align: right;
    user-select: none;
}

.app-status-title{
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.75);
    letter-spacing: .2px;
}

.app-status-state{
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .6px;
}

.app-status-state.on{
    color: rgba(255,255,255,.98);
}

.app-status-state.off{
    color: rgba(255,255,255,.85);
    opacity: .9;
}


/* =========================================================
   LIVEVIEW (LV3_) - Map + Overlays + Stopps
   ========================================================= */

.LV3_mapWrap{
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: var(--app-surface);
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

#LV3_map{
    height: 45vh;
    min-height: 250px;
    width: 100%;
    background: #e9ecef;
}

.LV3_overlayCard{
    position: absolute;
    z-index: 600;
    background: rgba(255,255,255,.92);
    color: var(--app-text);
    border-radius: 16px;
    padding: 12px 12px;
    box-shadow: 0 10px 22px rgba(0,0,0,.10);
    border: 1px solid rgba(0,0,0,.05);
    backdrop-filter: blur(6px);
}

html[data-theme="dark"] .LV3_overlayCard{
    background: rgba(23,24,26,.86);
    border: 1px solid rgba(255,255,255,.08);
}

/* kompakte Overlays (Map) */
.LV3_overlayMini{
    padding: 6px 10px;
    border-radius: 12px;
    box-shadow: 0 6px 14px rgba(0,0,0,.10);
}

.LV3_overlayTopBar{
    left: 12px;
    top: 12px;
    max-width: calc(100% - 72px); /* Platz für Standort-Button rechts */
}

.LV3_overlayTopLeft{ left: 12px; top: 12px; width: 160px; } /* legacy (nicht mehr genutzt) */
.LV3_overlayMidLeft{ left: 12px; top: 110px; width: 92px; text-align: center; } /* legacy (nicht mehr genutzt) */

.LV3_overlayBottomLeft{ left: 12px; bottom: 12px; width: auto; }

.LV3_topRow{
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}
.LV3_topRow i{ font-size: 14px; }
.LV3_topSep{ opacity: .45; font-weight: 700; }

.LV3_etaTitle{ font-weight: 900; font-size: 12px; } /* legacy */
.LV3_etaTime{ font-weight: 1000; font-size: 12px; margin-top: 0; }
.LV3_remainingNum{ font-weight: 1000; font-size: 12px; color: #dc3545; line-height: 1; }
.LV3_remainingIcon{ font-size: 26px; margin-bottom: 6px; } /* legacy */

.LV3_speedBox{
    background: transparent;
    border-radius: 0;
    padding: 0;
    font-weight: 1000;
    font-size: 12px;
    line-height: 1;
}
html[data-theme="dark"] .LV3_speedBox{
    background: transparent;
}

.LV3_floatBtns{
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 650;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.LV3_floatBtn{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 0;
    background: rgba(255,255,255,.92);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(0,0,0,.10);
    text-decoration: none;
}
.LV3_floatBtn i{ font-size: 16px; }


/* Leaflet Zoom (+/-) kompakter */
#LV3_map .leaflet-control-zoom{
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 14px rgba(0,0,0,.10);
}

/* Buttons */
#LV3_map .leaflet-control-zoom a{
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 16px;
    font-weight: 900;
}

/* Leaflet "touch" Mode überschreibt sonst Größen -> fix klein halten */
#LV3_map.leaflet-touch .leaflet-control-zoom a{
    width: 30px;
    height: 30px;
    line-height: 30px;
}

/* Trennlinie zwischen + und - */
#LV3_map .leaflet-control-zoom a + a{
    border-top: 1px solid rgba(0,0,0,.08);
}
html[data-theme="dark"] #LV3_map .leaflet-control-zoom a + a{
    border-top-color: rgba(255,255,255,.12);
}


html[data-theme="dark"] .LV3_floatBtn{
    background: rgba(23,24,26,.86);
    color: var(--app-text);
    border: 1px solid rgba(255,255,255,.08);
}

.LV3_listTitle{
    font-weight: 1000;
    font-size: 16px;
    margin-top: 12px;
    text-decoration: underline;
}

.LV3_stopCard{
    background: var(--app-surface);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    padding: 12px;
    margin-top: 10px;
}

.LV3_stopRow{
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,.08);
}
html[data-theme="dark"] .LV3_stopRow{
    border-bottom: 1px solid rgba(255,255,255,.10);
}
.LV3_stopRow:last-child{ border-bottom: 0; }

/* LV3: kurzer Klick-Flash (gelb) */
.LV3_rowFlash{
    animation: LV3_rowFlash 650ms ease-out 0s 1;
}
@keyframes LV3_rowFlash{
    0%   { background: rgba(255,193,7,.35); }
    100% { background: transparent; }
}

.LV3_actions{
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 140px;
}

.LV3_actionBtn{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: rgba(0,0,0,.06);
    color: var(--app-text);
}
html[data-theme="dark"] .LV3_actionBtn{
    background: rgba(255,255,255,.10);
}

.LV3_actionBtn:hover{ transform: translateY(-1px); }

.LV3_actionWarn{
    color: #dc3545 !important;
}

.LV3_stopMain{
    flex: 1;
    min-width: 0;
}
.LV3_stopLine1{
    font-weight: 1000;
    font-size: 13px;
    line-height: 1.15;
}
.LV3_stopLine2{
    font-weight: 1000;
    font-size: 16px;
    line-height: 1.12;
    color: var(--app-text);
    margin-top: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* Leaflet-Popup: Straße/Hausnummer für Fahrer besser lesbar */
#LV3_map .leaflet-popup-content{
    margin: 10px 12px;
    min-width: 190px;
    max-width: 260px;
}
.LV3_popupBox{
    line-height: 1.2;
}
.LV3_popupTitle{
    font-weight: 1000;
    font-size: 14px;
    color: var(--app-text);
}
.LV3_popupStreet{
    margin-top: 7px;
    font-size: 19px;
    line-height: 1.12;
    font-weight: 1000;
    color: #4B2415;
    word-break: break-word;
}
html[data-theme="dark"] #LV3_map .leaflet-popup-content-wrapper{
    background: rgba(255,255,255,.96);
    color: #111;
}
html[data-theme="dark"] #LV3_map .leaflet-popup-tip{
    background: rgba(255,255,255,.96);
}
html[data-theme="dark"] #LV3_map .leaflet-popup-close-button{
    color: #111;
}
html[data-theme="dark"] .LV3_popupTitle{
    color: #111;
}
html[data-theme="dark"] .LV3_popupStreet{
    color: #4B2415;
}

.LV3_completedBadge{
    font-size: 12px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(25,135,84,.12);
    color: #198754;
}

.LV3_hintMuted{
    color: var(--app-muted);
    font-size: 13px;
    margin-top: 8px;
}

/* Leaflet Zoom Buttons etwas "Appiger" (ohne Aufblasen) */
#LV3_map .leaflet-control-zoom a{
    border-radius: 0 !important;     /* Container hat schon Radius + overflow hidden */
    margin: 0 !important;            /* WICHTIG: kein extra Abstand zwischen + und - */
    box-shadow: none !important;     /* Schatten kommt vom Container */
}

/* LiveView Modal (LV3_) */
.LV3_modalContent{
  border-radius: 18px;
  border: 0;
  box-shadow: 0 14px 40px rgba(0,0,0,.18);
}

.LV3_modalStopCard{
  border-radius: 16px;
  padding: 14px;
  background: rgba(0,0,0,.04);
}

html[data-theme="dark"] .LV3_modalStopCard{
  background: rgba(255,255,255,.06);
}

/* LV3_ Fokus/Highlight nächster Stopp */
.LV3_focus {
  border-radius: 14px;
  outline: 3px solid rgba(255, 193, 7, .55);
  outline-offset: 4px;
  animation: LV3_focusPulse 1.2s ease-in-out 0s 2;
}

@keyframes LV3_focusPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, .50); }
  100% { box-shadow: 0 0 0 14px rgba(255, 193, 7, 0); }
}

/* LV3_ Foto wartet auf Upload (Offline-Queue) */
.LV3_photoQueued {
  background: rgba(255,193,7,.22) !important;
  outline: 2px dashed rgba(255,193,7,.65);
}

.LV3_stopRow{ cursor: pointer; }
.LV3_stopRow:active{ opacity: .85; }

/* App-Toast besser lesbar / nicht transparent */
#appToast{
    --bs-toast-bg: var(--app-surface);
    --bs-toast-color: var(--app-text);
    --bs-toast-border-color: rgba(0,0,0,.12);
    --bs-toast-box-shadow: 0 10px 26px rgba(0,0,0,.22);

    background: var(--app-surface) !important;
    color: var(--app-text) !important;
    border: 1px solid rgba(0,0,0,.12) !important;
    opacity: 1 !important;
    backdrop-filter: none !important;
}

#appToast .toast-body{
    font-weight: 800;
}

html[data-theme="dark"] #appToast{
    --bs-toast-bg: #17181a;
    --bs-toast-color: #f2f2f2;
    --bs-toast-border-color: rgba(255,255,255,.10);
    --bs-toast-box-shadow: 0 10px 26px rgba(0,0,0,.42);

    background: #17181a !important;
    color: #f2f2f2 !important;
    border: 1px solid rgba(255,255,255,.10) !important;
}

/* 3.5.0-rc1.1: Karten-Nachtmodus (nur Rasterkacheln, nicht Marker/Overlays). */
html[data-theme="dark"] #LV3_map,
html[data-theme="dark"] #AV_map {
    background: #202326;
}
html[data-theme="dark"] #LV3_map .leaflet-tile-pane,
html[data-theme="dark"] #AV_map .leaflet-tile-pane {
    filter: invert(.92) hue-rotate(180deg) saturate(.70) brightness(.86) contrast(.92);
}
html[data-theme="dark"] #LV3_map .leaflet-control-zoom a,
html[data-theme="dark"] #AV_map .leaflet-control-zoom a {
    background: #24272b;
    color: #f2f2f2;
    border-color: #41464c;
}
html[data-theme="dark"] #LV3_map .leaflet-control-zoom a.leaflet-disabled,
html[data-theme="dark"] #AV_map .leaflet-control-zoom a.leaflet-disabled {
    background: #24272b;
    color: #92989f;
}
html[data-theme="dark"] #LV3_map .leaflet-control-zoom a:not(.leaflet-disabled):hover,
html[data-theme="dark"] #AV_map .leaflet-control-zoom a:not(.leaflet-disabled):hover {
    background: #363c42;
}
/* Quellen bleiben sichtbar und verlinkt. Umbruch nur bei zu wenig Platz. */
#LV3_map .leaflet-bottom.leaflet-right,
#AV_map .leaflet-bottom.leaflet-right {
    max-width: 100%;
}
#LV3_map .leaflet-control-attribution,
#AV_map .leaflet-control-attribution {
    box-sizing: border-box;
    max-width: 100%;
    font-size: 11px;
    line-height: 1.35;
    padding: 2px 5px;
    text-align: right;
    white-space: normal;
    overflow-wrap: normal;
}
html[data-theme="dark"] #LV3_map .leaflet-control-attribution,
html[data-theme="dark"] #AV_map .leaflet-control-attribution {
    background: #24272b;
    color: #e5e7eb;
}
html[data-theme="dark"] #LV3_map .leaflet-control-attribution a,
html[data-theme="dark"] #AV_map .leaflet-control-attribution a {
    color: #a9d4ff;
}
/* Geschwindigkeitsanzeige oberhalb der Quellenzeile(n) halten. */
.LV3_overlayBottomLeft { bottom: 25px; }
@media (max-width: 380px) {
    .LV3_overlayBottomLeft { bottom: 38px; }
}
