/**
 * ナビゲーションバー＆関連製品スタイル V3.15
 * - ノッチ・ホームバー対応（safe-area）、モバイルメニュー時の背景タップで閉じる
 * - 製品ページ本体のモバイル余白・チャート高さ（body:has(#fixed-navigation)）
 */

/* ===== 固定ナビゲーションバー ===== */
.fixed-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding-top: env(safe-area-inset-top, 0px);
    background: linear-gradient(135deg, #1e40af 0%, #0f172a 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.fixed-navigation.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.fixed-navigation.hidden {
    transform: translateY(-100%);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 max(2rem, env(safe-area-inset-right, 0px)) 0 max(2rem, env(safe-area-inset-left, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

/* ===== ロゴ ===== */
.nav-logo a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    transition: opacity 0.3s ease;
}

.nav-logo a:hover {
    opacity: 0.8;
}

.nav-logo i {
    font-size: 1.3rem;
}

/* ===== メニュー ===== */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-link i:not(.fa-chevron-down) {
    font-size: 0.9rem;
}

/* ===== ドロップダウン ===== */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dropdown-toggle .fa-chevron-down {
    font-size: 0.7rem;
    margin-left: 0.2rem;
    transition: transform 0.3s ease;
}

.nav-dropdown.open .fa-chevron-down {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.nav-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 0.75rem 1rem;
    color: #1e293b;
    text-decoration: none;
    display: block;
    transition: all 0.2s ease;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

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

.dropdown-item:hover {
    background: #f8fafc;
}

.dropdown-item.active {
    background: linear-gradient(135deg, #1e40af15 0%, #0f172a10 100%);
    font-weight: 600;
    border-left: 3px solid #1e40af;
}

/* ===== 製品ドロップダウン ===== */
.products-dropdown {
    min-width: 350px;
}

.products-dropdown .dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.85rem 1rem;
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
}

.product-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #64748b;
}

.product-meta .manufacturer {
    font-weight: 600;
    color: #475569;
    text-transform: none;
}

.product-meta .price {
    color: #0ea5e9;
    font-weight: 600;
}

.product-meta .rating {
    color: #f59e0b;
    font-weight: 600;
}

/* ===== メーカー・価格帯ドロップダウン ===== */
.manufacturer-filter,
.price-filter {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manufacturer-name,
.price-label {
    font-weight: 600;
    color: #1e293b;
}
.manufacturer-name {
    text-transform: none;
}

.product-count {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

/* ===== モバイルメニュー ===== */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}

/* bodyにpadding-topを追加してナビゲーションバーの下にコンテンツが表示されるようにする */
body {
    padding-top: calc(60px + env(safe-area-inset-top, 0px));
}

/* モバイルメニュー展開時：背後を暗くしてタップで閉じられるようにする（navigation.js と連動） */
body.nav-mobile-open {
    overflow: hidden;
    touch-action: none;
}

body.nav-mobile-open::before {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: calc(60px + env(safe-area-inset-top, 0px));
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    pointer-events: auto;
}

/* ===== 関連製品セクション ===== */
.related-products-section {
    background: #f8fafc;
    padding: 4rem 0;
    margin-top: 4rem;
}

.related-products-section .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 3rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.section-title i {
    color: #0ea5e9;
}

.related-group {
    margin-bottom: 3rem;
}

.related-subtitle {
    font-size: 1.3rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e2e8f0;
}

.related-subtitle i {
    color: #0ea5e9;
    font-size: 1.1rem;
}

.related-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.related-product-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.related-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: #0ea5e9;
}

.related-product-info {
    flex: 1;
}

.related-manufacturer {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.4rem;
    /* 全メーカー products-data / JSON の表記（Roborock, ECOVACS, Anker, Dreame, SwitchBot, iRobot 等）をそのまま表示 */
    text-transform: none;
    letter-spacing: 0.02em;
}

.related-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.6rem;
    line-height: 1.3;
}

.related-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.related-price {
    color: #0ea5e9;
    font-weight: 700;
}

.related-rating {
    color: #f59e0b;
    font-weight: 600;
}

.related-arrow {
    color: #cbd5e1;
    font-size: 1.3rem;
    transition: all 0.3s ease;
}

.related-product-card:hover .related-arrow {
    color: #0ea5e9;
    transform: translateX(4px);
}

/* ===== 全製品を見るボタン ===== */
.view-all-link {
    text-align: center;
    margin-top: 3rem;
}

.btn-view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, #1e40af 0%, #0f172a 100%);
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(30, 64, 175, 0.3);
    transition: all 0.3s ease;
}

.btn-view-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(30, 64, 175, 0.4);
}

.btn-view-all i {
    font-size: 1rem;
}

/* ===== レスポンシブ ===== */
@media (max-width: 1024px) {
    .nav-container {
        padding: 0 max(1.5rem, env(safe-area-inset-right, 0px)) 0 max(1.5rem, env(safe-area-inset-left, 0px));
    }
    
    .nav-menu {
        gap: 0.6rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .dropdown-menu {
        min-width: 260px;
    }
    
    .products-dropdown {
        min-width: 320px;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }
    
    .nav-menu {
        position: fixed;
        top: calc(60px + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1e40af 0%, #0f172a 100%);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.75rem 1rem max(1rem, env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - 60px - env(safe-area-inset-top, 0px));
        max-height: calc(100dvh - 60px - env(safe-area-inset-top, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }
    
    .nav-menu.mobile-open {
        transform: translateX(0);
    }
    
    .nav-link {
        width: 100%;
        min-height: 48px;
        padding: 0.75rem 1rem;
        justify-content: flex-start;
        border-radius: 8px;
        -webkit-tap-highlight-color: transparent;
    }

    .dropdown-item {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    .nav-dropdown {
        width: 100%;
    }
    
    .dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        margin-top: 0.5rem;
        background: rgba(255, 255, 255, 0.95);
    }
    
    .nav-dropdown.open .dropdown-menu {
        transform: none;
    }
    
    .related-products-grid {
        grid-template-columns: 1fr;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .related-subtitle {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
        height: 55px;
    }
    
    body {
        padding-top: calc(55px + env(safe-area-inset-top, 0px));
    }

    body.nav-mobile-open::before {
        top: calc(55px + env(safe-area-inset-top, 0px));
    }

    .nav-menu {
        top: calc(55px + env(safe-area-inset-top, 0px));
        max-height: calc(100vh - 55px - env(safe-area-inset-top, 0px));
        max-height: calc(100dvh - 55px - env(safe-area-inset-top, 0px));
    }
    
    .nav-logo a {
        font-size: 1rem;
    }
    
    .nav-logo i {
        font-size: 1.1rem;
    }
    
    .related-products-section {
        padding: 3rem 0;
    }
    
    .related-products-section .container {
        padding-left: max(1rem, env(safe-area-inset-left, 0px));
        padding-right: max(1rem, env(safe-area-inset-right, 0px));
    }
}

/* ===== 製品ページ（固定ナビあり）のモバイル調整 ===== */
@media (max-width: 768px) {
    body:has(#fixed-navigation) header {
        padding: 1.25rem 0;
    }

    body:has(#fixed-navigation) .header-content {
        padding-left: max(1rem, env(safe-area-inset-left, 0px));
        padding-right: max(1rem, env(safe-area-inset-right, 0px));
    }

    body:has(#fixed-navigation) .breadcrumb {
        flex-wrap: wrap;
        row-gap: 0.35rem;
        font-size: 0.85rem;
    }

    body:has(#fixed-navigation) .product-header h1.product-title,
    body:has(#fixed-navigation) h1.product-title {
        font-size: clamp(1.15rem, 4.5vw, 1.5rem);
    }

    body:has(#fixed-navigation) .performance-scores {
        justify-content: center;
    }

    body:has(#fixed-navigation) .product-meta {
        justify-content: center;
        gap: 0.75rem;
    }

    body:has(#fixed-navigation) .container {
        padding: 1.75rem max(1rem, env(safe-area-inset-left, 0px)) 2.5rem max(1rem, env(safe-area-inset-right, 0px));
    }

    body:has(#fixed-navigation) .section-title {
        font-size: clamp(1.15rem, 4vw, 1.5rem);
        flex-wrap: wrap;
    }

    body:has(#fixed-navigation) .card {
        padding: 1.25rem;
        border-radius: 12px;
    }

    body:has(#fixed-navigation) .chart-container {
        height: min(360px, 62vw);
        min-height: 240px;
    }

    body:has(#fixed-navigation) .stat-card {
        padding: 1.25rem;
    }

    body:has(#fixed-navigation) .stat-number {
        font-size: 2rem;
    }

    body:has(#fixed-navigation) .performance-details-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body:has(#fixed-navigation) .score-item {
        padding: 0.45rem 0.75rem;
    }

    body:has(#fixed-navigation) .score-value {
        font-size: 1.1rem;
    }

    body:has(#fixed-navigation) .chart-container {
        height: 260px;
    }
}

/* ===== スクロールバーのスタイル ===== */
.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
