/* ==========================================================================
   AI Shopping Assistant (HexaAi) Stylesheet
   ========================================================================== */

:root {
    --hexa-primary: #0177cd;
    --hexa-primary-hover: #0162a8;
    --hexa-primary-gradient: linear-gradient(135deg, #0177cd 0%, #17a2b8 100%);
    --hexa-user-bubble: #0177cd;
    --hexa-ai-bubble: #f1f5f9;
    --hexa-bg: #ffffff;
    --hexa-text-main: #1e293b;
    --hexa-text-muted: #64748b;
    --hexa-border: #e2e8f0;
    --hexa-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
    --hexa-radius: 16px;
    --hexa-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Floating Launcher Button */
.hexa-ai-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--hexa-primary-gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(1, 119, 205, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: var(--hexa-transition);
    outline: none !important;
}

.hexa-ai-launcher:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 30px rgba(1, 119, 205, 0.55);
}

.hexa-ai-launcher svg {
    transition: transform 0.3s ease;
}

.hexa-ai-launcher:hover svg {
    transform: rotate(15deg);
}

/* Panel Container */
.hexa-ai-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background: var(--hexa-bg);
    border-radius: var(--hexa-radius);
    box-shadow: var(--hexa-shadow);
    border: 1px solid var(--hexa-border);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--hexa-transition);
}

.hexa-ai-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.hexa-ai-header {
    background: var(--hexa-primary-gradient);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
}

.hexa-ai-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hexa-ai-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hexa-ai-brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.hexa-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hexa-ai-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    outline: none !important;
}

.hexa-ai-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Body & States */
.hexa-ai-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
}

.hexa-ai-state {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hexa-ai-state[hidden] {
    display: none !important;
}

/* Conversation View */
.hexa-ai-messages {
    flex: 1;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.hexa-ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: hexaFadeIn 0.3s ease;
}

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

.hexa-ai-msg-user {
    align-self: flex-end;
}

.hexa-ai-msg-assistant {
    align-self: flex-start;
}

.hexa-ai-msg-bubble {
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.55;
    border-radius: 16px;
    word-break: break-word;
}

.hexa-ai-msg-user .hexa-ai-msg-bubble {
    background: var(--hexa-user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.hexa-ai-msg-assistant .hexa-ai-msg-bubble {
    background: var(--hexa-ai-bubble);
    color: var(--hexa-text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--hexa-border);
}

.hexa-ai-msg-time {
    font-size: 10px;
    color: var(--hexa-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.hexa-ai-msg-user .hexa-ai-msg-time {
    text-align: right;
}

/* Quick Prompts Chips */
.hexa-ai-suggested-wrap {
    margin-top: 10px;
}

.hexa-ai-suggested-heading {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--hexa-text-muted);
    margin-bottom: 6px;
}

.hexa-ai-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hexa-ai-prompt-chip {
    background: #ffffff;
    border: 1px solid var(--hexa-primary);
    color: var(--hexa-primary);
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.hexa-ai-prompt-chip:hover {
    background: var(--hexa-primary);
    color: #ffffff;
}

/* Product Cards in Chat */
.hexa-ai-product-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.hexa-ai-product-card {
    background: #ffffff;
    border: 1px solid var(--hexa-border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.hexa-ai-product-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: #f8fafc;
    flex-shrink: 0;
}

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

.hexa-ai-product-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hexa-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    text-decoration: none;
}

.hexa-ai-product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--hexa-primary);
    margin: 3px 0 6px;
}

.hexa-ai-product-actions {
    display: flex;
    gap: 6px;
}

.hexa-ai-btn-add-cart {
    background: var(--hexa-primary);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.hexa-ai-btn-add-cart:hover {
    opacity: 0.9;
}

/* Typing Indicator */
.hexa-ai-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--hexa-ai-bubble);
    border-radius: 16px;
    align-self: flex-start;
    margin: 0 16px 12px;
    border: 1px solid var(--hexa-border);
}

.hexa-ai-typing-dots {
    display: flex;
    gap: 4px;
}

.hexa-ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--hexa-text-muted);
    border-radius: 50%;
    animation: hexaBounce 1.4s infinite ease-in-out both;
}

.hexa-ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.hexa-ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* History View */
.hexa-ai-history-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hexa-ai-history-item {
    background: #ffffff;
    border: 1px solid var(--hexa-border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
}

.hexa-ai-history-item:hover {
    border-color: var(--hexa-primary);
    background: #f0f7ff;
}

.hexa-ai-history-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hexa-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hexa-ai-history-time {
    font-size: 11px;
    color: var(--hexa-text-muted);
}

.hexa-ai-history-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--hexa-border);
    background: #ffffff;
}

.hexa-ai-new-chat-btn {
    width: 100%;
    background: var(--hexa-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

/* Footer / Input Bar */
.hexa-ai-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid var(--hexa-border);
}

.hexa-ai-input-wrap {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--hexa-border);
    border-radius: 24px;
    padding: 6px 12px 6px 16px;
    gap: 8px;
    transition: border-color 0.2s;
}

.hexa-ai-input-wrap:focus-within {
    border-color: var(--hexa-primary);
    background: #ffffff;
}

.hexa-ai-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    color: var(--hexa-text-main);
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.hexa-ai-input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hexa-ai-img-btn {
    color: var(--hexa-text-muted);
    background: transparent;
}

.hexa-ai-img-btn:hover {
    color: var(--hexa-primary);
    background: rgba(1, 119, 205, 0.08);
}

.hexa-ai-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--hexa-primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.hexa-ai-send-btn:hover {
    opacity: 0.9;
}

/* Image preview badge in input */
.hexa-ai-img-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 8px;
    width: fit-content;
}

.hexa-ai-img-preview img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
}

.hexa-ai-img-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 14px;
}

/* Overlay for Mobile */
@media (max-width: 576px) {
    .hexa-ai-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}
