/* Chat Bot Widget Styles */
:root {
    --chat-primary: #198754;
    /* FortMED Green */
    --chat-primary-dark: #146c43;
    --chat-bg: #ffffff;
    --chat-text: #333333;
    --chat-light-bg: #f8f9fa;
    --chat-bubble-user: #198754;
    --chat-bubble-bot: #f0f2f5;
    --font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
}

.chat-widget-container {
    position: fixed;
    bottom: 25px;
    left: 25px;
    /* Changed from right to left */
    z-index: 9999;
    font-family: var(--font-family);
}

/* 1. Toggle Button (Floating Action Button) */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-toggle-btn i {
    font-size: 28px;
    transition: transform 0.3s ease;
}

.chat-toggle-btn.open i {
    transform: rotate(90deg);
}

.chat-toggle-btn .close-icon {
    display: none;
}

.chat-toggle-btn.open .chat-icon {
    display: none;
}

.chat-toggle-btn.open .close-icon {
    display: block;
}

/* 2. Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    /* Changed from right to left */
    width: 350px;
    height: 500px;
    background: var(--chat-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
    /* Changed origin to left */
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-window.active {
    transform: scale(1);
    opacity: 1;
}

/* Header */
.chat-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-header-info p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    padding-bottom: 5px;
    /* Added slight padding */
    overflow-y: auto;
    background: var(--chat-light-bg);
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scroll-behavior: smooth;
    /* Smooth scrolling */
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message.bot {
    align-self: flex-start;
    background: var(--chat-bubble-bot);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--chat-bubble-user);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(25, 135, 84, 0.2);
}

.message-time {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    background: var(--chat-bubble-bot);
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 4px;
    width: fit-content;
}

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

.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);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--chat-primary);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.chat-send-btn:hover {
    background: var(--chat-primary-dark);
    transform: scale(1.1);
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        bottom: 90px;
        right: 0;
        height: 60vh;
    }
}