/* Modern Chatbot Styles — matches site theme (--primary / --secondary from page :root) */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #174487) 0%, var(--secondary, #2563eb) 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(23, 68, 135, 0.35);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(23, 68, 135, 0.45);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    animation: slideUp 0.3s ease;
}

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

.chatbot-window.active {
    display: flex;
}

.chatbot-header {
    background: linear-gradient(135deg, var(--primary, #174487) 0%, var(--secondary, #2563eb) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-title i {
    font-size: 18px;
}

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

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f9fafb;
    scroll-behavior: smooth;
}

.chatbot-message {
    margin-bottom: 12px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.message-bot {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 8px;
}

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

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
    font-size: 14px;
    position: relative;
    white-space: pre-wrap;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--primary, #174487) 0%, var(--secondary, #2563eb) 100%);
    color: white;
    border: none;
}

.message-bot .message-content {
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
}

.message-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary, #174487) 0%, var(--secondary, #2563eb) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 2px 8px rgba(23, 68, 135, 0.3);
}

.typing-word {
    display: inline;
    opacity: 0;
    transform: translateY(2px);
    will-change: opacity, transform;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.typing-word.word-visible {
    opacity: 1;
    transform: translateY(0);
}

.typing-cursor {
    display: inline-block;
    color: var(--secondary, #2563eb);
    font-weight: bold;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.thinking-text {
    color: #9ca3af;
    font-style: italic;
    font-size: 13px;
}

.message-timestamp {
    font-size: 11px;
    color: #8e8e93;
    margin-top: 4px;
    text-align: right;
}

.chatbot-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #f9fafb;
    font-family: inherit;
}

.chatbot-input:focus {
    border-color: var(--secondary, #2563eb);
    background: white;
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    background: linear-gradient(135deg, var(--primary, #174487) 0%, var(--secondary, #2563eb) 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.chatbot-send:hover {
    filter: brightness(1.08);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chatbot-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Prevent body scroll when chatbot is open */
body.chatbot-open {
    overflow: hidden;
}

/* Ensure chatbot scrolling works independently */
.chatbot-window.active {
    pointer-events: auto;
    touch-action: pan-y;
}

.chatbot-messages {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Custom scrollbar for chat messages */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 2px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}
