/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Position variants */
.chat-widget-bottom-right {
    right: 20px;
    bottom: 20px;
}

.chat-widget-bottom-left {
    left: 80px;
    bottom: 80px;
}

.chat-widget-top-right {
    right: 20px;
    top: 20px;
}

.chat-widget-top-left {
    left: 20px;
    top: 20px;
}

/* Toggle button */
.chat-widget-toggle {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a448a;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 3;
    bottom: 20px;
    right: 20px;
}

.chat-widget-close-icon .chat-widget-icon {
    font-size: 32px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

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

.chat-widget-toggle:active {
    transform: scale(0.98);
}

.chat-widget-icon {
    font-size: 24px;
    line-height: 1;
}

/* Chat container */
.chat-widget-container {
    display: none;
    flex-direction: column;
    width: 360px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
    z-index: 1;

    right: 20px;
    bottom: 95px;
}

.chat-widget-open .chat-widget-container {
    display: flex;
    animation: chatWidgetFadeIn 0.2s ease;
}

@keyframes chatWidgetFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chat-widget-header {
    padding: 16px;
    background: #1a448a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    /* background: rgba(255, 255, 255, 0.2); */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.chat-widget-title {
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    margin: -4px -4px -4px 8px;
    transition: opacity 0.2s;
    display: none;
    /* Hide the close button in header since we're using the toggle button */
}

.chat-widget-close:hover {
    opacity: 1;
}

.chat-widget-new-chat,
.chat-widget-popout {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-popout {
    margin-left: auto;
    /* Push to the right */
    margin-right: 4px;
}

.chat-widget-new-chat {
    margin-left: 0;
}

.chat-widget-new-chat:hover,
.chat-widget-popout:hover {
    opacity: 1;
}

.chat-widget-new-chat svg,
.chat-widget-popout svg {
    width: 20px;
    height: 20px;
}

/* Messages container */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-sizing: border-box;
}

/* Message wrapper */
.chat-widget-message-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Individual messages */
.chat-widget-message {
    margin-bottom: 8px;
    max-width: 85%;
    animation: messageFadeIn 0.2s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget-message-user {
    margin-left: auto;
    align-items: flex-end;
}

.chat-widget-message-assistant {
    margin-right: auto;
    align-items: flex-start;
}

.chat-widget-message-content {
    padding: 10px 16px;
    border-radius: 18px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: normal;
    hyphens: auto;
    display: inline-block;
    position: relative;
}

.chat-widget-message-timestamp {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
    line-height: 1.2;
    opacity: 0.8;
}

.chat-widget-message-user .chat-widget-message-timestamp {
    color: rgba(255, 255, 255, 0.7);
}

.chat-widget-message-user .chat-widget-message-content {
    background: #1a448a;
    color: white;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    margin-left: 25%;
    text-align: left;
    max-width: 100%;
    width: auto;
    min-width: 80px;
}

.chat-widget-message-assistant .chat-widget-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    margin-right: 25%;
    max-width: 100%;
    width: auto;
    min-width: 80px;
}

/* Typing indicator */
.chat-widget-typing {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0 0 2px 25%;
    height: 20px;
    padding: 2px 0;
    position: relative;
}

.chat-widget-typing span {
    height: 6px;
    width: 6px;
    background: #6b7280;
    border-radius: 50%;
    display: inline-block;
    margin: 0 3px;
    animation: typingAnimation 0.9s infinite ease-in-out both;
    transform: translateY(0);
}

.chat-widget-typing span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingAnimation {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    50% {
        transform: translateY(-2px);
        opacity: 1;
    }
}

/* Input area */
.chat-widget-input-container {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-widget-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-widget-input:focus {
    outline: none;
    border-color: #1a448a;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-widget-send {
    background: #1a448a;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.1s;
}

.chat-widget-send:hover {
    background: #4338ca;
}

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

.chat-widget-send svg {
    width: 18px;
    height: 18px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .chat-widget-container {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-widget {
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .chat-widget-bottom-right,
    .chat-widget-bottom-left,
    .chat-widget-top-right,
    .chat-widget-top-left {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .chat-widget-toggle {
        bottom: 20px;
        right: 20px;
    }
}

/* Scrollbar styling - hidden but scrollable */
.chat-widget-messages {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.chat-widget-messages::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
    width: 0;
    height: 0;
}