/*
 * ファイル名: style.css
 * バージョン: 2.10 (サジェストエリア拡張版)
 * 作成日: 2025-12-06
 * 説明: Music Libraryアプリケーションのスタイルシート
 * 修正点 (v2.10):
 * - #suggestionList の max-height を 200px -> 60vh に拡大
 * - #suggestionList の max-width を 400px -> 600px に拡大
 * - これにより、サジェスト候補が増えても一覧性が確保されます。
 */

/* --- 基本設定 --- */
:root {
    --primary-bg: #f4f4f9;
    --secondary-bg: #ffffff;
    --header-bg: #333;
    --header-text: #ffffff;
    --text-color: #333;
    --accent-color: #007bff;
    --accent-hover-color: #0056b3;
    --border-color: #ddd;
    --panel-header-bg: #e9ecef;
}

html, body {
    height: 100%;
    margin: 0;
    overscroll-behavior: none; /* スマホでのページ全体バウンス抑止 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* --- ヘッダー (上部固定) --- */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 0; 
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* タイトルとアイコンを保持するコンテナ */
#headerBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    cursor: pointer;
}

header h1 {
    margin: 0;
    padding: 8px 15px;
    font-size: 1.5em;
    line-height: 1.2;
}

/* アイコンコンテナ */
#iconContainer {
    padding-right: 15px;
    display: flex;
    align-items: center;
    font-size: 1.5em;
    color: #ccc; /* 視認性を上げるため少し明るく */
    transition: transform 0.2s ease-in-out;
}

.search-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #444; /* ヘッダーより少し明るい色で区別 */
}

/* 検索コンテナ非表示 */
.search-container.hidden {
    display: none;
}

#searchInput {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 250px;
    max-width: 100%;
}

button {
    padding: 0.5rem 1rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

button:hover {
    background-color: var(--accent-hover-color);
}

/* --- メインコンテンツ --- */
.container {
    display: flex;
    padding: 1rem;
    gap: 1rem;
    flex-grow: 1;
    overflow: hidden; /* コンテナ自体はスクロールせず、内部パネルでスクロール */
    box-sizing: border-box;
}

.left-panel, .right-panel {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ★ PCレイアウト: 左右分割 (35% : 65%) */
.left-panel {
    flex: 0 0 35%; /* flex-grow, flex-shrink, flex-basis */
    max-width: 35%;
    min-width: 250px;
}

.right-panel {
    flex: 1 1 auto; /* 残りの幅を埋める */
    max-width: 65%;
}

/* パネルのh2共通スタイル */
.left-panel h2, .right-panel h2 {
    background-color: var(--panel-header-bg);
    margin: 0;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* タイトルテキスト */
.panel-title-container > span {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ソートボタンコンテナ */
.sort-buttons {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.sort-btn {
    padding: 0.2rem 0.4rem; 
    font-size: 0.8rem; 
    line-height: 1;
    background-color: var(--accent-color);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.sort-btn:hover {
    background-color: var(--accent-hover-color);
}
.sort-btn:disabled {
    background-color: #aaa; 
    cursor: not-allowed;
    opacity: 0.7;
}

/* ジャンルプルダウン */
.genre-container {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#genreDropdown {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    font-size: 1rem;
}

/* リストエリア (スクロール可能領域) */
.artist-list, .track-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto; /* ここでスクロールさせる */
    flex-grow: 1;
    -webkit-overflow-scrolling: touch; /* iOS慣性スクロール */
}

.artist-list li {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.artist-list li:hover {
    background-color: var(--primary-bg);
}
.artist-list li.active {
    background-color: var(--accent-color);
    color: white;
}

.track-item {
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    cursor: pointer;
}
.track-item:hover {
    background-color: #f9f9f9;
}
.track-title {
    font-weight: bold;
}
.track-info {
    font-size: 0.9em;
    color: #555;
}

/* --- フッター (下部固定) --- */
footer {
    background-color: var(--header-bg);
    color: var(--header-text);
    text-align: center;
    padding: 1rem;
    position: sticky;
    bottom: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

.category-link {
    cursor: pointer;
    margin: 0 0.5rem;
    color: #aaa;
    text-decoration: none;
}
.category-link.active {
    color: #fff;
    font-weight: bold;
    text-decoration: underline;
}

footer a {
    color: var(--header-text);
    text-decoration: none;
}

/* --- 曲情報オーバーレイ --- */
.song-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    color: white;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    cursor: pointer;
}

.song-overlay.visible {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 1rem;
    width: 90%;
    max-width: 800px;
}

#overlayTitle {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 1rem;
    line-height: 1.2;
}
#overlayArtist {
    font-size: clamp(1.2rem, 3vw, 2.5rem);
    color: #ccc;
}

body.overlay-active {
    overflow: hidden;
}

/* --- サジェストリスト (修正: エリア拡張) --- */
#suggestionList {
    position: absolute;
    z-index: 1100;
    background: #fff;
    border: 1px solid #ccc;
    
    /* 修正: 高さ制限をピクセル固定から画面比率(60%)に変更して拡大 */
    max-height: 60vh; 
    
    overflow-y: auto;
    width: 90%; 
    
    /* 修正: PC表示でも見やすいように最大幅を拡張 (400px -> 600px) */
    max-width: 600px; 
    
    top: 100%; /* inputの直下 */
    left: 50%;
    transform: translateX(-50%);
    list-style: none;
    padding: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 4px;
    color: #333;
}

#suggestionList li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    text-align: left;
}
#suggestionList li.selected,
#suggestionList li:hover {
    background-color: #e0f7fa;
}

/* --- レスポンシブ対応 (モバイル: max-width: 768px) --- */
@media (max-width: 768px) {
    body {
        height: 100vh; /* ビューポート高さに固定 */
        overflow: hidden; /* 全体スクロール禁止 */
    }

    /* ★ コンテナを縦並び(Column)に変更し、高さを制限 */
    .container {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.5rem;
        height: calc(100vh - 120px); /* ヘッダー・フッター分を引く(調整値) */
        width: 100%;
    }

    /* --- 上パネル (Genres/Artists) --- */
    .left-panel {
        /* JSで flex-basis を書き換えるため !important を削除 */
        flex: 0 0 40%; 
        max-width: 100% !important;
        width: 100%;
        min-height: 120px; /* 潰れすぎ防止 */
    }

    /* --- 下パネル (Songs) --- */
    .right-panel {
        flex: 1 1 auto; /* 残りの高さを埋める */
        max-width: 100% !important;
        width: 100%;
        min-height: 120px;
    }

    /* パネルヘッダーのコンパクト化 */
    .left-panel h2, .right-panel h2 {
        padding: 0.5rem;
        font-size: 1rem;
        min-height: 40px;
    }

    /* ★ リサイズハンドルとしての Songs タイトルバー設定 */
    #trackListTitle.resizer {
        cursor: ns-resize; /* 上下リサイズカーソル */
        touch-action: none; /* スクロール干渉防止 */
        background-color: #ddd; /* つまめる感を出すために少し濃く */
        position: relative;
    }
    
    /* リサイズハンドルの視覚的ヒント（中央に線を入れるなど） */
    #trackListTitle.resizer::after {
        content: "";
        position: absolute;
        bottom: 2px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background-color: #bbb;
        border-radius: 2px;
    }

    .sort-buttons {
        transform: scale(0.9); /* ボタンを少し小さく */
    }

    /* 検索バー周り */
    .search-container {
        padding: 0.5rem;
    }
    #searchInput {
        width: 100%; /* 横幅いっぱい */
    }

    /* オーバーレイ（横向き回転用） */
    @media (orientation: portrait) {
        .song-overlay.visible .overlay-content {
            transform: rotate(90deg);
            width: 80vh; 
        }
    }
}