/* チャットウィジェット - 円形フローティングボタンスタイル */

#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', 'メイリオ', Meiryo, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* === フローティングボタン（共通スタイル） === */
.floating-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

.floating-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.floating-button:active {
    transform: scale(0.95);
}

.floating-button svg {
    width: 24px;
    height: 24px;
}

/* === HOMEボタン（上に配置） === */
#home-button {
    background: linear-gradient(135deg, #800000 0%, #800000 100%);
}

#home-button:hover {
    background: linear-gradient(135deg, #800000 0%, #800000 100%);
}

/* === チャットボタン（下に配置） === */
#chat-toggle {
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(123, 104, 238, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(123, 104, 238, 0.5);
    }
}

#chat-toggle:hover {
    background: linear-gradient(135deg, #8A77F7 0%, #7969DC 100%);
}

/* === チャットウィンドウ === */
#chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 400px;

    height: min(600px, calc(100vh - 130px));  /* 画面高さに合わせて自動調整 */
    max-height: calc(100vh - 130px);

    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* === ヘッダー === */
#chat-header {
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.status {
    color: white;
    font-size: 12px;
    opacity: 0.9;
}

/* === ヘッダーボタン === */
.header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-buttons button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.header-buttons button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-icon-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-icon-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.header-icon-button svg {
    width: 18px;
    height: 18px;
}

/* === メッセージエリア === */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* === メッセージ === */
.message {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
}

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

.user-message .message-avatar {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.message-bubble {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message .message-content {
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

/* === タイピングインジケーター === */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* === 入力エリア === */
#chat-input-container {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e8e8e8;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

#chat-input:focus {
    border-color: #7B68EE;
    box-shadow: 0 0 0 3px rgba(123, 104, 238, 0.1);
}

#chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

#chat-send:hover {
    transform: scale(1.05);
}

#chat-send:active {
    transform: scale(0.95);
}

#chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* === Powered by === */
.powered-by {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: #999;
    background: white;
    border-top: 1px solid #e8e8e8;
}

/* === エラーメッセージ === */
.error-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.5;
}

/* === レスポンシブ対応 === */
@media (max-width: 480px) {
    #chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: 600px;
        right: 20px;
        bottom: 100px;
    }

    .floating-button {
        width: 56px;
        height: 56px;
    }

    .floating-button svg {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 400px) {
    #chat-window {
        width: calc(100vw - 20px);
        right: 10px;
    }

    .floating-button {
        width: 52px;
        height: 52px;
    }
}
