/* ============================================
   チャット風マッチング UI — スタイル
   ============================================ */

.matching-page {
    padding: 24px 0 40px;
    min-height: 70vh;
    overflow-x: hidden;
    background-color: #F5F5F5;
}

/* 進捗バー */
.progress-container {
    max-width: 600px;
    margin: 0 auto 16px;
    padding: 0 16px;
    box-sizing: border-box;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.progress-label {
    font-size: 12px;
    color: #666666;
}

.progress-percent {
    font-size: 13px;
    font-weight: 700;
    color: #003366;
}

.progress-track {
    width: 100%;
    height: 6px;
    background-color: #E0E0E0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #003366, #0056b3);
    border-radius: 3px;
    transition: width 0.4s ease, background 0.4s ease;
}

.progress-step {
    font-size: 12px;
    color: #999999;
    text-align: right;
    margin-top: 4px;
    margin-bottom: 0;
}

/* チャットコンテナ */
.chat-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
    background: #F5F5F5;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.chat-input-area {
    overflow: visible !important;
    position: relative;
    z-index: 50;
}

.chat-suggest-wrapper {
    position: relative;
}

.chat-suggest-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    max-height: 250px;
    overflow-y: auto;
    background: #FFFFFF;
    border: 1px solid #CCCCCC;
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    margin-bottom: 4px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-input-area {
    padding: 12px 16px;
    background: #FFFFFF;
    border-top: 1px solid #E0E0E0;
    min-height: 0;
}

.chat-input-area:empty {
    display: none;
}

/* メッセージ共通 */
.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* AI（左側） */
.chat-row-ai {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #003366;
}

.chat-avatar svg {
    width: 22px;
    height: 22px;
}

.chat-bubble-ai {
    background: #FFFFFF;
    color: #333333;
    padding: 12px 16px;
    border-radius: 2px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 15px;
    line-height: 1.65;
    word-break: break-word;
}

.chat-bubble-ai strong {
    color: #C62828;
    font-weight: 700;
}

.chat-ai-name {
    font-size: 11px;
    color: #888888;
    margin-left: 44px;
    margin-bottom: 2px;
    margin-top: 8px;
}

/* ユーザー（右側） */
.chat-row-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-bubble-user {
    background: #003366;
    color: #FFFFFF;
    padding: 12px 16px;
    border-radius: 16px 2px 16px 16px;
    font-size: 15px;
    line-height: 1.65;
    word-break: break-word;
}

/* タイピングインジケーター */
.chat-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    max-width: 88%;
}

.typing-dots {
    background: #FFFFFF;
    padding: 12px 20px;
    border-radius: 2px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #AAAAAA;
    animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 選択肢ボタン（チャット入力エリア内） */
.chat-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-option-btn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background: #FFFFFF;
    border: 2px solid #003366;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #003366;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.chat-option-btn:hover {
    background: #EBF0F5;
    border-color: #0056b3;
}

.chat-option-btn:active,
.chat-option-btn.selected {
    background: #003366;
    color: #FFFFFF;
    border-color: #003366;
}

/* セレクトボックス */
.chat-select-wrapper {
    display: flex;
    gap: 8px;
}

.chat-select {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #003366;
    border-radius: 8px;
    background: #FFFFFF;
    color: #333333;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23003366' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    box-sizing: border-box;
}

.chat-select:focus {
    outline: none;
    border-color: #0056b3;
}

.chat-select-btn {
    padding: 14px 24px;
    background: #003366;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #FFFFFF;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.chat-select-btn:hover {
    background: #004080;
}

.chat-select-btn:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

/* テキスト入力 */
.chat-text-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #003366;
    border-radius: 8px;
    background: #FFFFFF;
    color: #333333;
    box-sizing: border-box;
}

.chat-text-input:focus {
    outline: none;
    border-color: #0056b3;
}

.chat-text-input::placeholder {
    color: #AAAAAA;
}

/* サジェストUI */
.chat-suggest-wrapper {
    position: relative;
}

.suggest-list {
    position: absolute;
    background: #FFFFFF;
    border: 1px solid #CCC;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.suggest-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #F0F0F0;
}

.suggest-item:last-child {
    border-bottom: none;
}

.suggest-item:hover {
    background: #EBF0F5;
}

/* メール入力 */
.chat-email-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-email-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #003366;
    border-radius: 8px;
    background: #FFFFFF;
    color: #333333;
    box-sizing: border-box;
}

.chat-email-input:focus {
    outline: none;
    border-color: #0056b3;
}

.chat-email-input::placeholder {
    color: #AAAAAA;
}

.chat-consent-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #555555;
    line-height: 1.6;
}

.chat-consent-group input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.chat-consent-group a {
    color: #0056b3;
    text-decoration: underline;
}

.chat-consent-group.consent-error {
    color: #C62828;
    font-weight: 700;
}

.chat-email-submit {
    padding: 14px 24px;
    background: #003366;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #FFFFFF;
    cursor: pointer;
    transition: background-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.chat-email-submit:hover {
    background: #004080;
}

.chat-email-submit:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

/* ============================================
   結果表示 — リードゲート
   ============================================ */

.result-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 結果バナー */
.result-banner {
    text-align: center;
    padding: 32px 20px;
    background: linear-gradient(135deg, #003366, #004d99);
    border-radius: 16px;
    margin-bottom: 24px;
    color: #FFFFFF;
    animation: chatFadeIn 0.5s ease;
}

.result-banner-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.result-banner-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #FFFFFF;
}

.result-banner-title strong {
    color: #FFD54F;
    font-size: 32px;
}

.result-banner-sub {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    margin: 0;
}

/* 補助金カード */
.subsidy-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #003366;
}

.subsidy-card[data-match="high"] {
    border-left-color: #2E7D32;
}

.subsidy-card[data-match="low"] {
    border-left-color: #999999;
}

.subsidy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.subsidy-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #003366;
    margin: 0;
    flex: 1;
}

.subsidy-card-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-high {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-medium {
    background: #E3F2FD;
    color: #1565C0;
}

.badge-low {
    background: #F5F5F5;
    color: #666666;
}

.subsidy-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.subsidy-detail-item {
    display: flex;
    flex-direction: column;
    background: #F8F9FA;
    padding: 8px 12px;
    border-radius: 6px;
    min-width: 100px;
    flex: 1;
}

.subsidy-detail-label {
    font-size: 11px;
    color: #888888;
    margin-bottom: 2px;
}

.subsidy-detail-value {
    font-size: 14px;
    font-weight: 700;
    color: #333333;
}

.subsidy-card-summary {
    font-size: 13px;
    color: #555555;
    line-height: 1.6;
    margin: 0;
}

.subsidy-card-meta {
    margin-top: 8px;
}

.subsidy-card-deadline {
    font-size: 12px;
    color: #C62828;
    font-weight: 600;
}

/* すりガラスモザイク */
.blurred-results-wrapper {
    position: relative;
}

.blurred-results-inner {
    filter: blur(8px);
    -webkit-filter: blur(8px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    transition: filter 0.5s ease;
}

.blurred-results-wrapper.revealed .blurred-results-inner {
    filter: none;
    -webkit-filter: none;
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

.blurred-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.85) 40%, rgba(255,255,255,0.95) 100%);
}

.blurred-overlay-content {
    text-align: center;
    padding: 32px 24px;
}

.blurred-overlay-text {
    font-size: 16px;
    color: #333333;
    margin: 0 0 20px;
    line-height: 1.6;
}

.blurred-overlay-text strong {
    color: #C62828;
}

.blurred-overlay-btn {
    display: inline-block;
    padding: 18px 40px;
    background: linear-gradient(135deg, #C62828, #E53935);
    color: #FFFFFF;
    font-size: 17px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(198,40,40,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
    animation: ctaPulse 2s infinite;
}

.blurred-overlay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(198,40,40,0.4);
}

@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(198,40,40,0.3); }
    50% { box-shadow: 0 4px 24px rgba(198,40,40,0.5); }
}

/* ============================================
   システム興味質問
   ============================================ */

.system-interest-section {
    margin-top: 32px;
    animation: chatFadeIn 0.5s ease;
}

.system-interest-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}

.system-interest-title {
    font-size: 16px;
    font-weight: 700;
    color: #003366;
    margin: 0 0 16px;
}

.system-interest-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.system-interest-btn {
    padding: 12px 24px;
    background: #FFFFFF;
    border: 2px solid #003366;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #003366;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.system-interest-btn:hover {
    background: #EBF0F5;
}

.system-interest-btn.selected {
    background: #003366;
    color: #FFFFFF;
}

/* ============================================
   最終CTA
   ============================================ */

.final-cta-section {
    margin-top: 24px;
    animation: chatFadeIn 0.5s ease;
}

.final-cta-card {
    background: linear-gradient(135deg, #003366, #004d99);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    color: #FFFFFF;
}

.final-cta-text {
    font-size: 15px;
    line-height: 1.7;
    margin: 0 0 24px;
    color: rgba(255,255,255,0.9);
}

.final-cta-text strong {
    color: #FFD54F;
}

.final-cta-btn {
    display: inline-block;
    padding: 18px 48px;
    background: linear-gradient(135deg, #C62828, #E53935);
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(198,40,40,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
    animation: ctaPulse 2s infinite;
}

.final-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(198,40,40,0.4);
    color: #FFFFFF;
    text-decoration: none;
}

.final-cta-note {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin: 12px 0 0;
}

/* サジェスト入力 */
.chat-suggest-wrapper {
    position: relative;
    flex: 1;
}

.chat-suggest-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #003366;
    border-radius: 8px;
    background: #FFFFFF;
    color: #333333;
    box-sizing: border-box;
}

.chat-suggest-input:focus {
    outline: none;
    border-color: #0056b3;
}

.chat-suggest-input::placeholder {
    color: #AAAAAA;
}

/* 重複定義削除 — .chat-suggest-dropdown は85行目で定義済み */

.chat-suggest-item {
    padding: 10px 16px;
    font-size: 15px;
    color: #333333;
    cursor: pointer;
    transition: background-color 0.1s;
}

.chat-suggest-item:hover {
    background: #EBF0F5;
    color: #003366;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .matching-page {
        padding: 12px 0 24px;
    }

    .progress-container {
        max-width: 100%;
        padding: 0 12px;
    }

    .chat-container {
        max-width: 100%;
        height: calc(100vh - 180px);
        border-radius: 0;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .chat-row {
        max-width: 92%;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
    }

    .chat-avatar svg {
        width: 20px;
        height: 20px;
    }

    .chat-bubble-ai,
    .chat-bubble-user {
        font-size: 14px;
        padding: 10px 14px;
    }

    .chat-ai-name {
        margin-left: 40px;
    }

    .chat-option-btn {
        padding: 12px 14px;
        font-size: 14px;
    }

    .chat-select,
    .chat-text-input,
    .chat-email-input {
        font-size: 16px; /* iOS zoom prevention */
        padding: 12px 14px;
    }

    .result-container {
        padding: 0 12px;
    }

    .result-banner {
        padding: 24px 16px;
        border-radius: 12px;
    }

    .result-banner-title {
        font-size: 20px;
    }

    .result-banner-title strong {
        font-size: 28px;
    }

    .subsidy-card {
        padding: 16px;
    }

    .subsidy-card-title {
        font-size: 15px;
    }

    .subsidy-detail-item {
        min-width: 80px;
    }

    .blurred-overlay-btn {
        padding: 16px 32px;
        font-size: 16px;
    }

    .system-interest-buttons {
        flex-direction: column;
    }

    .system-interest-btn {
        width: 100%;
    }

    .final-cta-btn {
        padding: 16px 32px;
        font-size: 16px;
    }
}

@media (max-width: 414px) {
    .matching-page {
        padding: 8px 0 20px;
    }

    .chat-container {
        height: calc(100vh - 160px);
    }

    .chat-option-btn {
        padding: 11px 12px;
        font-size: 13px;
    }

    .result-banner {
        padding: 20px 12px;
    }

    .result-banner-title {
        font-size: 18px;
    }

    .result-banner-title strong {
        font-size: 24px;
    }

    .subsidy-card {
        padding: 14px;
    }

    .subsidy-card-header {
        flex-direction: column;
        gap: 6px;
    }

    .blurred-overlay-content {
        padding: 24px 16px;
    }

    .blurred-overlay-text {
        font-size: 14px;
    }

    .blurred-overlay-btn {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .final-cta-card {
        padding: 24px 16px;
    }

    .final-cta-btn {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
        box-sizing: border-box;
    }
}


/* ============================================
   Exit modal
   ============================================ */
.exit-modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.5);z-index:10000;display:flex;align-items:center;justify-content:center;padding:20px;animation:fadeInOverlay .3s ease}
@keyframes fadeInOverlay{from{opacity:0}to{opacity:1}}
.exit-modal{background:#fff;border-radius:8px;padding:48px 40px 40px;max-width:460px;width:100%;text-align:center;position:relative;animation:slideUpModal .3s ease}
@keyframes slideUpModal{from{transform:translateY(24px);opacity:0}to{transform:translateY(0);opacity:1}}
.exit-modal-close{position:absolute;top:12px;right:16px;background:none;border:none;font-size:28px;color:#999;cursor:pointer;line-height:1;padding:4px}
.exit-modal-close:hover{color:#333}
.exit-modal-title{font-size:22px;font-weight:700;color:#003366;margin-bottom:12px}
.exit-modal-desc{font-size:15px;color:#555;line-height:1.7;margin-bottom:24px}
.exit-modal-btn{font-size:16px;font-weight:700;padding:16px 40px}
.exit-modal-note{font-size:12px;color:#999;margin-top:12px;margin-bottom:0}
@media(max-width:768px){.exit-modal{padding:36px 24px 32px}.exit-modal-title{font-size:19px}.exit-modal-desc br{display:none}}
