/* ==========================================================================
   1. 外部フォントの読み込み
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;500;700;900&display=swap');

/* ==========================================================================
   2. サイト全体の基本設定（タイポグラフィ・色）
   ========================================================================== */
body {
    font-family: 'Zen Maru Gothic', sans-serif !important;
    color: #5a5a5a;
    letter-spacing: 0.08em;
    line-height: 1.7;
    background-color: #f4faff !important;
}
/* タイトル・太字の強調 */
h1, h2, h3, h4, h5, h6, .font-bold, .text-4xl, .text-3xl, .text-2xl {
    font-weight: 900 !important;
    color: #444;
}
/* ==========================================================================
   3. ヘッダー周りの余白リセット（高さを極限まで削る）
   ========================================================================== */
:root {
    --ast-header-height: 0px !important;
}

.site-header,
.ast-primary-header-bar,
.ast-builder-grid-row-container,
.ast-builder-grid-row,
.site-header .ast-builder-layout-element {
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: #ffffff !important; /* ヘッダーを白に固定 */
}

/* コンテンツ全体の開始位置を引き上げ */
#content {
    padding-top: 0 !important;
}

.site-content {
    padding-top: 0 !important;
}

.benefit-detail-wrapper {
    padding-top: 0 !important;
}
/* ロゴの隙間排除 */
.site-logo-img,
.site-header .site-logo-img img {
    display: block !important;
    margin: 0 auto 0 0 !important; /* 左寄せを維持しつつ下余白を消去 */
    padding: 0 !important;
    line-height: 1;
}

/* ==========================================================================
   4. UI要素（ボタン・カード・角丸）
   ========================================================================== */
/* 角丸と影の共通設定 */
.bg-white, .rounded-xl, .rounded-2xl, .bg-red-50, .bg-cyan-100, 
button, .ast-button, input, textarea {
    border-radius: 40px !important;
    border: none !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.04) !important;
}

/* ボタンをぷっくりさせる */
button, .ast-button {
    padding: 12px 32px !important;
    font-weight: 700 !important;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* ==========================================================================
   5. モバイル表示の最適化（フルワイド化）
   ========================================================================== */
@media (max-width: 921px) {
    /* コンテナの幅制限を解除 */
    .ast-container,
    .site-content,
    #content,
    #primary,
    main.site-main {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 0 !important;
    }

    /* 修正：フロントページのみ、読みやすさを考慮して左右に16pxの余白を確保 */
    .home main.site-main {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

/* コンテンツ内部にほどよい余白を持たせる（楽天アプリ風） */
    #summary, 
    .benefit-list, 
    #registration-success-message, 
    .space-y-4,
    .space-y-5 { /* 総合利用履歴のリストコンテナを追加 */
        margin-left: 12px !important;
        margin-right: 12px !important;
    }
}
/* 総合利用履歴：日付ラベル周りの余白をコンパクト化 */
.page-template-page-all-history h2.border-b {
    margin-bottom: 0.5rem !important;
    padding-bottom: 0.25rem !important;
    font-size: 0.85rem !important;
}
/* ==========================================================================
   6. プロフィール編集画面の改善（決定版）
   ========================================================================== */
/* --- 1. 下部のボタンエリア（更新・キャンセル）の修正 --- */
/* モバイル（画面幅 767px 以下）でのレイアウト */
@media (max-width: 767px) {
    #profile-form .mt-8.flex {
        flex-direction: column !important; /* 縦並びに変更 */
        gap: 20px !important;
        align-items: center !important;
    }

    /* 「プロフィールを更新」ボタンを押しやすく */
    #profile-form button[type="submit"] {
        width: 100% !important;
        max-width: 300px !important;
        order: 1 !important; /* ボタンを上に */
    }

    /* 「キャンセル」リンク */
    #profile-form a[href*="mypage"] {
        order: 2 !important; /* キャンセルを下に */
        font-size: 0.9rem !important;
        color: #888 !important;
        text-decoration: underline !important;
    }
}
/* 入力欄と読み取り専用フィールドの共通デザイン */
#profile-form input[type="text"],
#profile-form input[type="password"],
#profile-form input[type="email"],
#profile-form .readonly-field {
    border-radius: 40px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px 20px !important;
    background-color: #f8fafc !important;
    box-shadow: none !important;
    min-height: 48px;
    display: flex;
    align-items: center;
}

/* 読み取り専用（ユーザー名・メール）の設定 */
#profile-form .readonly-field {
    background-color: #f1f5f9 !important;
    color: #64748b !important;
    cursor: not-allowed;
    font-size: 0.95rem;
}
/* ログアウトリンクをラベルより高い位置に固定 */
.profile-logout-wrapper {
    position: absolute;
    top: 10px; /* 24px(top-6) から 10px に引き上げ */
    right: 20px;
    z-index: 10;
}

/* 右上のログアウトテキストリンク（黒・細めの下線） */
.text-logout-link {
    color: #000000 !important;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: underline;
    transition: opacity 0.2s;
}
.text-logout-link:hover {
    opacity: 0.6;
}
/* フォーカス時に少し色を付ける */
#profile-form input:focus {
    border-color: #3b82f6 !important;
    background-color: #fff !important;
    outline: none !important;
}

/* ==========================================================================
   8. モーダルウィンドウのモバイル対応
   ========================================================================== */
/* モーダルの背景設定：初期状態は非表示 */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 9999 !important;
    display: none !important;
    /* 修正：align-itemsをセンターにしつつ、padding-bottomをしっかり確保 */
    align-items: center !important; 
    justify-content: center !important;
    padding: 40px 16px !important; 
    box-sizing: border-box !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* 修正：中身が長い場合に上が切れないように調整 */
@media (max-height: 700px) {
    .modal-overlay {
        align-items: flex-start !important;
    }
}

/* 表示状態を制御するクラス */
.modal-overlay.is-visible {
    display: flex !important;
}

/* モーダルの箱：内部スクロールではなくオーバーレイ側のスクロールに従う設定 */
.modal-content {
    background-color: #ffffff !important;
    width: 100% !important;
    max-width: 500px !important;
    margin-top: auto !important; /* 上下に柔軟なマージンを確保 */
    margin-bottom: auto !important;
    max-height: none !important; /* 親側でスクロールさせるため、高さ制限を解除 */
    border-radius: 30px !important;
    padding: 32px 24px !important;
    position: relative !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3) !important;
}

/* モーダル内の入力パーツを「ぷっくり」デザインに統一 */
.modal-content input,
.modal-content select,
.modal-content textarea {
    border-radius: 40px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px 20px !important;
    background-color: #f8fafc !important;
    box-shadow: none !important;
    width: 100% !important;
    font-size: 16px !important; /* スマホでズームされないためのサイズ */
    margin-bottom: 8px !important;
    appearance: none;
}

.modal-content textarea {
    border-radius: 20px !important; /* メモ欄は少し角丸を抑える */
}

/* ラベルの強調 */
.modal-content label {
    font-weight: 700 !important;
    color: #4b5563 !important;
    display: block !important;
    margin-bottom: 4px !important;
    font-size: 0.85rem !important;
}

/* スマホでは更新・キャンセルボタンを縦に並べて確実に表示 */
@media (max-width: 767px) {
    .modal-content .mt-6.flex {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .modal-content button {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* --- 優待詳細ページ：モダン＆コンパクト・デザイン --- */
.benefit-detail-wrapper {
    max-width: 500px !important;
    margin: 0 auto !important;
    padding: 0 12px !important;
}

/* メインボタン：青を基調とした洗練されたデザイン */
.primary-action-btn {
    background: #3b82f6 !important;
    color: #fff !important;
    border-radius: 40px !important;
    padding: 16px !important;
    font-size: 1rem !important;
    font-weight: 900 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.4) !important;
    border: none !important;
    transition: all 0.2s ease;
}

.primary-action-btn:active {
    transform: scale(0.98);
    box-shadow: none !important;
}

.primary-action-btn:disabled {
    background: #e2e8f0 !important;
    box-shadow: none !important;
    opacity: 0.7;
    cursor: not-allowed;
}

/* サブアクション：白背景で清潔感を出す */
.secondary-action-btn, .delete-action-btn, .link-action-btn {
    background: #ffffff !important;
    color: #475569 !important;
    border-radius: 30px !important;
    padding: 12px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    border: 1px solid #e2e8f0 !important;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03) !important;
    display: block;
    width: 100%;
}

.delete-action-btn {
    color: #ef4444 !important; /* 削除は赤字 */
}

.link-action-btn {
    color: #3b82f6 !important;
    font-size: 0.75rem !important;
}

/* 総合利用履歴：フィルタボタンのデザイン */
#history-filter .filter-btn {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    padding: 6px 16px !important;
    background-color: #f1f5f9 !important;
    color: #64748b !important;
    border-radius: 40px !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.2s ease;
}

#history-filter .filter-btn.active {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

/* 非表示制御（JSで使用） */
.history-item-card.is-hidden {
    display: none !important;
}
/* フォーカス時に少し色を付ける */
#profile-form input:focus {
    border-color: #3b82f6 !important;
    background-color: #fff !important;
    outline: none !important;
}
/* ==========================================================================
   7. フッターメニュー改善
   ========================================================================== */
/* --- モバイルフッターナビ：5項目対応の最適化 --- */
.mobile-bottom-nav {
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    background: #ffffff !important;
    border-top: 1px solid #eeeeee !important;
    padding: 8px 0 !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.mobile-nav-item {
    flex: 1 !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-decoration: none !important;
}

.mobile-nav-item svg {
    width: 22px !important; /* 少しサイズを抑えて間隔を確保 */
    height: 22px !important;
    margin-bottom: 2px !important;
}
.mobile-nav-item .nav-text {
    font-size: 9px !important; /* 5項目を1行に収めるための最小サイズ */
    font-weight: 700 !important;
    color: #666666 !important;
    white-space: nowrap !important; /* 改行を禁止 */
    letter-spacing: -0.02em; /* 文字間隔をわずかに詰め */
}
/* --- 個別優待ページ：履歴テーブルのデザイン --- */
/* 追加：コンテナの角丸がきつすぎて中身が隠れないよう調整 */
#history-list-container {
    border-radius: 12px !important; /* rounded-2xl(16px) より少し小さく設定 */
    overflow: hidden;
}

#history-list-container table {
    border-collapse: separate;
    border-spacing: 0;
}

#history-list-container th {
    letter-spacing: 0.05em;
}

#history-list-container td {
    border-bottom: 1px solid #f1f5f9;
}

#history-list-container tr:last-child td {
    border-bottom: none;
}
/* ==========================================================================
   9. Astra オフキャンバスメニュー（モバイルメニュー）の幅調整
   ========================================================================== */
/* メニュー全体の幅を画面の約2/3（70%）に制限 */
.ast-mobile-popup-drawer.ast-mobile-popup-active {
    max-width: 70% !important;
}

/* メニューの背景色とデザインの調整 */
.ast-mobile-popup-inner {
    background-color: #ffffff !important;
    /* 右からスライドしてくる場合、左側の角を丸くして柔らかい印象にする */
    border-radius: 30px 0 0 30px !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05) !important;
}

/* メニュー内のリンクテキストの調整 */
.ast-mobile-popup-content .main-navigation ul li a {
    font-weight: 700 !important;
    color: #444444 !important;
    font-size: 0.95rem !important;
}