/* Base Variables */
:root {
    --svp-safe-bottom: env(safe-area-inset-bottom, 0px);
    --svp-safe-right: env(safe-area-inset-right, 0px);
    --svp-safe-left: env(safe-area-inset-left, 0px);
    --svp-safe-top: env(safe-area-inset-top, 0px);
    
    --sopheva-floating-bottom-offset: 24px;
    --sopheva-floating-right-offset: 24px;
    --sopheva-floating-zindex: 9999;
    --sopheva-brand-color: #a3351e; /* Matches site primary CTA color (rgb(163, 53, 30)) */
    --sopheva-brand-color-hover: #862a18; /* Darkened for hover/active feedback */
    --sopheva-text-color: #ffffff;
    --sopheva-font-family: 'Manrope', system-ui, -apple-system, sans-serif; /* Matches site typography */
}

/* Include safe area padding on body from old FrontendIntegration */
body {
    padding-top: var(--svp-safe-top);
    padding-bottom: var(--svp-safe-bottom);
}

/* Floating Install Container */
.svp-floating-install-container {
    position: fixed;
    bottom: calc(var(--sopheva-floating-bottom-offset) + var(--svp-safe-bottom));
    right: calc(var(--sopheva-floating-right-offset) + var(--svp-safe-right));
    z-index: var(--sopheva-floating-zindex);
    
    display: flex;
    align-items: stretch;
    gap: 2px;
    background-color: var(--sopheva-brand-color);
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(163, 53, 30, 0.35);
    font-family: var(--sopheva-font-family);

    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.svp-floating-install-container:hover {
    background-color: var(--sopheva-brand-color-hover);
    box-shadow: 0 6px 20px rgba(163, 53, 30, 0.45);
}

.svp-floating-install-container.svp-visible:active {
    transform: translateY(0) scale(0.97);
}

.svp-floating-install-container.svp-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Floating Install Button */
.svp-floating-install-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--sopheva-text-color);
    border: none;
    padding: 12px 16px 12px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 50px 0 0 50px;
}

.svp-floating-install-btn:focus-visible {
    outline: 2px solid var(--sopheva-text-color);
    outline-offset: -2px;
}

.svp-install-icon {
    display: block;
    flex-shrink: 0;
}

/* Floating Dismiss Button */
.svp-floating-dismiss-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--sopheva-text-color);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 16px 0 12px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 0 50px 50px 0;
    opacity: 0.8;
}

.svp-floating-dismiss-btn:hover {
    opacity: 1;
}

.svp-floating-dismiss-btn:focus-visible {
    outline: 2px solid var(--sopheva-text-color);
    outline-offset: -2px;
    opacity: 1;
}

/* iOS Bottom Sheet */
.svp-ios-sheet {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: calc(var(--sopheva-floating-zindex) + 1);
    
    display: flex;
    align-items: flex-end;
    justify-content: center;
    
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.svp-ios-sheet.svp-visible {
    opacity: 1;
    pointer-events: auto;
}

.svp-ios-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
    touch-action: none;
}

.svp-ios-sheet-content {
    position: relative;
    z-index: 2;
    background: #ffffff;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 24px calc(24px + var(--svp-safe-bottom)) 24px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: var(--sopheva-font-family);
}

.svp-ios-sheet-content:focus {
    outline: none;
}

.svp-ios-sheet.svp-visible .svp-ios-sheet-content {
    transform: translateY(0);
}

.svp-ios-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 4px;
}

.svp-ios-sheet-content h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.svp-ios-sheet-content strong {
    color: var(--sopheva-brand-color);
}

.svp-ios-sheet-content p {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #666;
}

.svp-ios-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.svp-ios-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #f7f2f1;
    border-radius: 14px;
}

.svp-ios-step-number {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sopheva-brand-color);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.svp-ios-step-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.svp-ios-step-text {
    font-size: 14.5px;
    line-height: 1.4;
    color: #333;
}

.svp-ios-step-text strong {
    color: var(--sopheva-brand-color);
}

.svp-ios-step-visual {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--sopheva-brand-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Success Toast */
.svp-install-toast {
    position: fixed;
    bottom: calc(var(--sopheva-floating-bottom-offset) + var(--svp-safe-bottom));
    left: 50%;
    transform: translate(-50%, 20px);
    z-index: calc(var(--sopheva-floating-zindex) + 2);
    
    background: #3a8f4a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-family: var(--sopheva-font-family);
    font-size: 14px;
    font-weight: 600;

    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 32px);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.svp-install-toast.svp-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.svp-install-toast button {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Small Screens: tighten offsets/padding so nothing crowds the screen edge */
@media (max-width: 380px) {
    .svp-floating-install-container {
        --sopheva-floating-bottom-offset: 16px;
        --sopheva-floating-right-offset: 16px;
    }

    .svp-floating-install-btn {
        padding: 11px 14px 11px 16px;
        font-size: 14px;
        gap: 6px;
    }

    .svp-floating-dismiss-btn {
        padding: 0 14px 0 10px;
        font-size: 18px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .svp-floating-install-container {
        transition: opacity 0.2s ease;
        transform: none;
    }
    .svp-ios-sheet-content {
        transition: none;
    }
    .svp-install-toast {
        transition: opacity 0.2s ease;
        transform: translate(-50%, 0);
    }
}
