/* ====== 3/3: レイアウト・コンポーネントCSS（layout-components.css） ====== */

/* ====== 検索結果情報 ====== */
.search-results-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.05));
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.search-results-text {
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-term {
    color: var(--primary-color);
    font-weight: 700;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.search-count {
    color: var(--primary-color);
    font-weight: 700;
}

/* シノニム展開表示 */
.expanded-terms {
    background: rgba(102, 126, 234, 0.08);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
}

.expanded-terms-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.expanded-terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.expanded-term {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ====== メインレイアウト ====== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* PC表示：横並び */
@media (min-width: 769px) {
    .main-container {
        display: grid;
        grid-template-columns: 1fr 350px;
        flex-direction: row;
        align-items: flex-start;
    }
    
    .main-content {
        order: 1;
        flex: 1;
        margin-right: 2rem;
    }
    
    .sidebar {
        order: 2;
        width: 350px;
        flex-shrink: 0;
    }
    
    .random-section {
        order: 3;
        width: 100%;
        margin-top: 2rem;
        grid-column: 1 / -1;
    }
}

/* スマホ表示：縦並び */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }
    
    .main-content {
        order: 1;
    }
    
    .sidebar {
        order: 2;
        position: static;
    }
    
    .random-section {
        order: 3;
    }
}

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

.sidebar {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    height: fit-content;
}

@media (min-width: 769px) {
    .sidebar {
        position: sticky;
        top: 30px;
    }
}

/* ====== コンテンツヘッダー ====== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (max-width: 768px) {
    .page-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 640px) {
    .content-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}

.content-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-button {
    background: var(--card-background);
    border: 2px solid #e0e0e0;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--text-color);
    text-decoration: none;
}

.filter-button.active,
.filter-button:hover {
    background: var(--gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
}

/* ====== 動画グリッド ====== */
.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
    contain: layout style paint;
}

@media (max-width: 768px) {
    .videos-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.video-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
    background: linear-gradient(45deg, #f0f0f0, #e0e0e0);
    contain: layout style paint;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.video-rank {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: bold;
    font-size: 1rem;
}

.video-rank:first-letter {
    font-size: 120%;
}

.rank-1 { 
    background: linear-gradient(90deg, rgba(236, 196, 102, 0.87), rgb(133, 144, 69)); 
    color: black;
    text-shadow: 0.5px -0.5px 1px rgba(255, 255, 255, 0.3); 
}
.rank-2 { 
    background: linear-gradient(90deg, rgba(195, 197, 198, 0.86), rgb(160, 161, 166)); 
    color: black;
    text-shadow: 0.5px -0.5px 1px rgba(255, 255, 255, 0.3); 
}
.rank-3 { 
    background: linear-gradient(90deg, rgba(174, 110, 13, 0.85), rgb(160, 93, 11)); 
    color: white; 
    text-shadow: 0.5px -0.5px 1px rgba(0,0,0,0.3);
}

.video-info {
    padding: 1.5rem;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-color);
}

.video-title:hover {
    color: var(--primary-color);
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.video-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

/* 動画カードアニメーション */
.video-card {
    animation: fadeInUp 0.4s ease-out;
    animation-fill-mode: both;
}

.video-card:nth-child(even) {
    animation-delay: 0.05s;
}

.video-card:nth-child(3n) {
    animation-delay: 0.1s;
}

/* ====== サイドバー ====== */
.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-video {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.45rem 0.75rem 0.25rem;
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-video:hover {
    background: rgba(102, 126, 234, 0.05);
}

.sidebar-thumbnail {
    width: 150px;
    height: 82.26px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-video-info {
    flex: 1;
    min-width: 0;
}

.sidebar-video-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-video-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ====== ページネーション ====== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 3rem 0;
}

.pagination a,
.pagination span {
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
    border: 1px solid #e1e8ed;
    background: var(--card-background);
}

.pagination a:hover {
    background: var(--gradient);
    color: white;
    border-color: transparent;
}

.pagination .current {
    background: var(--gradient);
    color: white;
    border-color: transparent;
}

/* ====== 空状態 ====== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.empty-description {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* ====== ランダムセクション ====== */
.random-section {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    margin: 3rem 0;
}

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

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

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

.random-btn {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.random-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.random_p {
    display: block;
    margin: 12px auto;
}

/* ====== ネイティブアプリ風UI ====== */
@media (max-width: 768px) {
    /* プルトゥリフレッシュ */
    .pull-to-refresh {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 80px;
        background: var(--gradient);
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        z-index: 999;
    }
    
    .pull-to-refresh.visible {
        transform: translateY(0);
    }
    
    .pull-indicator {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-weight: 600;
    }
    
    .pull-spinner {
        width: 20px;
        height: 20px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top: 2px solid white;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
    
    /* ネイティブモーダル */
    .native-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(10px);
        z-index: 2000;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        padding: 1rem;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .native-modal.visible {
        opacity: 1;
        visibility: visible;
    }
    
    .modal-content {
        background: white;
        border-radius: 20px 20px 0 0;
        width: 100%;
        max-width: 500px;
        max-height: 80vh;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }
    
    .native-modal.visible .modal-content {
        transform: translateY(0);
    }
    
    .modal-handle {
        width: 40px;
        height: 4px;
        background: #c7c7cc;
        border-radius: 2px;
        margin: 12px auto 20px;
    }
    
    /* ネイティブトースト */
    .native-toast {
        position: fixed;
        top: calc(env(safe-area-inset-top) + 60px);
        left: 50%;
        transform: translateX(-50%) translateY(-100px);
        background: rgba(0, 0, 0, 0.85);
        color: white;
        padding: 12px 20px;
        border-radius: 25px;
        font-size: 0.9rem;
        font-weight: 500;
        z-index: 3000;
        backdrop-filter: blur(10px);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .native-toast.visible {
        transform: translateX(-50%) translateY(0);
    }
    
    /* フローティングアクションボタン */
    .fab {
        position: fixed;
        bottom: calc(env(safe-area-inset-bottom) + 100px);
        right: 1rem;
        width: 56px;
        height: 56px;
        background: var(--gradient);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 1.5rem;
        box-shadow: 0 4px 20px rgba(66, 134, 198, 0.4);
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
    }
    
    .fab:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 25px rgba(66, 134, 198, 0.5);
    }
    
    .fab:active {
        transform: scale(0.95);
    }
    
    /* スプラッシュスクリーン */
    .splash-screen {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--gradient);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: white;
        z-index: 9999;
        transition: opacity 0.5s ease, visibility 0.5s ease;
    }
    
    .splash-screen.hidden {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    
    .splash-logo {
        font-size: 3rem;
        font-weight: 900;
        margin-bottom: 1rem;
        font-family: 'チェックアンドＵ－Ｆｏフォント', sans-serif;
    }
    
    .splash-tagline {
        font-size: 1.1rem;
        opacity: 0.8;
        margin-bottom: 2rem;
    }
    
    .splash-loader {
        width: 40px;
        height: 40px;
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-top: 3px solid white;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
}

/* PC表示では非表示 */
@media (min-width: 769px) {
    .fab,
    .pull-to-refresh,
    .native-toast,
    .splash-screen {
        display: none;
    }
}