/* Chat Widget Styles */
/* Colors:
   Primary: rgb(78, 101, 124) - #4e657c
   Light bg: rgb(215, 228, 245) - #d7e4f5
   Accent/red: rgb(190, 0, 23) - #be0017
   Lighter bg: rgb(222, 233, 247) - #dee9f7
   Dark text: rgb(52, 58, 64) - #343a40
*/

/* Chat Button */
.chat-widget-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgb(78, 101, 124);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(78, 101, 124, 0.4);
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(78, 101, 124, 0.5);
}

.chat-widget-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
}

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

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

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

/* Unread Badge */
.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    background: rgb(190, 0, 23);
    color: white;
    border-radius: 11px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    animation: pulse-badge 2s infinite;
}

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

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.chat-widget-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(78, 101, 124, 0.3);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chat-widget-window.is-open {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* Header */
.chat-widget-header {
    background: rgb(78, 101, 124);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chat-widget-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

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

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

.chat-widget-header-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Messages Container */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: rgb(222, 233, 247);
}

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

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

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: rgb(78, 101, 124);
    border-radius: 3px;
}

/* Message */
.chat-message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
    max-width: 90%;
}

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

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

.chat-message.operator,
.chat-message.system {
    justify-content: flex-start;
}

.chat-message-bubble {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message.user .chat-message-bubble {
    background: rgb(78, 101, 124);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.operator .chat-message-bubble {
    background: white;
    color: rgb(52, 58, 64);
    border: 1px solid rgb(215, 228, 245);
    border-bottom-left-radius: 4px;
}

.chat-message.system .chat-message-bubble {
    background: rgb(215, 228, 245);
    color: rgb(78, 101, 124);
    font-size: 12px;
    font-style: italic;
    max-width: 100%;
    text-align: center;
}

.chat-message-time {
    font-size: 10px;
    color: rgb(78, 101, 124);
    opacity: 0.7;
    margin-top: 4px;
}

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

/* Input Area */
.chat-widget-input {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid rgb(215, 228, 245);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-widget-input textarea {
    flex: 1;
    border: 1px solid rgb(215, 228, 245);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    color: rgb(52, 58, 64);
}

.chat-widget-input textarea:focus {
    border-color: rgb(78, 101, 124);
}

.chat-widget-input textarea::placeholder {
    color: rgb(78, 101, 124);
    opacity: 0.6;
}

.chat-widget-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgb(78, 101, 124);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.chat-widget-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-widget-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Empty State */
.chat-widget-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgb(78, 101, 124);
    text-align: center;
    padding: 20px;
}

.chat-widget-empty svg {
    width: 60px;
    height: 60px;
    fill: rgb(215, 228, 245);
    margin-bottom: 16px;
}

.chat-widget-empty-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgb(52, 58, 64);
}

.chat-widget-empty-text {
    font-size: 14px;
    color: rgb(78, 101, 124);
}

/* Loading State */
.chat-widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-widget-loading-dots {
    display: flex;
    gap: 4px;
}

.chat-widget-loading-dots span {
    width: 8px;
    height: 8px;
    background: rgb(78, 101, 124);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-widget-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-widget-loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.chat-widget-loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 420px) {
    .chat-widget-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }

    .chat-widget-btn {
        width: 54px;
        height: 54px;
        bottom: 15px;
        right: 15px;
    }

    .chat-widget-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* Dark mode - disabled to keep site colors consistent */
