/**
 * Centromex Chat Widget Styles
 */

/* Variables */
:root {
    --centromex-chat-primary: #2e7d32;
    --centromex-chat-primary-dark: #1b5e20;
    --centromex-chat-primary-light: #4caf50;
    --centromex-chat-bg: #ffffff;
    --centromex-chat-text: #333333;
    --centromex-chat-text-light: #666666;
    --centromex-chat-border: #e0e0e0;
    --centromex-chat-user-bg: #e8f5e9;
    --centromex-chat-bot-bg: #f5f5f5;
    --centromex-chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --centromex-chat-radius: 16px;
}

/* Chat widget container */
.centromex-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Toggle button */
.centromex-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--centromex-chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--centromex-chat-shadow);
    transition: transform 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.centromex-chat-toggle:hover {
    transform: scale(1.05);
    background: var(--centromex-chat-primary-dark);
}

.centromex-chat-toggle:active {
    transform: scale(0.95);
}

.centromex-chat-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
}

.centromex-chat-toggle .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat window */
.centromex-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 700px;
    max-height: calc(100vh - 120px);
    background: var(--centromex-chat-bg);
    border-radius: var(--centromex-chat-radius);
    box-shadow: var(--centromex-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Header */
.centromex-chat-header {
    background: var(--centromex-chat-primary);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.centromex-chat-header .header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.centromex-chat-header .header-icon svg {
    width: 24px;
    height: 24px;
}

.centromex-chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.centromex-chat-header .status {
    font-size: 12px;
    opacity: 0.9;
}

.centromex-chat-header .minimize-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.centromex-chat-header .minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.centromex-chat-header .minimize-btn svg {
    width: 20px;
    height: 20px;
}

/* Messages area */
.centromex-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.4;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

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

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

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

.chat-message.typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.chat-message.typing .dot {
    width: 8px;
    height: 8px;
    background: var(--centromex-chat-text-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.chat-message.typing .dot:nth-child(1) { animation-delay: -0.32s; }
.chat-message.typing .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Products section */
.centromex-chat-products {
    border-top: 1px solid var(--centromex-chat-border);
    background: #fafafa;
    max-height: 280px;
    overflow-y: auto;
}

.centromex-chat-products .products-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-bottom: 1px solid var(--centromex-chat-border);
    position: sticky;
    top: 0;
}

.centromex-chat-products .products-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--centromex-chat-text);
}

.centromex-chat-products .add-all-btn {
    background: var(--centromex-chat-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.centromex-chat-products .add-all-btn:hover {
    background: var(--centromex-chat-primary-dark);
}

.centromex-chat-products .products-list {
    padding: 8px;
}

/* Product item */
.product-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
}

.product-item:last-child {
    margin-bottom: 0;
}

.product-item .product-link {
    flex-shrink: 0;
}

.product-item .product-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    background: #f0f0f0;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.product-item .product-image:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

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

.product-item .product-name-link {
    text-decoration: none;
    display: block;
}

.product-item .product-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--centromex-chat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: color 0.2s;
}

.product-item .product-name:hover {
    color: var(--centromex-chat-primary);
}

.product-item .product-details {
    font-size: 12px;
    color: var(--centromex-chat-text-light);
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.product-item .product-qty {
    background: var(--centromex-chat-user-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--centromex-chat-primary-dark);
}

.product-item .add-btn {
    background: var(--centromex-chat-primary-light);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.product-item .add-btn:hover {
    background: var(--centromex-chat-primary);
    transform: scale(1.1);
}

.product-item .add-btn svg {
    width: 18px;
    height: 18px;
}

.product-item .add-btn.added {
    background: #4caf50;
}

.product-item .add-btn.added svg {
    animation: checkmark 0.3s ease;
}

@keyframes checkmark {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Input area */
.centromex-chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--centromex-chat-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: white;
}

.centromex-chat-input textarea {
    flex: 1;
    border: 1px solid var(--centromex-chat-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

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

.centromex-chat-input textarea::placeholder {
    color: #999;
}

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

.centromex-chat-input .send-btn:hover {
    background: var(--centromex-chat-primary-dark);
}

.centromex-chat-input .send-btn:active {
    transform: scale(0.95);
}

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

.centromex-chat-input .send-btn svg {
    width: 20px;
    height: 20px;
}

/* Quick suggestions */
.centromex-chat-suggestions {
    padding: 8px 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: white;
}

.centromex-chat-suggestions .suggestion-btn {
    background: var(--centromex-chat-user-bg);
    border: 1px solid var(--centromex-chat-primary-light);
    color: var(--centromex-chat-primary-dark);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.centromex-chat-suggestions .suggestion-btn:hover {
    background: var(--centromex-chat-primary);
    color: white;
    border-color: var(--centromex-chat-primary);
}

/* Cart notification */
.centromex-cart-notification {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: var(--centromex-chat-primary);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--centromex-chat-shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    z-index: 100000;
}

.centromex-cart-notification.hide {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

.centromex-cart-notification a {
    color: white;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
    .centromex-chat-widget {
        bottom: 10px;
        right: 10px;
    }

    .centromex-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
        border-radius: 12px;
    }

    .centromex-chat-toggle {
        width: 54px;
        height: 54px;
    }

    .centromex-chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .centromex-chat-suggestions {
        padding: 8px 12px 12px;
    }

    .centromex-chat-suggestions .suggestion-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Total summary */
.chat-total {
    background: var(--centromex-chat-user-bg);
    border: 1px solid var(--centromex-chat-primary-light);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-total .total-label {
    font-size: 14px;
    color: var(--centromex-chat-text);
}

.chat-total .total-amount {
    font-size: 18px;
    font-weight: bold;
    color: var(--centromex-chat-primary-dark);
}

/* View cart link in messages */
.chat-message .view-cart-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--centromex-chat-primary);
    text-decoration: underline;
    font-weight: 500;
}

.chat-message.user .view-cart-link {
    color: white;
}

/* Expanded mode */
.centromex-chat-window.expanded {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: calc(100vw - 40px);
    max-width: 800px;
    height: calc(100vh - 40px);
    max-height: none;
    border-radius: 12px;
    z-index: 100001;
}

.centromex-chat-window.expanded .centromex-chat-products {
    max-height: 300px;
}

/* Header actions */
.centromex-chat-header .header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.centromex-chat-header .header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.centromex-chat-header .header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.centromex-chat-header .header-actions button svg {
    width: 20px;
    height: 20px;
}

/* Message formatting */
.chat-message p {
    margin: 0 0 8px 0;
}

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

.chat-message .list-item {
    display: block;
    padding: 4px 0;
    padding-left: 8px;
}

.chat-message .list-item .list-number {
    font-weight: 600;
    margin-right: 4px;
}

.chat-message .bullet-item {
    display: block;
    padding: 4px 0;
    padding-left: 8px;
}

.chat-message .chat-header {
    display: block;
    font-size: 14px;
    margin: 8px 0 4px 0;
}

.chat-message .chat-header:first-child {
    margin-top: 0;
}

.chat-message strong {
    font-weight: 600;
}

.chat-message em {
    font-style: italic;
}

/* Products actions container */
.centromex-chat-products .products-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.centromex-chat-products .clear-products-btn {
    background: none;
    border: none;
    color: var(--centromex-chat-text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.centromex-chat-products .clear-products-btn:hover {
    color: var(--centromex-chat-text);
    background: rgba(0, 0, 0, 0.05);
}

.centromex-chat-products .clear-products-btn svg {
    width: 18px;
    height: 18px;
}
