/**
 * 新ヘッダー: H-F 2段構成スティッキー
 * Phase 1: Week 26b - ヘッダー/メガメニュー統合
 * 作成日: 2025-01-05
 */

/* ========================================
   旧ヘッダー要素の非表示
   ※ 新ヘッダー（.header-new-wrapper）がある場合のみ適用
   ======================================== */
.header-new-wrapper ~ #container #header #maintitle,
body:has(.header-new-wrapper) #header #maintitle {
    display: none !important;
}

/* ========================================
   ヘッダーラッパー（固定表示）
   ======================================== */
.header-new-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1010;
    background: #fff;
    max-width: 100%;
    overflow-x: hidden;
}

/* 固定ヘッダー分のスペーサー */
.header-new-spacer {
    height: 110px; /* ヘッダー高さ分 */
}

/* ========================================
   上段: ロゴ + 検索 + アクションボタン
   ======================================== */
.header-new-top {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    border-bottom: 1px solid #e0e0e0;
    max-width: 980px;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
}

/* サイトロゴ */
.header-new-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    margin-right: 15px;
}

.header-new-logo:hover {
    opacity: 0.8;
}

.header-logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* SVGロゴテキスト */
.header-logo-svg {
    height: 36px;
    width: auto;
    flex-shrink: 0;
}

/* スクリーンリーダー用非表示テキスト */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 旧テキストスタイル（後方互換性） */
.header-logo-text {
    font-size: 1rem;
    font-weight: bold;
    color: #1a365d;
    white-space: nowrap;
}

/* 検索ボックス */
.header-new-search {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.header-new-search form {
    width: 100%;
}

.header-search-wrapper {
    display: flex;
    width: 100%;
}

.header-new-search input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px 0 0 4px;
    flex: 1;
    min-width: 120px;
    font-size: 0.9rem;
    outline: none;
}

.header-new-search input[type="text"]:focus {
    border-color: var(--color-primary-700, #334e68);
}

.header-new-search input[type="submit"],
.header-new-search button {
    padding: 8px 14px;
    background: var(--btn-primary-bg);
    color: #fff;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 0.9rem;
}

.header-new-search input[type="submit"]:hover,
.header-new-search button:hover {
    background: var(--btn-primary-hover);
}

/* アクションボタンエリア */
.header-new-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: 15px;
}

/* 選手登録ボタン（緑色 - 最も目立たせる） */
.header-new-actions .btn-register {
    padding: 8px 14px;
    background: var(--color-success, #22c55e);
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.header-new-actions .btn-register:hover {
    background: #16a34a;
}

/* ログインボタン（赤系 - 目立たせる） */
.header-new-actions .btn-login {
    padding: 8px 14px;
    background: var(--btn-login-bg);
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.header-new-actions .btn-login:hover {
    background: var(--btn-login-hover);
}

/* 新規登録ボタン */
.header-new-actions .btn-signup {
    padding: 8px 14px;
    background: #fff;
    color: var(--btn-primary-bg) !important;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--btn-primary-bg);
    font-size: 0.85rem;
    white-space: nowrap;
}

.header-new-actions .btn-signup:hover {
    background: var(--color-primary-100);
}

/* ログイン済みユーザー情報（リンク化） */
.header-new-user-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.header-new-user-link:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.header-new-user-link .user-name {
    color: #333;
    font-weight: 600;
    font-size: 0.9rem;
}

/* 管理者バッジ */
.header-new-user-link .admin-badge {
    background: #ffc107;
    color: #333;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* モバイル用イニシャルアイコン（デスクトップでは非表示） */
.header-new-user-link .user-avatar-mobile {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

/* 中画面: SVGテキストを縮小 */
@media screen and (max-width: 1024px) {
    .header-logo-svg {
        height: 28px;
    }
}

/* タブレット/モバイル: 縦積みレイアウト（本番環境準拠） */
@media screen and (max-width: 768px) {
    /* ヘッダースペーサー調整（2行: ロゴ行 + 検索行） */
    .header-new-spacer {
        height: 130px;
    }

    .header-new-top {
        flex-wrap: wrap;
        padding: 10px 60px 10px 15px; /* 右側にハンバーガー分の余白 */
        gap: 10px;
    }

    /* 1行目: ロゴのみ（ハンバーガーはmeanmenu） */
    .header-new-logo {
        margin-right: auto; /* ロゴを左寄せ */
        flex-shrink: 0;
        order: 1;
    }

    .header-logo-img {
        width: 36px;
        height: 36px;
    }

    .header-logo-svg,
    .header-logo-text {
        display: none;
    }

    /* 1行目右側: アクションボタン（選手登録 + ユーザーアイコン） */
    .header-new-actions {
        order: 2;
        position: fixed;
        top: 10px;
        right: 64px; /* ハンバーガー(44px) + 余白(20px) */
        z-index: 10001;
        margin-left: 0;
        gap: 14px;
    }

    /* ユーザー情報: アイコンのみ表示 */
    .header-new-user-link {
        padding: 0;
        background: transparent;
        border: none;
    }

    /* モバイル: イニシャルアイコンを表示 */
    .header-new-user-link .user-avatar-mobile {
        display: flex;
    }

    /* モバイル: ユーザー名と管理者バッジを非表示 */
    .header-new-user-link .user-name,
    .header-new-user-link .admin-badge {
        display: none;
    }

    /* 2行目: 検索ボックス（幅100%） */
    .header-new-search {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
    }

    .header-new-search input[type="text"] {
        min-width: 0;
        box-sizing: border-box;
    }

    .header-new-search input[type="submit"] {
        flex-shrink: 0;
    }
}

/* 小画面: ユーザー名を短縮 */
@media screen and (max-width: 640px) {
    .header-new-user-link .user-name {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ========================================
   旧ヘッダーのスタイル調整
   ======================================== */
#header {
    height: auto !important;
}

/* ========================================
   モバイルメニュー対応（Vue MegaMenu）
   ======================================== */
@media screen and (max-width: 768px) {
    /* 新ヘッダー内の.blackはモバイルでも表示（Vue MegaMenuのため） */
    .header-new-wrapper .black {
        display: block !important;
    }
}
