/* ═══════════════════════════════════════════════════════════════════════════
 * SBF Phone Max — Globale Call-Screens
 * iOS-like: Anrufe überlagern JEDEN anderen UI-Layer (Lock-Screen, Home,
 * App-Container, App-Switcher). Wird gesteuert von ui/src/phone-calls.js.
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared Call-Overlay-Styles (Incoming + Outgoing) ────────────────── */
.phone-call-overlay {
    position: absolute;
    inset: 0;
    z-index: 2000;  /* über allem (lockscreen-edit=1840, notifications=1500) */
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.30s ease;
    /* pointer-events: kein Default, das aktive Overlay setzt es explizit.
       Wichtig: versteckte Overlays (opacity 0 oder display none) dürfen
       KEINE Klicks abfangen — sonst ist die Phone-App nach Call-Ende
       unbedienbar. */
    pointer-events: none !important;
    visibility: hidden;
    color: #fff;
    background: #1c1c1e;
    /* Runde Ecken wie das Phone-Frame (45px), damit der Call-UI-Hintergrund
       nicht über die Phone-Rundung hinausläuft. clip-path war vorher auf
       dem .phone-frame, aber das Overlay ist ein separates Layer und
       braucht sein eigenes border-radius + clip-path. */
    border-radius: 45px;
    clip-path: inset(0 round 45px);
    -webkit-clip-path: inset(0 round 45px);
}

.phone-call-overlay--active {
    opacity: 1;
    pointer-events: auto !important;  /* nur aktiv: Klicks fangen */
    visibility: visible;
}

/* Hintergrund-Layer — bekommt das Wallpaper via JS gesetzt (siehe
   phoneCallManager._refreshWallpaper()). Blur + leichtes Overlay
   sorgen für Lesbarkeit der Texte. */
.phone-call-overlay .phone-call-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Blur + leichte Abdunklung in einem Layer */
    filter: blur(4px);
    transform: scale(1.15);  /* verhindert weiße Ränder durch den Blur */
}

/* Zusätzlicher dunkler Overlay-Gradient (lesbarer Text über busy Wallpaper) */
.phone-call-overlay .phone-call-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 20%, rgba(0,0,0,0.15), transparent 60%),
        linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
}

/* Theme-Klassen bestimmen Textfarbe (Wallpaper ist immer blur+dark) */
.phone-call-overlay.theme-light {
    color: #fff;  /* Text bleibt weiß wegen Overlay */
}
.phone-call-overlay.theme-dark {
    color: #fff;
}

.phone-call-overlay .phone-call-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    padding: 80px 32px 60px;
    box-sizing: border-box;
}

/* ── Avatar entfernt — User-Wunsch: kein Profilbild mehr zeigen ────── */
/* (Avatar-Element existiert nicht mehr im HTML, aber Selector bleibt für
   Abwärtskompatibilität falls andere Apps noch darauf zugreifen.) */
.phone-call-overlay .phone-call-avatar {
    display: none !important;
}

/* ── Name + Status ──────────────────────────────────────────────────── */
.phone-call-overlay .phone-call-name {
    font-size: 28px;
    font-weight: 600;
    margin-top: 24px;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.phone-call-overlay .phone-call-status {
    font-size: 16px;
    font-weight: 400;
    margin-top: 8px;
    opacity: 0.7;
    text-align: center;
}

.phone-call-overlay .phone-call-mobile {
    font-size: 14px;
    margin-top: 4px;
    opacity: 0.55;
    text-align: center;
}

.phone-call-overlay .phone-call-spacer {
    flex: 1 1 auto;
}

/* ── Action-Buttons ────────────────────────────────────────────────── */
.phone-call-overlay .phone-call-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 80px;
    width: 100%;
}

.phone-call-overlay .phone-call-btn {
    width: 65px;
    height: 65px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.15s ease;
    color: #fff;
    background: #FF3B30;  /* Decline + End sind rot */
}
.phone-call-overlay .phone-call-btn:active {
    transform: scale(0.92);
}
.phone-call-overlay .phone-call-btn svg {
    width: 36px;
    height: 36px;
}

.phone-call-overlay .phone-call-btn--accept {
    background: #34C759;  /* Accept = grün */
}

/* ── iOS-Homebar (immer light) ──────────────────────────────────────── */
/* Untere Bar im Call-Overlay — Tap minimiert den Call in die Dynamic
   Island. Wird per JS erst nach Connect eingeblendet (während Ringing
   wäre sie ein versehentlicher Decline-Hotspot). */
.phone-call-homebar {
    position: absolute;
    left: 50%;
    bottom: 4px;
    transform: translateX(-50%);
    width: 130px;
    height: 5px;
    background: rgba(255, 255, 255, 0.92);  /* IMMER light, auch im Dark-Theme */
    border-radius: 3px;
    z-index: 5;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.15s ease;
    pointer-events: auto;
}
.phone-call-homebar:active {
    transform: translateX(-50%) scaleX(1.15);
    background: rgba(255, 255, 255, 0.7);
}

/* ── Minimiert: Call-Overlay komplett ausblenden, nur noch Mini-View
   in der Dynamic Island sichtbar ───────────────────────────────────── */
.phone-call-overlay--minimized {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    /* KEIN display:none — sonst verschwindet der Timer, der vom
       phone-call-overlay--active-Overlay getrennt im Dynamic Island lebt */
}

/* ── Dynamic-Island Call-Mini (2. DI) — verdeckt die originale DI 1:1 ──
   Position/Aussehen sind 1:1 wie das Original-DI, nur Inhalt = SVG + Timer.
   z-index höher (2600) als Original-DI (2500), damit Lock-Icon/Kamera-Dot
   nicht mehr sichtbar sind. */
.dynamic-island-call {
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 30px;
    background: #000000;
    border-radius: 20px;
    z-index: 2600;  /* über Original-DI (2500) und Statusbar (2100) */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.dynamic-island-call .di-call-icon {
    width: 14px;
    height: 14px;
    fill: #34C759;  /* iOS-Call-Green */
    flex-shrink: 0;
}
.dynamic-island-call .di-call-timer {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}

/* ── Timer im großen Call-Overlay (nicht nur im Mini-View) ───────── */
.phone-call-overlay .phone-call-timer {
    font-size: 14px;
    font-weight: 500;
    margin-top: 4px;
    opacity: 0.6;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* ── Connected-Toolbar (Mute + Contacts im Liquid Glass, End-Button separat) ──
   Wird per JS bei Connect eingeblendet (display:none → display:flex).
   Ersetzt die bisherige einzelne End-Button-Reihe im Connected-State. */
.phone-call-overlay .phone-call-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    width: 100%;
    animation: phone-call-toolbar-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes phone-call-toolbar-in {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Liquid-Glass-Container für Mute + Contacts (1:1 wie Apple iOS Call) */
.phone-call-overlay .phone-call-toolbar-glass {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 22px;
    border-radius: 32px;
    background-color: rgba(120, 120, 128, 0.32);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
        inset 0 0 0 1px           rgb(255 255 255 / 12%),
        inset 1.8px 3px 0 -2px    rgb(255 255 255 / 30%),
        inset -2px -2px 0 -2px    rgb(255 255 255 / 18%),
        inset -3px -8px 1px -6px  rgb(255 255 255 / 14%),
        inset 0.3px 1px 4px 0     rgb(0 0 0 / 14%),
        inset 1.5px 2.5px 0 -2px  rgb(0 0 0 / 18%),
        inset 0 3px 4px -2px      rgb(0 0 0 / 22%),
        inset 2px -6.5px 1px -4px rgb(0 0 0 / 12%),
        0 1px 5px 0               rgb(0 0 0 / 10%),
        0 6px 16px 0              rgb(0 0 0 / 8%);
}

/* Einzelner Tool-Button (Mute, Contacts) — Icon + Label untereinander */
.phone-call-overlay .phone-call-tool {
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    background: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-width: 76px;
    border-radius: 20px;
    transition: transform 0.12s ease, opacity 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}
.phone-call-overlay .phone-call-tool:active {
    transform: scale(0.92);
}
.phone-call-overlay .phone-call-tool svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
    /* KEIN color hier setzen — sonst überschreibt es die currentColor-Quelle
       des SVG und das Parent's color:#FF453A (data-muted) greift nicht.
       fill: currentColor erbt automatisch vom Parent (.phone-call-tool),
       das per [data-muted="true"] auf rot geschaltet wird. */
    opacity: 0.95;
    transition: opacity 0.15s ease, color 0.15s ease;
}
/* Mute-Toggle: SVG-Farbe wechselt von weiß → rot (iOS systemRed).
   Wir setzen color auf dem Button selbst (Parent), nicht auf dem SVG,
   damit currentColor im SVG die Farbe übernimmt. */
.phone-call-overlay .phone-call-tool[data-muted="true"] { color: #FF453A; }
.phone-call-overlay .phone-call-tool[data-muted="true"] svg { color: #FF453A; fill: #FF453A; }

.phone-call-overlay .phone-call-tool-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.92;
    text-align: center;
    white-space: nowrap;
}

/* End-Button innerhalb Toolbar — gleiches Styling wie Decline/End,
   aber als alleinstehender Button unter dem Glass-Container. */
.phone-call-overlay .phone-call-btn--end-active {
    width: 65px;
    height: 65px;
}
