/**
 * PWA 설치 유도 UI 스타일
 * 사주살롱 디자인 시스템 기반
 *
 * 구성:
 * 1. 하단 배너 (Bottom Banner) - 결과 페이지
 * 2. 중앙 모달 (Center Modal) - 재방문자
 * 3. 토스트 알림 (Toast Notification) - 고관여
 */

/* ==========================================
   1. 하단 배너 (Bottom Banner)
   ========================================== */

.pwa-bottom-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    padding: 0 12px calc(12px + env(safe-area-inset-bottom)) 12px;

    /* 초기 숨김 상태 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-bottom-banner.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 배너 내용 컨테이너 */
.pwa-banner-content {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 -4px 20px rgba(139, 92, 246, 0.15);
    backdrop-filter: blur(10px);

    /* 그라데이션 배경 (라이트) */
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.08) 0%,
        rgba(236, 72, 153, 0.08) 100%),
        var(--bg-card);
}

html.dark .pwa-banner-content {
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.15) 0%,
        rgba(236, 72, 153, 0.15) 100%),
        rgba(42, 45, 60, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

/* 배너 레이아웃 */
.pwa-banner-layout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* 아이콘 영역 */
.pwa-banner-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    animation: crystalGlow 2s ease-in-out infinite;
}

/* 텍스트 영역 */
.pwa-banner-text {
    flex: 1;
    min-width: 0;
}

.pwa-banner-title {
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.pwa-banner-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: keep-all;
}

/* 액션 버튼 그룹 */
.pwa-banner-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.pwa-banner-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.pwa-banner-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.pwa-banner-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

.pwa-banner-btn.primary:active {
    transform: translateY(0);
}

.pwa-banner-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

html.dark .pwa-banner-btn.secondary {
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pwa-banner-btn.secondary:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* 닫기 버튼 */
.pwa-banner-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
}

.pwa-banner-close:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

/* ==========================================
   2. 중앙 모달 (Center Modal)
   ========================================== */

.pwa-center-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;

    /* 초기 숨김 상태 */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.pwa-center-modal.visible {
    opacity: 1;
    visibility: visible;
}

/* 배경 오버레이 */
.pwa-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
}

html.dark .pwa-modal-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

/* 모달 카드 */
.pwa-modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 32px 24px 24px;
    box-shadow: 0 20px 60px rgba(139, 92, 246, 0.2);

    /* 애니메이션 */
    transform: scale(0.9) translateY(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-center-modal.visible .pwa-modal-card {
    transform: scale(1) translateY(0);
}

html.dark .pwa-modal-card {
    background: rgba(42, 45, 60, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* 모달 헤더 */
.pwa-modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.pwa-modal-icon {
    font-size: 64px;
    margin-bottom: 16px;
    display: inline-block;
    animation: modalIconBounce 0.6s ease-out;
}

@keyframes modalIconBounce {
    0% { transform: scale(0) rotate(-180deg); }
    50% { transform: scale(1.1) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

.pwa-modal-title {
    font-family: var(--font-title);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.pwa-modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* 혜택 리스트 */
.pwa-modal-benefits {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.pwa-benefit-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

html.dark .pwa-benefit-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pwa-benefit-item:last-child {
    border-bottom: none;
}

.pwa-benefit-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.1) 0%,
        rgba(236, 72, 153, 0.1) 100%);
    font-size: 18px;
}

html.dark .pwa-benefit-icon {
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.2) 0%,
        rgba(236, 72, 153, 0.2) 100%);
}

.pwa-benefit-text {
    flex: 1;
}

.pwa-benefit-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.pwa-benefit-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* 모달 액션 버튼 */
.pwa-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-modal-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pwa-modal-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.pwa-modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.pwa-modal-btn.primary:active {
    transform: translateY(0);
}

.pwa-modal-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 14px;
}

.pwa-modal-btn.secondary:hover {
    color: var(--text-primary);
}

/* 닫기 버튼 (우상단) */
.pwa-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 24px;
}

.pwa-modal-close:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

/* ==========================================
   3. 토스트 알림 (Toast Notification)
   ========================================== */

.pwa-toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 16px;
    z-index: 9995;
    max-width: 320px;

    /* 초기 숨김 상태 */
    opacity: 0;
    visibility: hidden;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* 토스트 카드 */
.pwa-toast-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 12px;
}

html.dark .pwa-toast-card {
    background: rgba(42, 45, 60, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.pwa-toast-icon {
    flex-shrink: 0;
    font-size: 24px;
}

.pwa-toast-content {
    flex: 1;
    min-width: 0;
}

.pwa-toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.pwa-toast-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.pwa-toast-action {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--primary-gradient);
    color: white;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-toast-action:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.pwa-toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
}

.pwa-toast-close:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

/* ==========================================
   4. 공통 유틸리티
   ========================================== */

/* 애니메이션 재사용 */
@keyframes crystalGlow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(139, 92, 246, 0.7));
        transform: scale(1.05);
    }
}

/* 하단 네비게이션이 있는 경우 */
.has-bottom-nav .pwa-bottom-banner {
    bottom: calc(64px + env(safe-area-inset-bottom));
}

.has-bottom-nav .pwa-toast {
    bottom: calc(144px + env(safe-area-inset-bottom));
}

/* 접근성: 포커스 스타일 */
.pwa-banner-btn:focus,
.pwa-modal-btn:focus,
.pwa-toast-action:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* 접근성: 감소된 모션 선호 */
@media (prefers-reduced-motion: reduce) {
    .pwa-bottom-banner,
    .pwa-center-modal,
    .pwa-toast,
    .pwa-modal-card,
    .pwa-banner-icon,
    .pwa-modal-icon {
        animation: none;
        transition: opacity 0.2s ease;
    }
}

/* 반응형: 작은 화면 */
@media (max-width: 380px) {
    .pwa-banner-content {
        padding: 12px;
    }

    .pwa-banner-icon {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .pwa-banner-title {
        font-size: 14px;
    }

    .pwa-banner-desc {
        font-size: 12px;
    }

    .pwa-banner-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .pwa-modal-card {
        padding: 24px 20px 20px;
    }

    .pwa-modal-icon {
        font-size: 56px;
    }

    .pwa-modal-title {
        font-size: 20px;
    }

    .pwa-toast {
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

/* 다크모드 전환 애니메이션 */
.pwa-banner-content,
.pwa-modal-card,
.pwa-toast-card {
    transition:
        background 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}
