/* ===================================
   Contact Form 7 Custom Styles
   =================================== */

/* Contact Form 7 基本スタイル */
.wpcf7 {
    width: 100%;
}

.wpcf7-form {
    width: 100%;
}

/* スクリーンリーダー用の非表示要素 */
.screen-reader-response {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* フォームフィールド全体 */
.wpcf7-form p {
    margin-bottom: 30px;
}

.wpcf7-form p:last-of-type {
    margin-bottom: 0;
}

/* ラベル */
.wpcf7-form label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

/* 入力フィールド共通 */
.wpcf7-form-control.wpcf7-text,
.wpcf7-form-control.wpcf7-email,
.wpcf7-form-control.wpcf7-tel,
.wpcf7-form-control.wpcf7-number,
.wpcf7-form-control.wpcf7-date,
.wpcf7-form-control.wpcf7-select,
.wpcf7-form-control.wpcf7-textarea {
    width: 100%;
    padding: 14px 18px;
    font-size: 15px;
    font-family: var(--font-japanese);
    color: var(--text-primary);
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

/* フォーカス時 */
.wpcf7-form-control.wpcf7-text:focus,
.wpcf7-form-control.wpcf7-email:focus,
.wpcf7-form-control.wpcf7-tel:focus,
.wpcf7-form-control.wpcf7-number:focus,
.wpcf7-form-control.wpcf7-date:focus,
.wpcf7-form-control.wpcf7-select:focus,
.wpcf7-form-control.wpcf7-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* エラー時 */
.wpcf7-form-control.wpcf7-not-valid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* テキストエリア */
.wpcf7-form-control.wpcf7-textarea {
    resize: vertical;
    min-height: 150px;
}

/* セレクトボックス */
.wpcf7-form-control.wpcf7-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    padding-right: 45px;
}

/* チェックボックス・ラジオボタン */
.wpcf7-form-control.wpcf7-checkbox,
.wpcf7-form-control.wpcf7-radio {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wpcf7-list-item {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpcf7-list-item input[type="checkbox"],
.wpcf7-list-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.wpcf7-list-item-label {
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* 承認チェックボックス */
.wpcf7-form-control.wpcf7-acceptance {
    margin: 30px 0;
}

.wpcf7-form-control.wpcf7-acceptance .wpcf7-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.wpcf7-form-control.wpcf7-acceptance input[type="checkbox"] {
    margin-top: 2px;
}

.wpcf7-form-control.wpcf7-acceptance .wpcf7-list-item-label {
    font-size: 14px;
}

/* 送信ボタン */
.wpcf7-form p:has(.wpcf7-submit) {
    text-align: center;
    position: relative;
}

.wpcf7-form-control.wpcf7-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 48px;
    font-size: 18px;
    font-weight: 600;
    font-family: var(--font-japanese);
    color: white;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    position: relative;
    /* overflow: visible にして擬似要素を表示 */
    min-width: 200px;
}

/* 送信中のボタンスタイル */
.wpcf7-form.submitting .wpcf7-submit,
.wpcf7-form.submitting .wpcf7-form-control.wpcf7-submit {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
    padding-right: 60px !important; /* スピナー用のスペースを確保 */
}

/* 送信完了後のボタンスタイル */
.wpcf7-form.sent .wpcf7-submit {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.wpcf7-form-control.wpcf7-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
}

.wpcf7-form-control.wpcf7-submit:active {
    transform: translateY(0);
}

/* 送信中のスピナー */
.wpcf7-form-control.wpcf7-submit.has-spinner {
    position: relative;
}

/* スピナーをボタン内に配置するためのスタイル（擬似要素使用） */
.wpcf7-form.submitting .wpcf7-submit::after,
.wpcf7-form.submitting .wpcf7-form-control.wpcf7-submit::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: wpcf7-spin 0.8s linear infinite;
    display: block !important;
    z-index: 1;
    pointer-events: none;
}

/* スピナーのアニメーション */
@keyframes wpcf7-spin {
    to { 
        transform: translateY(-50%) rotate(360deg); 
    }
}

/* ボタンの外側（横）に配置されたスピナーを完全に非表示 */
.wpcf7-form p .wpcf7-spinner {
    /* ボタンの横に配置されたスピナーを完全に非表示にする */
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    border: 3px solid rgba(255, 255, 255, 0.3) !important;
    border-top-color: white !important;
    border-radius: 50% !important;
    animation: wpcf7-spin 0.8s linear infinite !important;
    /* デフォルトでは非表示 */
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    /* レイアウトに影響を与えないように */
    pointer-events: none !important;
}

/* 送信中はスピナーを表示（ボタンの内側に配置） */
/* 注意: 実際にはHTML側の<span class="wpcf7-spinner">は使わず、::after擬似要素を使用 */
.wpcf7-form.submitting p .wpcf7-spinner {
    /* HTML側のスピナーは常に非表示 */
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* デモ確認用: submitting状態の視覚確認 */
.wpcf7-form.submitting {
    /* 送信中状態が適用されていることを確認 */
}

/* デバッグ用: スピナーの視認性を高める（必要に応じてコメントアウト解除） */
/*
.wpcf7-form.submitting .wpcf7-submit::after {
    border-width: 4px !important;
    width: 24px !important;
    height: 24px !important;
}
*/

/* エラーメッセージ（個別フィールド） */
.wpcf7-not-valid-tip {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #ef4444;
    font-weight: 500;
}

/* レスポンスメッセージ（送信結果） */
.wpcf7-response-output {
    margin-top: 30px;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 15px;
    text-align: center;
    border: 2px solid;
    display: none;
}

/* aria-hiddenがtrueでも、特定の状態では表示する */
.wpcf7-response-output[aria-hidden="true"] {
    display: none;
}

/* フォームが送信完了状態の時はメッセージを表示 */
.wpcf7-form.sent .wpcf7-response-output[aria-hidden="true"],
.wpcf7-form[data-status="sent"] .wpcf7-response-output[aria-hidden="true"] {
    display: block;
}

/* バリデーションエラー時も表示 */
.wpcf7-form.invalid .wpcf7-response-output[aria-hidden="true"],
.wpcf7-form[data-status="invalid"] .wpcf7-response-output[aria-hidden="true"] {
    display: block;
}

/* スパム判定時も表示 */
.wpcf7-form.spam .wpcf7-response-output[aria-hidden="true"],
.wpcf7-form[data-status="spam"] .wpcf7-response-output[aria-hidden="true"] {
    display: block;
}

/* 送信失敗時も表示 */
.wpcf7-form.failed .wpcf7-response-output[aria-hidden="true"],
.wpcf7-form[data-status="failed"] .wpcf7-response-output[aria-hidden="true"] {
    display: block;
}

/* 中断時も表示 */
.wpcf7-form.aborted .wpcf7-response-output[aria-hidden="true"],
.wpcf7-form[data-status="aborted"] .wpcf7-response-output[aria-hidden="true"] {
    display: block;
}

/* 成功メッセージ */
.wpcf7-mail-sent-ok {
    display: block;
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

/* エラーメッセージ */
.wpcf7-mail-sent-ng,
.wpcf7-validation-errors,
.wpcf7-acceptance-missing {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* スパム判定 */
.wpcf7-spam-blocked {
    display: block;
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

/* 送信失敗 */
.wpcf7-aborted {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* 必須マーク用のクラス（手動で追加する場合） */
.required {
    color: #ef4444;
    font-weight: 700;
    margin-left: 4px;
}

/* フォームラッパー調整 */
.contact-form.glass-card .wpcf7 {
    padding: 0;
}

/* Ajaxローダー非表示（Spinnerを使用） */
.wpcf7 .ajax-loader {
    display: none;
}

/* レスポンシブ対応 */
@media (max-width: 640px) {
    .wpcf7-form-control.wpcf7-text,
    .wpcf7-form-control.wpcf7-email,
    .wpcf7-form-control.wpcf7-tel,
    .wpcf7-form-control.wpcf7-number,
    .wpcf7-form-control.wpcf7-date,
    .wpcf7-form-control.wpcf7-select,
    .wpcf7-form-control.wpcf7-textarea {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .wpcf7-form-control.wpcf7-submit {
        width: 100%;
        padding: 16px 36px;
        font-size: 16px;
    }
    
    .wpcf7-form label {
        font-size: 14px;
    }
}

/* 2カラムレイアウト用（オプション） */
.form-row-cf7 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.form-row-cf7 p {
    margin-bottom: 0;
}

@media (max-width: 968px) {
    .form-row-cf7 {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-row-cf7 p {
        margin-bottom: 30px;
    }
}

