.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--white);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all var(--transition);
    z-index: 999;
    border: none;
    outline: none;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.chat-button.has-unread::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--danger-color);
    border-radius: 50%;
    border: 2px solid var(--white);
}

.chat-panel {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 370px;
    height: 530px;
    background: var(--white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}

.chat-panel.open {
    display: flex;
}

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

.chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-light);
}

.chat-header h4 i {
    font-size: 1.2rem;
}

.chat-beta-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.9;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-new {
    background: none;
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    color: var(--gray-light);
    font-size: 0.9rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.chat-header-new:hover {
    opacity: 1;
    border-color: rgba(226,232,240,0.9);
    background: rgba(226,232,240,0.1);
}

.chat-header-close {
    background: none;
    border: none;
    color: var(--gray-light);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    margin-left: 2px;
}

.chat-header-close:hover {
    opacity: 1;
    color: var(--gray-light);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--light-bg);
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-light);
    border-radius: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageIn 0.25s ease;
}

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

.chat-message.bot {
    background: var(--white);
    color: var(--dark-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-light);
}

.chat-message.user {
    background: var(--primary-color);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.bot p {
    margin: 0 0 6px 0;
}

.chat-message.bot p:last-child {
    margin-bottom: 0;
}

.chat-message.bot ul, 
.chat-message.bot ol {
    margin: 4px 0;
    padding-left: 18px;
}

.chat-message.bot li {
    margin-bottom: 2px;
}

.chat-message.bot strong {
    color: var(--primary-color);
}

.chat-message.bot a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
}

.chat-message.bot a:hover {
    color: var(--secondary-dark);
}

.chat-message .chat-product-link {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-size: 0.8rem;
    transition: background var(--transition-fast);
}

.chat-message .chat-product-link:hover {
    background: var(--secondary-dark);
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--white);
    border-radius: var(--border-radius);
    align-self: flex-start;
    border: 1px solid var(--gray-light);
    box-shadow: var(--shadow-sm);
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: var(--gray);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.chat-input-area {
    display: flex;
    padding: 12px 16px;
    gap: 10px;
    border-top: 1px solid var(--gray-light);
    background: var(--white);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--gray-light);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    font-size: 0.9rem;
    outline: none;
    transition: border var(--transition-fast);
}

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

.chat-input-area button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--white);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input-area button:hover {
    background: var(--secondary-dark);
}

.chat-input-area button:disabled {
    background: var(--gray-light);
    color: var(--gray);
    cursor: not-allowed;
}

.chat-error {
    background: #FEF2F2;
    color: var(--danger-color);
    border: 1px solid #FECACA;
    align-self: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 8px 12px;
}

.chat-bot-text {
    margin-bottom: 6px;
    white-space: pre-wrap;
}
.chat-bot-text:last-child {
    margin-bottom: 0;
}
.chat-bot-text p {
    margin: 0 0 6px 0;
}
.chat-bot-text p:last-child {
    margin-bottom: 0;
}

.chat-product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.chat-product-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--light-bg);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    color: var(--dark-text);
    transition: background var(--transition-fast);
    border: 1px solid var(--gray-light);
}

.chat-product-card:hover {
    background: var(--white);
    border-color: var(--primary-color);
}

.chat-product-card-img {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
    background-color: var(--gray-light);
    background-size: cover;
    background-position: center;
}

.chat-product-card-info {
    flex: 1;
    min-width: 0;
}

.chat-product-card-name {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-product-card-price {
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.chat-product-card-link {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
}

.chat-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chatSpin 0.6s linear infinite;
}

@keyframes chatSpin {
    to { transform: rotate(360deg); }
}

.chat-variant-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .chat-button {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        bottom: 20px;
        right: 20px;
    }

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

    .chat-header {
        border-radius: 0;
    }
}
