/* グローバルヘッダー CSS（jsで表示崩れしていたので移植） */

/* 言語切り替え*/
.text-en { display: none; }
.text-ja { display: inline; }

/* 英語設定時は逆転 */
html[lang="en"] .text-ja { display: none; }
html[lang="en"] .text-en { display: inline; }

/* グローバルヘッダー全体 */
.global-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #252a42 0%, #424d71 100%);
    box-shadow: 0 2px 2px rgba(0,0,0,0.5);
}

/* 上段：サイト名＋タブ＋言語切り替え */
.header-main {
    display: flex;
    align-items: center;
    padding: 0 15px;
    height: 50px;
    gap: 10px;
}

/* ハンバーガーボタン（ヘッダー内） */
.header-hamburger {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.header-hamburger:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-hamburger .hamburger-line {
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

/* アイコン領域 */
.header-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.header-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* サイト名 */
.header-title {
    color: white;
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 140px; /* 言語切り替え時の幅変動対策 */
    cursor: pointer;
    transition: opacity 0.2s;
}

.header-title:hover {
    opacity: 0.8;
}

/* タブナビゲーション */
.header-tabs {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    justify-content: left; /* タブの位置 */
}

.header-tabs::-webkit-scrollbar {
    display: none;
}

.header-tabs li {
    flex-shrink: 0;
}

.header-tabs a {
    display: block;
    padding: 8px 16px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 5px;
    transition: all 0.2s;
}

.header-tabs a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.header-tabs a.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* 言語切り替えボタン */
.header-lang {
    flex-shrink: 0;
}

.header-lang-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-lang-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ヘッダー上部のボタン追加（変更履歴を移植） */
.header-extra-btns {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-extra-btn {
    padding: 6px 12px;
    min-width: auto;
    min-height: auto;
    font-size: 13px;
    white-space: nowrap;
}

/* 下段：ページごとのボタン（スマホは開閉可） */
.header-controls-wrapper {
    position: relative;
}

.header-controls {
    display: flex;
    align-items: center;
    justify-content: center; /* ボタン位置 */
    gap: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    min-height: 50px;
    transition: all 0.3s ease;
    overflow: hidden;
}

/* 閉じた状態 */
.header-controls.collapsed {
    max-height: 0;
    padding: 0 15px;
    min-height: 0;
    opacity: 0;
}

/* 下段が空の場合は非表示 */
.header-controls:empty {
    display: none;
}

.header-controls:empty + .header-toggle {
    display: none;
}

/* 開閉トグルボタン */
.header-toggle {
    display: none; /* デフォルトはPC向けに非表示 */
    position: absolute;
    bottom: -24px;
    left: 10%;
    transform: translateX(-50%);
    width: 64px;
    height: 24px;
    background: linear-gradient(135deg, #252a42 0%, #424d71 100%);
    border: none;
    border-radius: 0 0 10px 10px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    touch-action: manipulation;
}

.header-toggle::after {
    content: '▼';
    color: white;
    font-size: 14px;
    transition: transform 0.3s;
}

.header-toggle.collapsed::after {
    content: '▲';
}

/* モバイルでトグルボタンを表示 */
@media (max-width: 768px) {
    .header-toggle {
        display: block;
    }
    
    .header-controls-wrapper {
        padding-bottom: 8px; /* トグルボタン分の余白 */
    }
}

/* 下段のボタン */
.header-controls .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* 下段のチェックボックス */
.header-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.header-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* サイドメニュー */
.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.side-menu.open {
    left: 0;
}

.side-menu-header {
    background: linear-gradient(135deg, #252a42 0%, #424d71 100%);
    color: white;
    padding: 20px;
    font-size: 18px;
    font-weight: bold;
}

.side-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.side-menu-list li {
    border-bottom: 1px solid #d5cdc7;
}

.side-menu-list a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.side-menu-list a:hover {
    background: #f5f5f5;
}

.side-menu-list .menu-item-current {
    background: #dddddd;
    color: #635b58;
    font-weight: bold;
}

.side-menu-list .menu-item-disabled {
    display: block;
    padding: 15px 20px;
    color: #999;
    cursor: default;
}

/* メニューオーバーレイ */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
}

.menu-overlay.active {
    display: block;
}

/* モバイル対応 */

/* タブレット */
@media (max-width: 768px) {
    .header-main {
        padding: 0 10px;
        height: 48px;
    }
    
    .header-title {
        font-size: 14px;
        min-width: 100px;
    }
    
    .header-tabs a {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 36px;
        display: flex;
        align-items: center;
    }
    
    .header-controls {
        padding: 10px;
        gap: 8px;
        min-height: 52px;
    }
    
    .header-controls .btn {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .header-controls label {
        font-size: 14px;
        min-height: 40px;
    }
    
    .header-lang-btn {
        padding: 8px 12px;
        min-height: 36px;
    }
    
    /* サイドメニューの調整 */
    .side-menu {
        width: 280px;
        left: -280px;
    }
    
    .side-menu-list a {
        padding: 16px 20px;
        min-height: 52px;
    }
}

/* スマートフォン */
@media (max-width: 480px) {
    .header-main {
        height: 48px;
        gap: 4px;
        padding: 0 4px;
    }
    
    .header-title {
        font-size: 8px;
        min-width: 20px;
    }
    
    /* タブを横スクロール対応 */
    .header-tabs {
        justify-content: flex-start;
        gap: 3px;
        scroll-snap-type: x mandatory;
    }
    
    .header-tabs li {
        scroll-snap-align: start;
    }
    
    .header-tabs a {
        padding: 8px 8px;
        font-size: 10px;
        min-height: 36px;
    }
    
    .header-hamburger {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .header-icon {
        width: 0px;
        height: 0px;
    }
    
    .header-lang-btn {
        padding: 6px 8px;
        font-size: 10px;
        min-height: 36px;
    }
    
    /* コントロール部分 */
    .header-controls {
        padding: 8px;
        gap: 6px;
        min-height: 48px;
        justify-content: flex-start; /* 左寄せに変更 */
    }
    
    .header-controls .btn {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 36px;
        min-width: auto;
        flex: 0 1 auto; /* フレックスを自動サイズに */
        white-space: nowrap; /* テキストを折り返さない */
    }
    
    .header-controls .toggle-button {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 36px;
        flex: 0 1 auto;
    }
    
    .header-controls .toggle-button .toggle-checkbox {
        width: 16px;
        height: 16px;
    }
    
    .header-controls .toggle-button .toggle-label {
        font-size: 11px;
    }
    
    .header-controls label {
        font-size: 12px;
        min-height: 36px;
        flex: 0 1 auto;
    }
    
    /* ヘッダー上部の追加ボタン（スマホ用） */
    .header-extra-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    /* サイドメニューの調整 */
    .side-menu {
        width: 75vw;
        max-width: 300px;
        left: -85vw;
    }
    
    .side-menu.open {
        left: 0;
    }
    
    .side-menu-header {
        padding: 16px;
        font-size: 16px;
    }
    
    .side-menu-list a,
    .side-menu-list .menu-item-disabled {
        padding: 14px 16px;
        min-height: 48px;
        font-size: 15px;
    }
}

/* 小型スマホ（iPhone SE等） */
@media (max-width: 374px) {
    .header-main {
        gap: 4px;
        padding: 0 4px;
    }
    
    .header-title {
        font-size: 8px;
        min-width: 20px;
    }
    
    .header-tabs a {
        padding: 6px 8px;
        font-size: 10px;
    }
    
    .header-lang-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .header-controls .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .header-controls label {
        font-size: 12px;
    }
}
