/**
 * PWA 相關樣式
 * 念念 Memorial
 */

/* ===== PWA 安裝底部橫條 ===== */

.pwa-install-banner {
    display: none; /* pwa.js 控制顯示 */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    padding: 12px 16px;
    animation: pwaBannerSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pwaBannerSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* iPhone X+ safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pwa-install-banner {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

.pwa-banner-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.pwa-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
}

.pwa-banner-text {
    flex: 1;
    min-width: 0;
}

.pwa-banner-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-banner-desc {
    display: block;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-banner-install-btn {
    flex-shrink: 0;
    padding: 8px 18px;
    background: linear-gradient(135deg, #ffd700 0%, #f9a825 100%);
    color: #333;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.pwa-banner-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.5);
}

.pwa-banner-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    transition: all 0.2s;
}

.pwa-banner-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* ===== iOS 安裝說明 ===== */

.pwa-ios-guide {
    display: none; /* pwa.js 控制顯示 */
    position: fixed;
    inset: 0;
    z-index: 9995;
    background: rgba(0, 0, 0, 0.5);
    align-items: flex-end;
    animation: pwaFadeIn 0.2s ease;
}

.pwa-ios-guide.pwa-ios-open {
    display: flex;
}

@keyframes pwaFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pwa-ios-guide-card {
    width: 100%;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 24px 24px 40px;
    position: relative;
    text-align: center;
    animation: pwaCardSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pwa-ios-guide-card {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

@keyframes pwaCardSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.pwa-ios-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #555;
    padding: 0;
    transition: all 0.2s;
}

.pwa-ios-close:hover {
    background: rgba(0, 0, 0, 0.15);
}

.pwa-ios-app-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin: 0 auto 12px;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pwa-ios-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 6px;
}

.pwa-ios-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0 0 24px;
}

.pwa-ios-steps {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.pwa-ios-step {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-ios-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #f9a825 100%);
    color: #333;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-ios-step-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.pwa-ios-step-highlight {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 215, 0, 0.2);
    color: #b8860b;
    padding: 1px 7px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.pwa-ios-arrow {
    color: #ffd700;
    display: flex;
    justify-content: center;
    animation: pwaArrowBounce 1.2s ease-in-out infinite;
}

.pwa-ios-arrow .material-icons {
    font-size: 36px;
}

@keyframes pwaArrowBounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(8px); }
}

/* ===== 網路狀態提示 ===== */

#network-status {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: none;
}

#network-status.success {
    background: #4caf50;
    color: white;
    display: block;
}

#network-status.warning {
    background: #ff9800;
    color: white;
    display: block;
}

#network-status.hidden {
    display: none;
}

/* ===== 離線模式 ===== */

body.offline::before {
    content: '離線模式';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
}

/* ===== PWA Standalone 模式 ===== */

body.pwa-standalone .pwa-only-hide {
    display: none;
}

body:not(.pwa-standalone) .pwa-only-show {
    display: none;
}

/* ===== 深色模式 ===== */

@media (prefers-color-scheme: dark) {
    .pwa-install-banner {
        background: #1c1c1e;
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .pwa-banner-title { color: #f0f0f0; }
    .pwa-banner-desc  { color: #aaa; }

    .pwa-banner-close        { color: #777; }
    .pwa-banner-close:hover  { background: rgba(255, 255, 255, 0.08); color: #eee; }

    .pwa-ios-guide-card { background: #1c1c1e; }
    .pwa-ios-title      { color: #f0f0f0; }
    .pwa-ios-subtitle   { color: #aaa; }
    .pwa-ios-step-text  { color: #ddd; }
    .pwa-ios-close      { background: rgba(255, 255, 255, 0.1); color: #aaa; }
    .pwa-ios-step-highlight { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
}

/* ===== 響應式 ===== */

@media (max-width: 480px) {
    .pwa-banner-desc {
        display: none; /* 手機太小時隱藏描述，保留標題 + 按鈕 */
    }

    #network-status {
        top: 15px;
        right: 15px;
        left: 15px;
        text-align: center;
    }
}
