/* ===== チャットウィジェット =====*/

/* チャットウィジェットコンテナ */
.chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* チャットウィンドウ */
.chat-widget-window {
    position: absolute;
    bottom: 100px;
    right: 0;
    width: 380px;
    height: 600px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
}

.chat-widget-window.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* チャットウィンドウヘッダー */
.chat-widget-header {
    background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%);
    color: white;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
    user-select: none;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-widget-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.chat-widget-header-title-icon {
    font-size: 18px;
}

.chat-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* チャットメッセージ領域 */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ウェルカムメッセージ */
.chat-widget-welcome {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
}

.chat-widget-welcome-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.chat-widget-welcome p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* メッセージ */
.chat-message {
    display: flex;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

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

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

.chat-message.assistant {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 8px;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.4;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #4CAF50, #81C784);
    color: white;
    border-radius: 8px 4px 8px 8px;
}

.chat-message.assistant .chat-message-content {
    background: rgba(76, 175, 80, 0.1);
    color: var(--text-color);
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: 4px 8px 8px 8px;
}

.chat-message-timestamp {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: flex-end;
}

/* タイピングインジケーター */
.chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 8px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: typing 1.4s infinite;
}

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

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

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

/* チャット入力フォーム */
.chat-widget-input-container {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 12px 12px;
}

.chat-widget-input-form {
    display: flex;
    gap: 8px;
}

.chat-widget-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 13px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
}

.chat-widget-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.chat-widget-send-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
}

.chat-widget-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.chat-widget-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* フローティングボタン */
.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid rgba(76, 175, 80, 0.3);
    background: #111;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    overflow: hidden;
}

.chat-widget-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.chat-widget-button.open {
    transform: scale(0.95);
}

.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ED4245;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid #111;
}

.chat-widget-badge.hidden {
    display: none;
}

@media (max-width: 768px) {
    .chat-widget-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-widget-window.open {
        transform: translateY(0);
    }
}
