/* ════════════════════════════════════════════════════════
   PeopleCRM – Dark Glassmorphism Design System
   ════════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a0f;
    --bg-elevated: #13131a;
    --glass: rgba(255, 255, 255, 0.06);
    --glass-strong: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.12);
    --border-soft: rgba(255, 255, 255, 0.07);
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #71717a;
    --accent: #8b5cf6;
    --accent-2: #6366f1;
    --accent-grad: linear-gradient(135deg, #8b5cf6, #6366f1);
    --danger: #f87171;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Dezenter violetter Glow im Hintergrund */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(ellipse 60% 40% at 90% 110%, rgba(99, 102, 241, 0.10), transparent 60%);
    pointer-events: none;
}

::selection { background: rgba(139, 92, 246, 0.4); }

/* ─── Glas-Grundfläche ─────────────────────────────────── */
.glass {
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ─── Topbar ───────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    background: rgba(10, 10, 15, 0.75);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto;
}

.topbar-spacer { flex: 1; }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.brand h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-grad);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.8);
}

/* ─── Suche ────────────────────────────────────────────── */
.search-wrap {
    position: relative;
    max-width: 640px;
    margin: 10px auto 0;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
}

.search-input {
    padding-left: 44px;
    border-radius: 999px;
}

input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-input { padding-right: 52px; }

.ai-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #fff;
    background: var(--accent-grad);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.4);
    transition: transform 0.15s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.ai-btn:active { transform: translateY(-50%) scale(0.9); }

.ai-btn.ai-loading svg {
    animation: ai-spin 1s linear infinite;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

.ai-status {
    max-width: 640px;
    margin: 8px auto 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.ai-reason {
    display: block;
    margin-top: 6px;
    padding: 5px 10px;
    font-size: 13px;
    line-height: 1.45;
    color: #d8ccff;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 10px;
}

/* ─── Inputs & Buttons ─────────────────────────────────── */
.input {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font: inherit;
    font-size: 16px; /* verhindert iOS-Zoom */
    color: var(--text);
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.input::placeholder { color: var(--faint); }

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    background: var(--glass-strong);
}

textarea.input { resize: none; line-height: 1.5; }

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin: 16px 2px 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.optional { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 22px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    color: #fff;
    background: var(--accent-grad);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover { box-shadow: 0 4px 28px rgba(139, 92, 246, 0.55); }

.btn-ghost {
    color: var(--muted);
    background: var(--glass);
    border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); background: var(--glass-strong); }

.btn-block { width: 100%; margin-top: 20px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: var(--muted);
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s, background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover { color: var(--text); background: var(--glass-strong); }
.icon-btn:active { transform: scale(0.92); }
.icon-danger:hover { color: var(--danger); }
.icon-sm { width: 34px; height: 34px; border: none; background: transparent; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ─── Content ──────────────────────────────────────────── */
.content {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px calc(110px + var(--safe-bottom));
}

/* ─── Personen-Liste ───────────────────────────────────── */
.people-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.person-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.person-card:hover {
    background: var(--glass-strong);
    border-color: rgba(139, 92, 246, 0.4);
}

.person-card:active { transform: scale(0.98); }

.person-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.person-name {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.person-prof {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
}

.person-note {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 3px;
    min-width: 0;
}

.note-preview {
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.note-time {
    font-size: 12px;
    color: var(--faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.chevron { color: var(--faint); flex-shrink: 0; }

/* ─── Avatare ──────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 50%;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    background: linear-gradient(135deg,
        hsl(var(--hue, 260), 70%, 58%),
        hsl(calc(var(--hue, 260) + 40), 72%, 46%));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(0, 0, 0, 0.35);
    user-select: none;
}

.avatar-lg { width: 88px; height: 88px; font-size: 30px; }

.avatar-photo { background: var(--bg-elevated); overflow: hidden; }

.avatar-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ─── Website-Link ─────────────────────────────────────── */
.website-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #d8ccff;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.website-link:hover { background: rgba(139, 92, 246, 0.24); }
.website-link:active { transform: scale(0.96); }

/* ─── Foto-Feld + Cropper ──────────────────────────────── */
.photo-actions { display: flex; gap: 8px; }

.btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.photo-current img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
    margin-bottom: 10px;
}

.cropper { margin-top: 12px; }

.crop-canvas {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    display: block;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    touch-action: none;
    cursor: grab;
}

.crop-canvas:active { cursor: grabbing; }

.crop-hint {
    text-align: center;
    font-size: 12px;
    color: var(--faint);
    margin: 8px 0 6px;
}

.crop-zoom {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    accent-color: var(--accent);
    min-height: 32px;
    cursor: pointer;
}

/* ─── Personen-Detail ──────────────────────────────────── */
.person-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 0 28px;
}

.person-title {
    margin-top: 14px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.person-subtitle {
    margin-top: 2px;
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
}

.person-meta {
    margin-top: 6px;
    font-size: 13px;
    color: var(--faint);
}

.section-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ─── Notizen ──────────────────────────────────────────── */
.notes-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card { padding: 14px 16px; }

.note-latest { border-color: rgba(139, 92, 246, 0.45); }

.note-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.note-date {
    font-size: 12px;
    color: var(--faint);
    flex: 1;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    color: #d8ccff;
    background: rgba(139, 92, 246, 0.22);
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.note-body {
    font-size: 15px;
    color: var(--text);
    overflow-wrap: break-word;
}

/* ─── Composer (Notiz-Eingabe unten) ───────────────────── */
.composer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto;
    padding: 10px 16px calc(12px + var(--safe-bottom));
    background: rgba(10, 10, 15, 0.85);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-soft);
}

.composer-main {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.composer-date-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    font-size: 13px;
    color: var(--muted);
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}

.composer-date {
    font: inherit;
    font-size: 13px;
    color: var(--muted);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    cursor: pointer;
}

.composer-date::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.composer-input {
    flex: 1;
    max-height: 130px;
    border-radius: 22px;
}

.btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    color: #fff;
    background: var(--accent-grad);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    transition: transform 0.15s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-send:active { transform: scale(0.9); }

/* ─── FAB ──────────────────────────────────────────────── */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(24px + var(--safe-bottom));
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    color: #fff;
    background: var(--accent-grad);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(139, 92, 246, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.fab:hover { box-shadow: 0 8px 36px rgba(139, 92, 246, 0.7); }
.fab:active { transform: scale(0.92); }

/* ─── Bottom-Sheet ─────────────────────────────────────── */
/* hidden-Attribut muss display:flex schlagen, sonst blockiert das
   unsichtbare Overlay alle Klicks auf der Seite */
.sheet-backdrop[hidden] { display: none !important; }

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s;
}

.sheet-backdrop.open { opacity: 1; }

.sheet {
    width: 100%;
    max-width: 640px;
    max-height: 88dvh;
    overflow-y: auto;
    padding: 10px 20px calc(24px + var(--safe-bottom));
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    box-shadow: var(--shadow);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-backdrop.open .sheet { transform: translateY(0); }

.sheet-handle {
    width: 40px;
    height: 4px;
    margin: 4px auto 14px;
    border-radius: 999px;
    background: var(--border);
}

.sheet-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.sheet-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.sheet-actions .btn { flex: 1; }

/* ─── KI-Vorschlag ─────────────────────────────────────── */
.suggest-original {
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted);
    background: var(--glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    max-height: 130px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.website-summary { font-size: 13px; }

/* Ladeanzeige während der KI-Umformulierung */
.ai-toast {
    position: fixed;
    left: 50%;
    bottom: calc(110px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid rgba(139, 92, 246, 0.5);
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.25);
    white-space: nowrap;
    pointer-events: none;
}

.ai-toast .spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}

.summary-pending { color: var(--faint); font-style: italic; }

.btn-send.ai-loading svg {
    animation: ai-spin 1s linear infinite;
}

.btn-send[disabled] { opacity: 0.6; cursor: wait; }

/* ─── Login ────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 16px;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    color: #fff;
    background: var(--accent-grad);
    border-radius: 22px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.5);
    margin-bottom: 18px;
}

.login-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.login-sub {
    color: var(--muted);
    margin-top: 4px;
    margin-bottom: 28px;
}

.login-card {
    width: 100%;
    padding: 24px;
    text-align: left;
}

.login-card .field-label { margin-top: 0; }

.form-error {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--danger);
}

/* ─── Empty States ─────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 64px 24px;
    color: var(--muted);
}

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    color: var(--accent);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    margin-bottom: 18px;
}

.empty-state h2 {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p { max-width: 320px; font-size: 15px; }

.empty-compact { padding: 28px 16px; }

.hidden { display: none !important; }

/* ─── Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (min-width: 640px) {
    .fab { right: calc(50% - 320px + 20px); }
}
