/* 🔥 完全修正版CSS - 全セクション対応 */

@font-face {
    font-family: 'チェックアンドＵ－Ｆｏフォント';
    src: url('https://ero-video.fun/css/font/CP and U-Fo.woff') format('woff'),
        url('https://ero-video.fun/css/font/CP and U-Fo.otf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   🎯 基本設定とリセット
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: rgb(66, 130, 198);
    --secondary-color: rgb(103, 100, 186);
    --accent-color: rgb(135, 162, 206);
    --background-color: #f8f9ff;
    --card-background: #ffffff25;
    --text-color: #2c3e50;
    --text-light: #6b7280;
    --favorite-color: #e53935;
    --success-color: #4caf50;
    --border-radius: 12px;
    --shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
    --shadow-hover: 0 20px 60px rgba(102, 126, 234, 0.25);
    --gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --transition: all 0.2s ease-out;
    --sinchaku: rgba(41, 216, 255, 0.6);
    
    /* ライトモード */
    --bg-primary: #f8f9ff;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e1e8ed;
    --sub-title-color: rgba(205, 205, 205, 0.85);
}

/* 🌙 ダークモード */
.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #333333;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --background-color: rgb(30, 30, 43);
    --card-background: #16213e;
    --text-color: #eee;
    --text-light: #bbb;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --sub-title-color: rgba(46, 46, 46, 0.85);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: 80px;
}

/* ========================================
   🖥️ メインコンテナ（PC版2カラムレイアウト）
========================================= */

.main-container {
    max-width: 1920px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 30px;
    contain: layout style paint;
}

.main-content {
    min-width: 0;
}

/* ========================================
   🔍 検索オプションセクション（PC: 横並び）
========================================= */

.search-options-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem auto;
    max-width: 1680px;
    box-shadow: var(--shadow);
}

.search-options-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: nowrap;
}

.search-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-option label {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.search-option select {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-option select:hover {
    border-color: var(--primary-color);
}

.search-option select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 134, 198, 0.1);
}

/* ========================================
   🎨 コンテンツフィルター
========================================= */

.content-filters {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.filter-button {
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 25px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    white-space: nowrap;
}

.filter-button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(66, 134, 198, 0.3);
}

.filter-button.active {
    background: linear-gradient(135deg, #4286c6, #6764ba);
    color: white;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(66, 134, 198, 0.4);
}

.filter-button-special {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.filter-button-special:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

/* ========================================
   🏷️ タグセクション
========================================= */

.tags-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 2rem auto;
    max-width: 1680px;
    box-shadow: var(--shadow);
}

.tags-container-wrapper h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.tag {
    background: var(--gradient);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(66, 134, 198, 0.4);
}

/* ========================================
   📊 サイドバー（video-view.phpの.secondary-contentサイズ）
========================================= */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0;
}

.sidebar-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.sidebar-section h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 横スクロールセクション */
.horizontal-scroll-section {
    margin-bottom: 2rem;
}

.horizontal-scroll-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.horizontal-scroll-container {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
}

.horizontal-scroll-container::-webkit-scrollbar {
    display: none;
}

.horizontal-scroll-container .video-card {
    min-width: 200px;
    max-width: 200px;
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* サイドバー動画グリッド */
.sidebar .sidebar-videos-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar .category-videos-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.sidebar .video-card {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.sidebar .video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.sidebar .video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
}

.sidebar .video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar .video-info {
    padding: 1rem;
}

.sidebar .video-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar .video-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sidebar .video-stats {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.sidebar .stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sidebar .stat-item i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar .video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ========================================
   📄 ページネーション
========================================= */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin: 3rem auto;
    padding: 2rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 48px;
    padding: 0 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(66, 134, 198, 0.3);
}

.pagination .current {
    background: linear-gradient(135deg, #4286c6, #6764ba);
    color: white;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(66, 134, 198, 0.4);
}

/* ========================================
   🎲 ランダムセクション
========================================= */

.random-section {
    background: linear-gradient(135deg, 
        rgba(66, 134, 198, 0.1) 0%, 
        rgba(103, 100, 186, 0.1) 100%);
    border-radius: 16px;
    padding: 3rem;
    margin: 3rem auto;
    max-width: 1680px;
    text-align: center;
}

.random-section .section-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.random-section .section-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.random-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.random-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #4286c6, #6764ba);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(66, 134, 198, 0.3);
}

.random-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(66, 134, 198, 0.4);
}

.random_p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ========================================
   🦶 フッター
========================================= */

.footer {
    background: var(--bg-card);
    border-top: 2px solid var(--border-color);
    padding: 4rem 0 2rem;
    margin-top: 4rem;
}

.footer-container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3rem;
}

.footer-section h3,
.footer-section h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
    padding-top: 2rem;
}

.footer-bottom .footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-copyright p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-meta {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ========================================
   📱 モバイル対応（768px以下）
========================================= */

@media (max-width: 768px) {
    body {
        padding-top: 60px;
        padding-bottom: 90px;
    }

    /* メインコンテナ：1カラム */
    .main-container {
        grid-template-columns: 1fr;
        padding: 0;
        gap: 1rem;
    }

    /* 🏷️ タグセクション：100%幅、余白なし */
    .tags-section {
        margin: 0;
        padding: 1rem;
        border-radius: 0;
        width: 100%;
    }

    .tags-container-wrapper {
        width: 100%;
    }

    .tags-container-wrapper h3 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }

    .tags-container {
        width: 100vw;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.5rem;
        padding: 0.5rem;
        margin: 0 -1rem;
        justify-content: flex-start;
    }

    .tags-container::-webkit-scrollbar {
        display: none;
    }

    .tag {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* 🔍 検索オプション：縦並び */
    .search-options-section {
        margin: 1rem;
        padding: 1rem;
    }

    .search-options-container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .search-option {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .search-option label {
        text-align: left;
    }

    .search-option select {
        width: 100%;
    }

    /* 🎨 コンテンツフィルター：2カラムグリッド */
    .content-filters {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin: 1rem;
    }

    .filter-button {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 📊 サイドバー：非表示 */
    .sidebar {
        display: none;
    }

    /* 📄 ページネーション */
    .pagination {
        gap: 0.5rem;
        margin: 2rem 0;
        padding: 0 1rem;
        flex-wrap: wrap;
    }

    .pagination a,
    .pagination span {
        min-width: 40px;
        height: 40px;
        padding: 0 0.75rem;
        font-size: 0.875rem;
    }

    /* 🎲 ランダムセクション */
    .random-section {
        padding: 2rem 1rem;
        margin: 2rem 1rem;
    }

    .random-section .section-title {
        font-size: 1.5rem;
    }

    .random-section .section-description {
        font-size: 1rem;
    }

    .random-buttons {
        flex-direction: column;
        gap: 1rem;
    }

    .random-btn {
        width: 100%;
        padding: 1rem;
    }

    /* 🦶 フッター */
    .footer {
        padding: 2rem 0 1rem;
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0 1rem;
    }

    .footer-bottom .footer-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ========================================
   📱 カテゴリセクション（モバイル：2カラム）
========================================= */

@media (max-width: 768px) {
    .category-section {
        margin: 0.5rem;
        padding: 1rem;
        border-radius: 12px;
        width: calc(100% - 1rem);
    }

    .category-videos-grid,
    #categoryVideosGrid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    .category-videos-grid .video-card {
        width: 100% !important;
    }

    .category-tab {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* ========================================
   🌙 ダークモード追加スタイル
========================================= */

.dark-mode .search-options-section,
.dark-mode .tags-section,
.dark-mode .random-section {
    background: var(--bg-secondary);
}

.dark-mode .footer {
    background: var(--bg-secondary);
}