/* 🆘 SosButton — fixed-position emergency button for seniors */

#sos-button-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 8500;
    pointer-events: none;
}

#sos-button-root > * { pointer-events: auto; }

.sos-btn {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    box-shadow: 0 6px 24px rgba(239, 68, 68, 0.55), 0 2px 6px rgba(0, 0, 0, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.14s, box-shadow 0.14s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sos-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 10px 32px rgba(239, 68, 68, 0.7), 0 2px 6px rgba(0, 0, 0, 0.2);
}

.sos-btn:focus {
    outline: 3px solid rgba(239, 68, 68, 0.5);
    outline-offset: 4px;
}

.sos-btn:active,
.sos-btn.sos-holding {
    transform: scale(0.96);
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.6);
}

.sos-ring {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.sos-label {
    position: relative;
    z-index: 2;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.sos-btn.sos-fired {
    animation: sos-fired-pulse 0.5s ease-out 5;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    box-shadow: 0 6px 24px rgba(34, 197, 94, 0.55);
}

@keyframes sos-fired-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

/* Idle pulsing to draw attention (subtle) */
.sos-btn:not(.sos-holding):not(.sos-fired) {
    animation: sos-idle-pulse 3.6s ease-in-out infinite;
}
@keyframes sos-idle-pulse {
    0%, 60%, 100% { box-shadow: 0 6px 24px rgba(239, 68, 68, 0.55), 0 2px 6px rgba(0,0,0,0.18); }
    30% { box-shadow: 0 8px 28px rgba(239, 68, 68, 0.75), 0 0 0 10px rgba(239, 68, 68, 0.12); }
}

/* Hint tooltip shown during hold */
.sos-hint {
    position: absolute;
    bottom: 84px;
    right: 0;
    background: #1a202c;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.sos-hint::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 28px;
    width: 12px;
    height: 12px;
    background: #1a202c;
    transform: rotate(45deg);
}
.sos-hint.sos-hint-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Result overlay (post-fire confirmation) */
.sos-result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: sos-overlay-in 0.25s ease-out;
}
@keyframes sos-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sos-result-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: sos-card-in 0.3s ease-out;
}
@keyframes sos-card-in {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.sos-result-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
    line-height: 1;
}

.sos-result-card h2 {
    color: #2d3748;
    font-size: 1.4rem;
    margin: 0 0 12px;
    font-weight: 700;
}

.sos-result-card p {
    color: #4a5568;
    font-size: 1rem;
    line-height: 1.55;
    margin: 6px 0;
}

.sos-result-count {
    color: #48bb78 !important;
    font-weight: 600;
}

.sos-result-warn {
    background: #fff8e1;
    border-left: 3px solid #f59e0b;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.92rem !important;
    text-align: left;
    margin-top: 14px !important;
}

.sos-result-close {
    margin-top: 18px;
    background: var(--radim-primary, var(--radim-primary));
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
}
.sos-result-close:hover {
    box-shadow: 0 4px 12px color-mix(in srgb, var(--radim-primary) 30%, transparent);
}

/* Mobile: smaller button + safe-area inset */
@media (max-width: 640px) {
    #sos-button-root {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: 16px;
    }
    .sos-btn {
        width: 64px;
        height: 64px;
    }
    .sos-ring {
        width: 64px; height: 64px;
    }
    .sos-label { font-size: 1rem; }
}

/* Don't overlap with mobile bottom nav */
@media (max-width: 640px) {
    body.has-bottom-nav #sos-button-root {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}
