:root {
    --chat-primary: #2563eb;
    --chat-primary-dark: #1d4ed8;
    --chat-surface: #ffffff;
    --chat-muted: #64748b;
    --chat-line: #e2e8f0;
    --chat-bg: #f8fafc;
    --chat-user: #1d4ed8;
    --chat-bot: #f1f5f9;
    --chat-danger-bg: #fee2e2;
    --chat-danger-text: #991b1b;
}

.chat-toggler {
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 1001;
}

.chat-toggler button {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: var(--chat-primary);
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.28);
}

.chat-widget-container {
    position: fixed;
    right: 30px;
    bottom: 96px;
    z-index: 1000;
    width: 410px;
    height: 660px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--chat-surface);
    border: 1px solid var(--chat-line);
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
    transition: width 0.25s ease, height 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

.chat-widget-container.chat-closed {
    width: 0;
    height: 0;
    opacity: 0;
    transform: translate(40px, 40px);
    pointer-events: none;
}

.resized-widget {
    width: 620px !important;
    height: 820px !important;
}

.chat-header {
    min-height: 68px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #0f172a;
    background: #fff;
    border-bottom: 1px solid var(--chat-line);
}

.chat-header-inner,
.chat-header-actions {
    display: flex;
    align-items: center;
}

.chat-header-inner {
    min-width: 0;
    gap: 10px;
}

.chat-header-actions {
    gap: 8px;
}

.chat-back-icon,
.chat-resize-icon,
.chat-toggle-icon,
.conversation-list-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #475569;
    cursor: pointer;
}

.chat-back-icon:hover,
.chat-resize-icon:hover,
.chat-toggle-icon:hover,
.conversation-list-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.chat-resize-icon {
    transform: rotate(45deg);
}

.chat-toggle-icon {
    transform: rotate(180deg);
}

.chat-closed .chat-toggle-icon {
    transform: rotate(0deg);
}

.chat-header-avatar,
.advisor-avatar,
.conversation-item-avatar,
.start-advisor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
}

.chat-header-avatar img,
.advisor-avatar img,
.conversation-item-avatar img,
.start-advisor img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.chat-header-avatar.is-generic,
.advisor-avatar.is-generic,
.conversation-item-avatar.is-generic {
    color: #2563eb;
    background: #dbeafe;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.chat-header-text {
    min-width: 0;
}

.chat-title {
    font-size: 15px;
    line-height: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle {
    font-size: 12px;
    line-height: 16px;
    color: var(--chat-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-body {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
}

.chat-closed .chat-body {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
}

.message.user-message {
    justify-content: flex-end;
}

.message.bot-message {
    justify-content: flex-start;
}

.advisor-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 12px;
    background: var(--chat-primary);
}

.message-content {
    max-width: min(78%, 420px);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.42;
    word-break: break-word;
}

.user-message .message-content {
    color: #fff;
    background: var(--chat-user);
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    color: #0f172a;
    background: var(--chat-bot);
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.advisor-name {
    margin-bottom: 3px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    color: #334155;
}

.message .timestamp {
    margin-top: 6px;
    font-size: 11px;
    line-height: 14px;
    color: rgba(255, 255, 255, 0.78);
}

.bot-message .timestamp {
    color: #64748b;
}

.chat-start-panel {
    margin: 4px auto 18px;
    padding: 14px 12px;
    max-width: 360px;
    text-align: center;
    color: #0f172a;
}

.start-advisors {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.start-advisor {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-left: -6px;
    font-size: 12px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.start-advisor:first-child {
    margin-left: 0;
}

.start-title {
    margin-bottom: 6px;
    font-size: 19px;
    line-height: 25px;
    font-weight: 800;
}

.start-copy,
.start-message {
    color: var(--chat-muted);
    font-size: 13px;
    line-height: 19px;
}

.start-message {
    margin-top: 10px;
}

.start-new-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    cursor: pointer;
    text-align: left;
}

.start-new-btn span {
    font-weight: 800;
}

.start-new-btn small {
    color: #475569;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #fff;
}

.conversation-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.conversation-list-title {
    font-size: 18px;
    line-height: 24px;
    font-weight: 800;
    color: #0f172a;
}

.conversation-list-subtitle {
    max-width: 290px;
    color: var(--chat-muted);
    font-size: 12px;
    line-height: 17px;
}

.new-conversation-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    cursor: pointer;
    text-align: left;
}

.new-conversation-card:hover {
    background: #dbeafe;
}

.new-conversation-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--chat-primary);
    color: #fff;
}

.new-conversation-card strong,
.new-conversation-card small {
    display: block;
}

.new-conversation-card small {
    margin-top: 2px;
    color: #475569;
    line-height: 16px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    background: #fff;
}

.conversation-item:hover {
    border-color: #bfdbfe;
    background: #f8fafc;
}

.conversation-item-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 12px;
}

.conversation-item-body {
    min-width: 0;
}

.conversation-item-title {
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item-snippet {
    margin-top: 2px;
    font-size: 12px;
    color: var(--chat-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--chat-line);
}

.chat-input textarea {
    box-sizing: border-box;
    min-height: 46px;
    max-height: 120px;
    flex: 1;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    line-height: 20px;
    outline: none;
}

.chat-input textarea:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.chat-btn {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-input button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.send-btn {
    background: var(--chat-primary);
    color: #fff;
}

.send-btn:hover {
    background: var(--chat-primary-dark);
}

.attachment-btn {
    background: #f1f5f9 !important;
    color: #475569 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-btn:hover {
    background: #e2e8f0 !important;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: #475569;
    background: #fff;
    border-top: 1px dashed #cbd5e1;
}

.attachment-preview span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-remove-btn {
    border: 0 !important;
    background: transparent !important;
    color: #64748b !important;
    font-size: 20px !important;
    width: 26px !important;
    height: 26px !important;
    cursor: pointer;
}

.message-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    text-decoration: none;
}

.bot-message .message-attachment {
    border-color: #cbd5e1;
    background: #fff;
}

.message-attachment-img {
    max-width: 210px;
    max-height: 150px;
    display: block;
    border-radius: 6px;
}

.error {
    display: none;
    margin: 10px 12px 0;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--chat-danger-text);
    background: var(--chat-danger-bg);
    font-size: 13px;
}

.typing-name {
    margin-bottom: 7px;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.typing-row {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 15px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    animation: typing-wave 1.1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-wave {
    0%, 70%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    35% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

.product-options {
    margin: -4px 0 12px 38px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-option {
    padding: 9px 11px;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    color: #0f172a;
}

.product-option:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.product-item {
    background: #fff;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    padding: 8px;
}

.product-item .flex {
    display: flex;
    gap: 10px;
    align-items: center;
}

.product-image img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #eee;
}

.product-details {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: #334155;
}

.product-title {
    display: block;
    margin-bottom: 2px;
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
}

.product-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12px;
    color: #64748b;
}

.price-promo {
    color: #b91c1c;
    font-weight: 800;
}

.price-old {
    color: #64748b;
    text-decoration: line-through;
}

.product-stock.in-stock {
    color: #15803d;
}

.product-stock.out-of-stock {
    color: #b45309;
}

@media screen and (max-width: 500px) {
    .chat-widget-container {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: 0;
        z-index: 1002;
    }

    .resized-widget {
        width: 100% !important;
        height: 100% !important;
    }

    .chat-resize-icon {
        display: none;
    }

    .chat-toggler {
        right: 18px;
        bottom: 18px;
    }

    .message-content {
        max-width: 82%;
    }
}
