/* ===================================
   塗装診断チャットウィジェット
   =================================== */

/* チャット開始ボタン */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6F00 0%, #F57C00 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 111, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
    z-index: 999;
    animation: pulse 2s ease-in-out infinite;
}

/* 固定電話ボタンがある場合の調整 */
.fixed-phone-button + .chat-button,
body:has(.fixed-phone-button) .chat-button {
    bottom: 110px; /* 固定電話ボタンの上に配置 */
}

.chat-button i {
    font-size: 28px;
}

.chat-button span {
    font-size: 11px;
    font-weight: 700;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(255, 111, 0, 0.6);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(255, 111, 0, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(255, 111, 0, 0.7);
    }
}

/* チャットウィジェット */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.chat-widget.active {
    display: flex;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* チャットヘッダー */
.chat-header {
    background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%);
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
}

.chat-header-title i {
    font-size: 24px;
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.chat-icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* チャットメッセージエリア */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* メッセージ */
.chat-message {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

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

.message-content {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.bot-message .message-content {
    flex-direction: row;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    flex-direction: row-reverse;
}

/* アバター */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar i {
    font-size: 20px;
}

/* メッセージバブル */
.message-bubble {
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 15px;
}

.bot-message .message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #FF6F00 0%, #F57C00 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #1E88E5;
}

.message-bubble strong {
    color: #FF6F00;
}

.message-bubble small {
    display: block;
    font-size: 13px;
    opacity: 0.8;
    margin-top: 5px;
}

/* オプションボタン */
.chat-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeIn 0.3s ease-out 0.3s both;
}

.chat-option-btn {
    padding: 15px 20px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: block;
    text-decoration: none;
}

.chat-option-btn:hover {
    background: #f8f9fa;
    border-color: #1E88E5;
    color: #1E88E5;
    transform: translateX(5px);
}

.chat-option-btn.selected {
    background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%);
    border-color: #1E88E5;
    color: #fff;
}

.chat-next-btn {
    background: linear-gradient(135deg, #FF6F00 0%, #F57C00 100%);
    border-color: #FF6F00;
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.chat-next-btn:hover {
    background: linear-gradient(135deg, #F57C00 0%, #E65100 100%);
    transform: scale(1.05);
}

.chat-cta-btn {
    background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%);
    border-color: #1E88E5;
    color: #fff;
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.chat-cta-btn:hover {
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
    border-color: #1565C0;
    color: #fff;
    transform: scale(1.05);
}

.chat-line-btn {
    background: linear-gradient(135deg, #06C755 0%, #00B140 100%);
    border-color: #06C755;
}

.chat-line-btn:hover {
    background: linear-gradient(135deg, #00B140 0%, #009A34 100%);
}

/* 診断結果 */
.diagnosis-result {
    margin-top: 15px;
}

.urgency-meter {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.urgency-label {
    font-size: 14px;
    font-weight: 700;
    color: #666;
    margin-bottom: 10px;
}

.urgency-bar {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.urgency-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 1s ease-out;
    position: relative;
}

.urgency-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.3) 0%, 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.3) 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.urgency-high {
    background: linear-gradient(90deg, #FF5252 0%, #E53935 100%);
}

.urgency-medium {
    background: linear-gradient(90deg, #FF9800 0%, #F57C00 100%);
}

.urgency-low {
    background: linear-gradient(90deg, #4CAF50 0%, #388E3C 100%);
}

.urgency-value {
    font-size: 24px;
    font-weight: 900;
    color: #FF6F00;
    text-align: center;
    margin-top: 10px;
}

.diagnosis-recommendations {
    margin-bottom: 20px;
}

.diagnosis-recommendations p {
    margin-bottom: 10px;
    padding-left: 0;
}

.diagnosis-cost {
    background: #FFF3E0;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #FF6F00;
    margin-bottom: 20px;
    text-align: center;
}

.diagnosis-cost strong {
    display: block;
    font-size: 16px;
    margin-bottom: 10px;
    color: #FF6F00;
}

.diagnosis-cta {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    padding: 15px;
    border-radius: 10px;
    border: 2px dashed #1E88E5;
}

.diagnosis-cta p {
    margin-bottom: 8px;
}

.diagnosis-cta strong {
    color: #1E88E5;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .chat-widget {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-button {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
    }
    
    /* 固定電話ボタンがある場合の調整（スマホ） */
    .fixed-phone-button + .chat-button,
    body:has(.fixed-phone-button) .chat-button {
        bottom: 90px; /* 固定電話ボタンの上に配置 */
    }

    .chat-button i {
        font-size: 24px;
    }

    .chat-button span {
        font-size: 10px;
    }

    .message-content {
        max-width: 90%;
    }

    .message-bubble {
        font-size: 14px;
        padding: 12px 16px;
    }

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

/* スクロールバーのスタイリング */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #1E88E5;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #1565C0;
}
