/**
 * Toquemonos Pure - Web Assistant Chat Styles
 * Premium UI/UX style sheet featuring Glassmorphism, animations and responsive support.
 */

/* 1. Chat Widget Container */
.tqm-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999; /* Overlays everything */
    font-family: 'Figtree', 'Inter', sans-serif;
}

/* 2. Chat Bubble (Activation Button) */
.tqm-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #ca767e; /* Sweet Rose Accent */
    border: none;
    box-shadow: 0 8px 25px rgba(202, 118, 126, 0.4);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    padding: 0;
}

.tqm-chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    background-color: #b35e66;
    box-shadow: 0 10px 30px rgba(202, 118, 126, 0.6);
}

.tqm-chat-bubble:active {
    transform: scale(0.95);
}

.tqm-chat-bubble-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Turns dark lineart to white */
    transition: transform 0.3s ease;
}

/* Notification badge */
.tqm-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ff4d4d;
    color: white;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
}

/* 3. Chat Window (Popup) */
.tqm-chat-window {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 370px;
    height: 520px;
    background-color: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: tqmSlideUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    z-index: 999998;
}

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

/* Chat Header */
.tqm-chat-header {
    background-color: #ca767e;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.tqm-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 4px;
    filter: brightness(0) invert(1);
    object-fit: contain;
}

.tqm-chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tqm-chat-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tqm-chat-status::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #2ecc71; /* Green status dot */
    box-shadow: 0 0 8px #2ecc71;
}

.tqm-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    padding: 0;
    line-height: 1;
}

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

/* Chat Message Logs Area */
.tqm-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrollbar on chat window */
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom Scrollbars */
.tqm-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.tqm-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.tqm-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Message Bubbles Base */
.tqm-msg {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    animation: tqmMsgFade 0.25s ease forwards;
}

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

/* User Messages */
.tqm-msg-user {
    align-self: flex-end;
    background-color: #f7d5d9; /* Sweet Rose Light */
    color: #111111;
    border-radius: 18px 18px 0px 18px;
    box-shadow: 0 2px 8px rgba(202, 118, 126, 0.1);
}

/* Bot Messages */
.tqm-msg-bot {
    align-self: flex-start;
    background-color: #ffffff;
    color: #111111;
    border-radius: 18px 18px 18px 0px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.tqm-msg-bot p {
    margin-bottom: 8px;
}
.tqm-msg-bot p:last-child {
    margin-bottom: 0;
}

.tqm-msg-bot ul, .tqm-msg-bot ol {
    margin-left: 15px;
    margin-top: 5px;
    margin-bottom: 5px;
}

.tqm-msg-bot li {
    list-style-type: disc;
    margin-bottom: 4px;
}

/* System Messages / Warnings */
.tqm-msg-system {
    align-self: center;
    background-color: rgba(0, 0, 0, 0.05);
    color: #555555;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 12px;
    max-width: 90%;
    text-align: center;
}

/* Typing Indicator Animation */
.tqm-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 6px;
}

.tqm-typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #999999;
    border-radius: 50%;
    display: inline-block;
    animation: tqmBounce 1.4s infinite ease-in-out both;
}

.tqm-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.tqm-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* 4. Chat Input Form */
.tqm-chat-input-form {
    padding: 15px 20px;
    background-color: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 10px;
    align-items: center;
}

.tqm-chat-input-form input {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
    background-color: #fcfcfc;
}

.tqm-chat-input-form input:focus {
    border-color: #ca767e;
    background-color: #ffffff;
}

.tqm-chat-input-form button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ca767e;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.tqm-chat-input-form button:hover {
    background-color: #b35e66;
}

/* 6. Dynamic Chat Cards (Products, Orders, Handoff & Pills) */

/* --- Quick Reply Pills --- */
.tqm-chat-pills {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    background-color: rgba(255, 255, 255, 0.95);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.tqm-chat-pills::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.tqm-pill {
    flex: 0 0 auto;
    padding: 7px 14px;
    background-color: rgba(202, 118, 126, 0.08);
    color: #b35e66;
    border: 1px solid rgba(202, 118, 126, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.tqm-pill:hover {
    background-color: #ca767e;
    color: #ffffff;
    border-color: #ca767e;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(202, 118, 126, 0.2);
}

.tqm-pill:active {
    transform: translateY(0);
}

.tqm-chat-pills.tqm-disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* --- Carousel Wrapper and Navigation Arrows --- */
.tqm-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    align-self: stretch;
    margin: 0;
    flex-shrink: 0;
}

.tqm-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(202, 118, 126, 0.25);
    color: #ca767e;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 999;
    transition: all 0.25s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    line-height: 1;
    opacity: 0; /* Updated dynamically by JS */
    pointer-events: none;
}

.tqm-carousel-arrow:hover {
    background-color: #ca767e;
    color: #ffffff;
    border-color: #ca767e;
    box-shadow: 0 4px 12px rgba(202, 118, 126, 0.3);
}

.tqm-carousel-arrow:active {
    transform: translateY(-50%) scale(0.92);
}

.tqm-carousel-prev {
    left: 2px;
}

.tqm-carousel-next {
    right: 2px;
}

/* --- Products Carousel --- */
.tqm-products-carousel {
    display: flex;
    gap: 12px;
    padding: 4px 32px 12px 32px; /* Extra side padding so cards scroll clear of the arrows */
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    align-self: stretch;
    margin: 0;
    flex-shrink: 0;
}

.tqm-products-carousel::-webkit-scrollbar {
    display: none;
}

.tqm-product-card {
    flex: 0 0 150px;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
    animation: tqmMsgFade 0.3s ease forwards;
}

.tqm-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
    border-color: rgba(202, 118, 126, 0.25);
}

.tqm-product-link {
    text-decoration: none !important;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.tqm-product-img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.tqm-product-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.tqm-product-title {
    margin: 0;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.35;
    color: #2c2c2c;
    height: 32px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tqm-product-price {
    font-size: 12px;
    font-weight: 700;
    color: #ca767e;
}

.tqm-product-add-btn {
    margin: 0 10px 10px 10px;
    padding: 7px 10px;
    background-color: #ca767e;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.tqm-product-add-btn:hover {
    background-color: #b35e66;
}

.tqm-product-add-btn.loading {
    background-color: #cccccc !important;
    color: #666666 !important;
    pointer-events: none;
}

/* --- Order Card --- */
.tqm-order-card {
    align-self: flex-start;
    width: 85%;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: tqmMsgFade 0.3s ease forwards;
}

.tqm-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tqm-order-number {
    font-size: 13.5px;
    font-weight: 700;
    color: #111111;
}

.tqm-order-date {
    font-size: 11px;
    color: #777777;
}

.tqm-order-status-badge {
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.tqm-order-status-badge.status-completed {
    background-color: #e2fbe8;
    color: #27ae60;
}

.tqm-order-status-badge.status-processing {
    background-color: #fff4e5;
    color: #d35400;
}

.tqm-order-status-badge.status-failed {
    background-color: #fcebeb;
    color: #c0392b;
}

.tqm-order-status-badge.status-pending {
    background-color: #f1f2f6;
    color: #57606f;
}

.tqm-order-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
    padding-top: 10px;
}

.tqm-order-items-title {
    font-size: 10.5px;
    font-weight: 700;
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tqm-order-items-list {
    margin: 0 0 4px 14px;
    padding: 0;
}

.tqm-order-items-list li {
    font-size: 12.5px;
    color: #2c2c2c;
    list-style-type: circle;
    margin-bottom: 2px;
}

.tqm-order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 8px;
    margin-top: 4px;
}

.tqm-order-total-label {
    font-size: 12px;
    font-weight: 600;
    color: #555555;
}

.tqm-order-total-val {
    font-size: 14px;
    font-weight: 700;
    color: #ca767e;
}

/* --- Human Handoff Card --- */
.tqm-handoff-card {
    align-self: flex-start;
    width: 85%;
    background: linear-gradient(135deg, #fdf5f6 0%, #faeef0 100%);
    border: 1px solid rgba(202, 118, 126, 0.18);
    border-radius: 18px 18px 18px 0;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(202, 118, 126, 0.06);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: tqmMsgFade 0.3s ease forwards;
}

.tqm-handoff-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #25d366; /* WhatsApp Green */
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.35);
}

.tqm-handoff-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tqm-handoff-content h5 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: #111111;
}

.tqm-handoff-content p {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #555555;
}

.tqm-handoff-btn {
    align-self: flex-start;
    margin-top: 4px;
    padding: 8px 16px;
    background-color: #25d366;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
    transition: all 0.2s ease;
}

.tqm-handoff-btn:hover {
    background-color: #128c7e;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(18, 140, 126, 0.35);
}

/* --- Orders Selection Carousel --- */
.tqm-orders-selection-carousel {
    display: flex;
    gap: 12px;
    padding: 4px 32px 12px 32px; /* Extra side padding so cards scroll clear of the arrows */
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    align-self: stretch;
    margin: 0;
    flex-shrink: 0;
}

.tqm-orders-selection-carousel::-webkit-scrollbar {
    display: none;
}

.tqm-order-mini-card {
    flex: 0 0 180px;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
    animation: tqmMsgFade 0.3s ease forwards;
}

.tqm-order-mini-items {
    font-size: 11px;
    color: #666666;
    margin: 2px 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 30px;
    font-weight: 500;
}

.tqm-order-mini-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
    border-color: rgba(202, 118, 126, 0.25);
}

.tqm-order-mini-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.tqm-order-mini-num {
    font-weight: 700;
    color: #111111;
}

.tqm-order-mini-date {
    color: #777777;
}

.tqm-order-mini-total {
    font-size: 13px;
    font-weight: 700;
    color: #ca767e;
}

.tqm-order-mini-status {
    font-size: 10px;
    font-weight: 600;
    color: #555555;
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 10px;
    align-self: flex-start;
}

.tqm-order-query-btn {
    margin-top: 4px;
    padding: 6px 10px;
    background-color: #ca767e;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.tqm-order-query-btn:hover {
    background-color: #b35e66;
}

/* 5. Responsive Styles (Mobile Optimization) */
@media (max-width: 480px) {
    .tqm-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .tqm-order-card, .tqm-handoff-card {
        width: 90%;
    }
    
    .tqm-chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        animation: tqmMobileSlideUp 0.3s ease forwards;
    }
    
    @keyframes tqmMobileSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .tqm-chat-bubble {
        width: 55px;
        height: 55px;
        box-shadow: 0 6px 20px rgba(202, 118, 126, 0.4);
    }
    
    .tqm-chat-header {
        padding: 12px 16px;
    }
}
