/* PWA専用スタイル */

/* インストールボタンのスタイル */
#pwa-install-btn {
    box-shadow: 0 4px 12px rgba(58, 99, 255, 0.3);
    transition: all 0.3s ease;
}

#pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(58, 99, 255, 0.4);
}

/* オフラインインジケーター */
#offline-indicator {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* すべての画面で、下部ナビゲーションバー分の余白を確保 */
body {
    padding-bottom: 70px; /* 下部ナビゲーションバーの高さ分 */
}

/* スタンドアロンモード（PWAとしてインストール済み）のスタイル */
@media all and (display-mode: standalone) {
    /* ステータスバー分の余白を追加（PWAアプリ） */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: calc(70px + env(safe-area-inset-bottom)); /* 下部ナビゲーションバーの高さ分 */
    }
    
    /* ナビゲーションバーの調整 */
    .navbar {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    /* PWAインストールボタンを非表示 */
    #pwa-install-btn {
        display: none !important;
    }
    
    /* フッターの調整 */
    .footer {
        margin-bottom: 70px; /* 下部ナビゲーションバーの高さ分 */
    }
}

/* PWA下部ナビゲーションバー（常に表示。必要に応じて各ページ側で非表示にする）
   上部ナビゲーションバーと同様に、常に画面の最下部に固定表示する。 */
.pwa-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* 明確に区別できる色（青系のグラデーション） */
    background: linear-gradient(180deg, rgba(58, 99, 255, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
    backdrop-filter: blur(20px);
    /* 上部に明確なボーダー（青系） */
    border-top: 3px solid #3a63ff;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(58, 99, 255, 0.4);
    justify-content: space-around;
    align-items: center;
}

.pwa-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    color: #8b9dc3;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
    flex: 1;
}

.pwa-bottom-nav-item:active {
    transform: scale(0.95);
}

.pwa-bottom-nav-item.active {
    color: #86b7ff;
}

.pwa-bottom-nav-item i {
    font-size: 20px;
    margin-bottom: 4px;
}

.pwa-bottom-nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.pwa-bottom-nav-item:hover {
    color: #86b7ff;
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    .pwa-bottom-nav-item {
        min-height: 50px;
        padding: 10px 16px;
    }
    
    .pwa-bottom-nav-item i {
        font-size: 22px;
    }
    
    .pwa-bottom-nav-item span {
        font-size: 12px;
    }
}

/* iOS Safari PWA対応 */
@media all and (display-mode: standalone) and (-webkit-touch-callout: none) {
    /* iOSのPWAモードでの調整 */
    .navbar {
        background: rgba(15, 23, 42, 0.98) !important;
        backdrop-filter: blur(20px);
    }
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    /* タッチターゲットのサイズを大きく */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* カードのタップ効果 */
    .card {
        transition: transform 0.2s ease;
    }
    
    .card:active {
        transform: scale(0.98);
    }
    
    /* リンクのタップ効果 */
    a:active {
        opacity: 0.7;
    }
}

/* プルトゥリフレッシュの無効化（PWAモードで） */
@media all and (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* スプラッシュスクリーン風のローディング */
.pwa-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.pwa-loading.fade-out {
    opacity: 0;
    pointer-events: none;
}

.pwa-loading-content {
    text-align: center;
    color: #e9eefc;
}

.pwa-loading-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    background: url("/static/images/pwa/lg-192x192.42e1530b6ed0.png") center/contain no-repeat;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.pwa-loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pwa-loading-subtitle {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* 更新通知 */
.pwa-update-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #3a63ff;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    display: none;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.pwa-update-notification button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 0.8rem;
}

.pwa-update-notification button:hover {
    background: rgba(255, 255, 255, 0.3);
}
