/* PostScan.cloud – Mobile First CSS (Multi-User Edition) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg:      #0f0f13;
    --bg2:     #16161d;
    --bg3:     #1e1e28;
    --border:  rgba(255,255,255,0.08);
    --text:    #e8e6f0;
    --muted:   #7a7890;
    --accent:  #7c6ff7;
    --accent2: #a594f9;
    --green:   #22c97a;
    --red:     #f25f5c;
    --amber:   #f5a623;
    --radius:  14px;
    --radius-sm: 8px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bot: env(safe-area-inset-bottom, 0px);
    /* CSS-Variablen-Kurzformen für setup.php */
    --ac: #22c97a;
    --re: #f25f5c;
    --bg4: #26263a;
}

/* Light Mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg:    #f5f4f8;
        --bg2:   #ffffff;
        --bg3:   #ebebf0;
        --bg4:   #e0dff0;
        --border: rgba(0,0,0,0.08);
        --text:  #1a1824;
        --muted: #8885a0;
        --accent: #6355e8;
        --accent2: #7c6ff7;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-shell {
    min-height: 100dvh;
    padding-top: calc(60px + var(--safe-top));
    padding-bottom: calc(70px + var(--safe-bot));
}
.container { max-width: 600px; margin: 0 auto; padding: 20px 16px; }
.page { padding: 16px; max-width: 600px; margin: 0 auto; }

/* ── TopBar ──────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(60px + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--bg2);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-action {
    background: none; border: none;
    color: var(--accent); font-size: 15px;
    cursor: pointer; padding: 8px;
    text-decoration: none; transition: opacity .15s;
}
.topbar-action:active { opacity: .7; }

/* ── BottomNav ───────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(60px + var(--safe-bot));
    padding-bottom: var(--safe-bot);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; padding: 8px 4px;
    text-decoration: none; color: var(--muted);
    font-size: 10px; font-weight: 500;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; line-height: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}
.card-body { padding: 14px 16px; }

/* ── Letter Card ─────────────────────────────────────────── */
.letter-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    transition: background .12s;
}
.letter-card:active { background: var(--bg3); }
.letter-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.letter-body { flex: 1; min-width: 0; }
.letter-sender { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.letter-subject { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.letter-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.letter-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.badge-rechnung  { background: rgba(242,95,92,.15); color: var(--red); }
.badge-mahnung   { background: rgba(245,166,35,.15); color: var(--amber); }
.badge-brief     { background: rgba(124,111,247,.15); color: var(--accent); }
.badge-default   { background: var(--bg3); color: var(--muted); }

/* ── Senders ─────────────────────────────────────────────── */
.sender-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    text-decoration: none; color: var(--text);
    -webkit-tap-highlight-color: transparent;
    transition: background .12s;
}
.sender-item:active { background: var(--bg3); }
.sender-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sender-count {
    background: var(--accent);
    color: white;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    min-width: 22px;
    text-align: center;
}

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(124,111,247,.15) 0%, transparent 60%), var(--bg);
}
.login-box {
    width: 100%; max-width: 380px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 36px 28px;
    box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.login-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-sub   { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 32px; }

/* ── Inputs ──────────────────────────────────────────────── */
input[type="password"],
input[type="text"],
input[type="search"],
input[type="email"] {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    padding: 13px 14px;
    outline: none;
    -webkit-appearance: none;
    transition: border-color .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,111,247,.15); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn, button.btn {
    display: block;
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    padding: 14px;
    cursor: pointer;
    margin-top: 12px;
    text-align: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .15s, transform .1s;
}
.btn:active { opacity: .85; transform: scale(.99); }
.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-danger {
    background: rgba(242,95,92,.15);
    color: var(--red);
    border: 1px solid rgba(242,95,92,.3);
}
.btn-sm {
    width: auto;
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    margin-top: 0;
}
.btn-primary { background: var(--accent); color: white; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert-err {
    background: rgba(242,95,92,.12);
    border: 1px solid rgba(242,95,92,.3);
    color: var(--red);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 14px;
}
.alert-ok {
    background: rgba(34,201,122,.1);
    border: 1px solid rgba(34,201,122,.3);
    color: var(--green);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 14px;
}

/* ── Divider / Headings ──────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.section-heading {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 16px 16px 8px;
}

/* ── Detail-Seite ────────────────────────────────────────── */
.detail-preview {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: contain;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    display: block;
}
.detail-summary {
    background: rgba(124,111,247,.08);
    border: 1px solid rgba(124,111,247,.2);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}
.meta-row {
    display: flex; justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 12px;
}
.meta-row:last-child { border-bottom: none; }
.meta-label { color: var(--muted); white-space: nowrap; }

/* ── Suchfeld ────────────────────────────────────────────── */
.search-wrap {
    padding: 12px 16px;
    position: sticky;
    top: calc(60px + var(--safe-top));
    z-index: 50;
    background: var(--bg);
}
.search-input {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 10px 16px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
    transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

/* ── Empty State ─────────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 15px; }

/* ── Settings / Forms ────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.4;
}
.form-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    padding: 11px 14px;
    outline: none;
    -webkit-appearance: none;
    transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,111,247,.15); }

/* Settings Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg3);
    border-radius: 99px;
    padding: 3px;
    margin-bottom: 20px;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    transition: all .15s;
}
.tab.active {
    background: var(--accent);
    color: white;
}

/* Scan-Adresse Row */
.addr-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.addr-row:last-child { border-bottom: none; }
.addr-email { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.addr-delete {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    opacity: .7;
    transition: opacity .15s;
    flex-shrink: 0;
}
.addr-delete:hover { opacity: 1; }

/* User-Liste (Admin) */
.user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.role-badge {
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px;
    text-transform: uppercase;
}
.role-admin { background: rgba(124,111,247,.2); color: var(--accent); }
.role-user  { background: var(--bg3); color: var(--muted); }

/* ── Cron-Log Viewer ─────────────────────────────────────── */
.log-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    color: var(--muted);
}

/* ── KI-Chat ─────────────────────────────────────────────── */
.chat-msg { margin-bottom: 10px; }
.chat-user { text-align: right; }
.chat-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    text-align: left;
}
.chat-user .chat-bubble,
.chat-bubble.chat-user {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.chat-ai {
    background: var(--bg3);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.chat-action-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
}
.chat-action-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ── Utility ─────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 11px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
