/* ═══════════════════════════════════════════════════════════════
   GPS-Tracker · iOS-Style Design
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Doppeltipp-Zoom auf iOS deaktivieren ohne Scroll zu beeinträchtigen */
html { touch-action: manipulation; }

:root {
    /* iOS System Colors */
    --bg:           #F2F2F7;
    --bg-elevated:  #FFFFFF;
    --tint:         #FF3B30;
    --tint-dk:      #D70015;
    --green:        #34C759;
    --green-dk:     #248A3D;
    --blue:         #007AFF;
    --label:        #000000;
    --label2:       #3C3C43CC;
    --label3:       #3C3C4399;
    --label4:       #3C3C4360;
    --sep:          rgba(60,60,67,.18);
    --sep-opaque:   #C6C6C8;
    --fill:         rgba(120,120,128,.12);
    --fill2:        rgba(120,120,128,.08);

    /* Spacing & Shape */
    --r-card:  13px;
    --r-btn:   14px;
    --r-pill:  20px;
    --safe-t:  env(safe-area-inset-top, 0px);
    --safe-b:  env(safe-area-inset-bottom, 0px);
}

html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    color: var(--label);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ── iOS Navigation Bar ───────────────────────────────────────── */
.ios-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: calc(var(--safe-t) + .55rem) 1rem .55rem;
    background: rgba(242,242,247,.82);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: .5px solid var(--sep-opaque);
}
.ios-nav-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.01em;
}
.ios-nav-action {
    font-size: .88rem;
    color: var(--tint);
    font-weight: 500;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .1rem 0;
}

/* ── Scrollbarer Inhalt ───────────────────────────────────────── */
main {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1rem calc(1.5rem + var(--safe-b));
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    max-width: 430px;
    width: 100%;
    margin: 0 auto;
}

/* ── iOS Section Header ───────────────────────────────────────── */
.section-header {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--label3);
    margin-top: .5rem;
    margin-bottom: .35rem;
    padding-left: .2rem;
}

/* ── iOS Grouped Card ─────────────────────────────────────────── */
.ios-card {
    background: var(--bg-elevated);
    border-radius: var(--r-card);
    overflow: hidden;
}
.ios-card-row {
    display: flex;
    align-items: center;
    padding: .8rem 1rem;
    gap: .75rem;
    position: relative;
}
.ios-card-row + .ios-card-row::before {
    content: '';
    position: absolute;
    top: 0; left: 1rem; right: 0;
    height: .5px;
    background: var(--sep);
}
.ios-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.icon-red   { background: var(--tint);  color: #fff; }
.icon-green { background: var(--green); color: #fff; }
.icon-blue  { background: var(--blue);  color: #fff; }
.icon-gray  { background: #8E8E93;      color: #fff; }

.ios-card-content { flex: 1; min-width: 0; }
.ios-card-label   { font-size: .95rem; font-weight: 400; }
.ios-card-sub     { font-size: .78rem; color: var(--label3); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ios-card-value   { font-size: .88rem; color: var(--label3); white-space: nowrap; }
.ios-card-chevron { color: var(--label4); font-size: .75rem; margin-left: .25rem; }

/* ── GPS-Status Pill ──────────────────────────────────────────── */
.gps-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--fill);
    border-radius: 20px;
    padding: .35rem .85rem;
    font-size: .8rem;
    color: var(--label2);
    margin: 0 auto;
}
.gps-pill .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #8E8E93;
    transition: background .3s;
}
.gps-pill.ok  .dot { background: var(--green); }
.gps-pill.err .dot { background: var(--tint);  }
.gps-pill.ok       { color: var(--label);       }

/* ── Standort-Chips (iOS Pill Style) ─────────────────────────── */
.chips-wrap { display: flex; flex-wrap: wrap; gap: .45rem; padding: .1rem 0; }
.chip {
    background: var(--fill);
    border: none;
    border-radius: var(--r-pill);
    padding: .38rem .85rem;
    font-size: .82rem;
    font-family: inherit;
    color: var(--label);
    cursor: pointer;
    transition: all .15s;
    -webkit-user-select: none;
    user-select: none;
}
.chip:active { transform: scale(.95); }
.chip.active {
    background: var(--tint);
    color: #fff;
}

/* ── iOS Action-Button (Rounded Rectangle) ────────────────────── */
.btn-action-wrap { padding: .25rem 0; }

.btn-action-big {
    width: 100%;
    padding: 1.1rem 1.5rem;
    border-radius: 16px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #fff;
    cursor: pointer;
    transition: transform .1s cubic-bezier(.34,1.3,.64,1), opacity .1s;
    -webkit-user-select: none;
    user-select: none;
}
.btn-action-big:active   { transform: scale(.97); opacity: .88; }
.btn-action-big:disabled { opacity: .4; cursor: default; }
.btn-action-big .btn-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}
.btn-start-big {
    background: linear-gradient(135deg, #4cd964 0%, var(--green-dk) 100%);
    box-shadow: 0 4px 18px rgba(52,199,89,.4);
}
.btn-stop-big {
    background: linear-gradient(135deg, #ff6b6b 0%, var(--tint-dk) 100%);
    box-shadow: 0 4px 18px rgba(255,59,48,.4);
}

/* ── Status-Karte (Running) ───────────────────────────────────── */
.status-indicator {
    text-align: center;
    padding: .5rem;
}
.status-indicator .status-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    margin-right: .4rem;
    animation: statusPulse 1.6s ease-in-out infinite;
}
@keyframes statusPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(52,199,89,.5); }
    50%      { box-shadow: 0 0 0 7px rgba(52,199,89,0); }
}
.status-indicator .status-label {
    font-size: .88rem;
    font-weight: 500;
    color: var(--green);
    vertical-align: middle;
}

/* ── Adress-Zeile ─────────────────────────────────────────────── */
.addr-section {
    padding: .9rem 1rem;
}
.addr-item {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .3rem 0;
}
.addr-dot { font-size: .65rem; padding-top: .35rem; flex-shrink: 0; }
.addr-text { font-size: .9rem; line-height: 1.35; }
.addr-label { font-size: .7rem; color: var(--label3); margin-bottom: .05rem; }
.addr-connector { width: 1px; height: 12px; background: var(--sep-opaque); margin-left: .35rem; }

/* ── km-Badge ─────────────────────────────────────────────────── */
.km-section {
    padding: .5rem 1rem .9rem;
    border-top: .5px solid var(--sep);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}
.km-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--tint);
    font-variant-numeric: tabular-nums;
}
.km-label { font-size: .82rem; color: var(--label3); }

/* ── iOS-Formular ─────────────────────────────────────────────── */
.ios-form-row {
    display: flex;
    align-items: center;
    padding: .8rem 1rem;
    gap: .75rem;
    position: relative;
}
.ios-form-row + .ios-form-row::before {
    content: '';
    position: absolute;
    top: 0; left: 1rem; right: 0;
    height: .5px;
    background: var(--sep);
}
.ios-form-label {
    font-size: .9rem;
    color: var(--label);
    flex-shrink: 0;
    width: 90px;
}
.ios-form-row input[type="text"],
.ios-form-row select {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: .9rem;
    color: var(--label);
    background: transparent;
    text-align: right;
    min-width: 0;
}
.ios-form-row input::placeholder { color: var(--label4); }
.ios-form-row select { text-align-last: right; }

.ios-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    position: relative;
}
.ios-toggle-row::before {
    content: '';
    position: absolute;
    top: 0; left: 1rem; right: 0;
    height: .5px;
    background: var(--sep);
}
.ios-toggle-label { font-size: .9rem; }
.ios-switch {
    position: relative;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 31px;
    background: var(--sep-opaque);
    transition: background .22s;
}
.ios-switch input:checked + .ios-switch-track { background: var(--green); }
.ios-switch-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 27px; height: 27px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
    transition: transform .22s cubic-bezier(.34,1.3,.64,1);
}
.ios-switch input:checked + .ios-switch-track::after {
    transform: translateX(20px);
}

/* ── iOS Buttons (Formular-Footer) ────────────────────────────── */
.ios-btn-row {
    display: flex;
    gap: .6rem;
    padding: 0 .25rem;
}
.ios-btn {
    flex: 1;
    padding: .8rem;
    border: none;
    border-radius: var(--r-btn);
    font-family: inherit;
    font-size: .97rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .12s, transform .08s;
    -webkit-user-select: none;
}
.ios-btn:active { opacity: .75; transform: scale(.98); }
.ios-btn:disabled { opacity: .4; cursor: default; }
.ios-btn-primary  { background: var(--tint); color: #fff; }
.ios-btn-secondary { background: var(--fill); color: var(--label); }

/* ── Letzte Fahrten ───────────────────────────────────────────── */
.trip-item-body { flex: 1; min-width: 0; }
.trip-item-title {
    font-size: .9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.trip-cat {
    font-size: .68rem;
    font-weight: 600;
    background: var(--fill);
    border-radius: 5px;
    padding: .1rem .4rem;
    color: var(--label3);
}
.trip-item-sub {
    font-size: .76rem;
    color: var(--label3);
    margin-top: .15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.trip-item-right { text-align: right; flex-shrink: 0; }
.trip-km   { font-size: .88rem; font-weight: 600; color: var(--tint); }
.trip-amt  { font-size: .72rem; color: var(--label3); }
.trip-date { font-size: .72rem; color: var(--label3); }

.trip-empty {
    padding: 1.2rem 1rem;
    text-align: center;
    color: var(--label3);
    font-size: .88rem;
}

/* ── Erfolgs-Screen ───────────────────────────────────────────── */
.success-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .9rem;
    padding: 2rem 1rem;
    text-align: center;
}
.success-checkmark {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: #fff;
    animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-title { font-size: 1.35rem; font-weight: 700; }
.success-detail { font-size: .88rem; color: var(--label3); }

/* ── Login — identisch zum Portal-Backend ─────────────────────── */
body.login-page { background: #f8f9fa; }

.login-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    min-height: 100dvh;
    background: #f8f9fa;
}
#login-checking {
    text-align: center;
}
.login-checking-text {
    color: #999;
    font-size: .9rem;
    margin-top: .5rem;
}
.login-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    padding: 2rem 1.75rem;
    width: 100%;
    max-width: 400px;
}
@media (min-width: 420px) {
    .login-box { padding: 2.5rem; }
}

.login-logo {
    color: #c0392b;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .2rem;
}
.login-sub {
    text-align: center;
    font-size: .875rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
}
.login-error {
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    color: #842029;
    border-radius: 5px;
    padding: .55rem .9rem;
    font-size: .88rem;
    margin-bottom: 1rem;
}
.login-field { margin-bottom: .9rem; }
.login-field-last { margin-bottom: 1.25rem; }
.login-label {
    display: block;
    font-weight: 600;
    font-size: .875rem;
    margin-bottom: .3rem;
    color: #212529;
}
.login-input {
    display: block;
    width: 100%;
    padding: .55rem .75rem;
    font-size: .95rem;
    font-family: inherit;
    color: #212529;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    transition: border-color .15s, box-shadow .15s;
}
.login-input:focus {
    outline: none;
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192,57,43,.15);
}
.login-btn {
    display: block;
    width: 100%;
    padding: .6rem;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.login-btn:hover   { background: #96281b; }
.login-btn:active  { background: #96281b; }

/* ── Swipe-to-delete ──────────────────────────────────────────── */

/* Äußerer Container: clippt den off-screen Delete-Button */
.trip-item { overflow: hidden; }

/* Gleit-Schiene: Content + Delete-Button nebeneinander */
.trip-slide { display: flex; }

/* Sichtbarer Inhaltsbereich füllt immer die volle Breite */
.trip-content {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1rem;
    background: var(--bg-elevated);
    width: 100%;
    flex-shrink: 0;
    position: relative;
}
.trip-content:active { background: var(--fill2); }
.trip-item + .trip-item .trip-content::before {
    content: '';
    position: absolute;
    top: 0; left: 1rem; right: 0;
    height: .5px;
    background: var(--sep);
}

/* Löschen-Button: startet rechts außerhalb, wird durch Swipe sichtbar */
.trip-delete-reveal {
    min-width: 82px;
    width: 82px;
    flex-shrink: 0;
    background: #FF3B30;
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    align-self: stretch;
    -webkit-user-select: none;
    user-select: none;
}
html.dark .trip-content { background: var(--bg-elevated); }

/* Delete-Button: immer sichtbar, Swipe als zusätzliche Option */
.btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--tint);
    font-size: 1.1rem;
    padding: .25rem .35rem;
    border-radius: 7px;
    flex-shrink: 0;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity .12s;
}
.btn-delete:active { opacity: .45; }

/* ── Utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.center { display: flex; flex-direction: column; align-items: center; }

/* ════════════════════════════════════════════════════════════════
   Dark Mode  — gesteuert über html.dark (JS-Toggle + System-Pref)
   ════════════════════════════════════════════════════════════════ */
html.dark {
    --bg:          #000000;
    --bg-elevated: #1C1C1E;
    --label:       #FFFFFF;
    --label2:      rgba(235,235,245,.6);
    --label3:      rgba(235,235,245,.3);
    --label4:      rgba(235,235,245,.18);
    --sep:         rgba(84,84,88,.65);
    --sep-opaque:  #38383A;
    --fill:        rgba(120,120,128,.36);
    --fill2:       rgba(120,120,128,.2);
}
html.dark body { background: var(--bg); color: var(--label); }

html.dark .ios-nav {
    background: rgba(28,28,30,.88);
    border-bottom-color: var(--sep-opaque);
}
html.dark .ios-card,
html.dark .trip-item-inner   { background: var(--bg-elevated); }
html.dark .ios-form-row input,
html.dark .ios-form-row select { color: var(--label); background: transparent; }
html.dark .ios-form-row input::placeholder { color: var(--label4); }
html.dark .chip        { background: rgba(120,120,128,.28); color: var(--label); border-color: transparent; }
html.dark .chip.active { background: var(--tint); color: #fff; }
html.dark .trip-cat    { background: rgba(120,120,128,.36); color: var(--label3); }
html.dark .km-badge    { background: rgba(255,214,10,.15); border-color: rgba(255,214,10,.35); color: #FFD60A; }
html.dark .gps-pill    { background: rgba(120,120,128,.24); }
html.dark .gps-pill.ok  { color: var(--label); }
html.dark .gps-pill.err { color: var(--tint); }
html.dark .ios-btn-secondary { background: #2C2C2E; color: var(--label); }
html.dark .success-title { color: var(--green); }

/* Login Dark */
html.dark .login-wrap  { background: #000; }
html.dark .login-box   { background: #1C1C1E; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
html.dark .login-logo  { color: #FF3B30; }
html.dark .login-sub   { color: rgba(235,235,245,.5); }
html.dark .login-label { color: #fff; }
html.dark .login-input { background: #2C2C2E; border-color: #38383A; color: #fff; }
html.dark .login-input:focus { border-color: #FF3B30; box-shadow: 0 0 0 3px rgba(255,59,48,.2); }
html.dark .login-error { background: rgba(255,59,48,.2); border-color: rgba(255,59,48,.4); color: #FF6B6B; }
html.dark .login-btn   { background: #FF3B30; }
html.dark .login-btn:hover,
html.dark .login-btn:active { background: #D70015; }

