* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
}

/* ===== Side Tab Trigger Button ===== */
.chat-trigger {
    position: fixed;
    top: 40%;
    right: 0;
    transform: translateY(-50%);
    width: auto;
    height: auto;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(180deg, #f26522 0%, #d44a0a 100%);
    border: none;
    cursor: pointer;
    box-shadow: -4px 0 24px rgba(242, 101, 34, 0.35), 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px;
    gap: 8px;
}

.chat-trigger:hover {
    transform: translateY(-50%) scaleX(1.08) scaleY(1.05);
    transform-origin: right center;
    box-shadow: -6px 0 32px rgba(242, 101, 34, 0.5), 0 0 16px rgba(242, 101, 34, 0.2);
}

.chat-trigger:active {
    transform: translateY(-50%) scaleX(1.03) scaleY(1.02);
    transform-origin: right center;
}

.trigger-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: bicubic;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.trigger-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: white;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.trigger-icon {
    display: none;
}

.trigger-pulse {
    display: none;
}

.chat-trigger.hidden {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Heartbeat pulse — stays in place, just a quick double-bump like a real heartbeat */
@keyframes tabHeartbeat {
    0%   { transform: translateY(-50%) scale(1); }
    14%  { transform: translateY(-50%) scale(1.12); }
    28%  { transform: translateY(-50%) scale(1); }
    42%  { transform: translateY(-50%) scale(1.07); }
    56%  { transform: translateY(-50%) scale(1); }
    100% { transform: translateY(-50%) scale(1); }
}

.chat-trigger.heartbeat {
    animation: tabHeartbeat 0.8s ease-in-out;
}

/* ===== Chat Widget ===== */
.chat-widget {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 620px;
    height: 750px;
    max-height: calc(100vh - 56px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    transform: translateX(30px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
    overflow: hidden;
}

.chat-widget.open {
    transform: translateX(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ===== Widget Header ===== */
.widget-header {
    background: linear-gradient(145deg, #f26522 0%, #c94d0a 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
    -webkit-image-rendering: auto;
}

.header-text h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.header-text p {
    font-size: 18px;
    font-weight: 500;
    opacity: 0.9;
}

.close-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* ===== Messages Area ===== */
.widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.message {
    display: flex;
    gap: 12px;
    max-width: 92%;
}

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(242, 101, 34, 0.3);
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
    -webkit-image-rendering: auto;
}

.message.user .message-avatar {
    background: linear-gradient(145deg, #1e3a5f 0%, #0f2440 100%);
    border: 2px solid #2d5a8e;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

.message.user .message-avatar svg {
    width: 60%;
    height: 60%;
}

.message-content {
    background: white;
    padding: 16px 20px;
    border-radius: 18px;
    border-top-left-radius: 6px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.message.user .message-content {
    background: linear-gradient(145deg, #f26522 0%, #e05a15 100%);
    color: white;
    border-radius: 18px;
    border-top-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(242, 101, 34, 0.25);
}

.message-content p {
    font-size: 24px;
    line-height: 1.5;
    font-weight: 450;
    margin-bottom: 12px;
    color: #1e293b;
}

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

.message.user .message-content p {
    color: white;
}

.message-content strong {
    color: #e05a15;
    font-weight: 600;
}

.message.user .message-content strong {
    color: white;
}

/* ===== Loading Animation ===== */
.message-content.loading {
    display: flex;
    gap: 6px;
    padding: 20px 24px;
    background: white;
}

.loading-dot {
    width: 10px;
    height: 10px;
    background: linear-gradient(145deg, #f26522, #e05a15);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Inline typing indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #f26522;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ===== Product Cards ===== */

/* Products intro line */
.products-intro {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    opacity: 0;
    animation: fadeIn 0.3s ease-out 0.05s forwards;
}

.products-intro-icon {
    font-size: 16px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.products-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

/* Staggered fade-in animation for product cards */
@keyframes productReveal {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s ease;
    
    /* Smooth reveal animation */
    opacity: 0;
    animation: productReveal 0.4s ease-out forwards;
}

/* Staggered delays for each card */
.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }
.product-card:nth-child(6) { animation-delay: 0.6s; }

.product-card:hover {
    border-color: #f26522;
    box-shadow: 0 4px 16px rgba(242, 101, 34, 0.15);
    transform: translateY(-2px);
}

.product-card h4 {
    font-size: 22px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.product-vendor {
    font-size: 18px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-price {
    font-size: 28px;
    font-weight: 700;
    color: #059669;
}

.product-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
    color: #e05a15;
    text-decoration: none;
    padding: 14px 22px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.product-link:hover {
    background: rgba(37, 99, 235, 0.15);
    transform: translateX(2px);
}

/* ===== Input Area ===== */
.widget-input {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.input-form {
    display: flex;
    gap: 12px;
}

.input-form input {
    flex: 1;
    padding: 18px 24px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    font-size: 22px;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.input-form input:focus {
    border-color: #f26522;
    background: white;
    box-shadow: 0 0 0 4px rgba(242, 101, 34, 0.1);
}

.input-form input::placeholder {
    color: #94a3b8;
    font-weight: 450;
}

.input-form button {
    width: 52px;
    height: 52px;
    background: linear-gradient(145deg, #f26522 0%, #d44a0a 100%);
    border: none;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(242, 101, 34, 0.3);
}

.input-form button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(242, 101, 34, 0.4);
}

.input-form button:active {
    transform: scale(0.95);
}

.input-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-form button svg {
    width: 22px;
    height: 22px;
}

.powered-by {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 14px;
}

.powered-by a {
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
}

.powered-by a:hover {
    color: #f26522;
}

/* ===== Responsive ===== */
@media (max-width: 520px) {
    .chat-widget {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .chat-trigger {
        top: auto;
        bottom: 20px;
        right: 0;
        transform: none;
        padding: 10px 8px;
    }
    
    .chat-trigger:hover {
        transform: translateX(-2px);
    }
    
    .trigger-avatar {
        width: 30px;
        height: 30px;
    }
    
    .trigger-label {
        font-size: 10px;
        letter-spacing: 1px;
    }
    
    .widget-header {
        padding: 12px 16px;
        border-radius: 0;
    }
    
    .avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 10px;
    }
    
    .header-text h1 {
        font-size: 18px;
        margin-bottom: 2px;
    }
    
    .header-text p {
        font-size: 13px;
    }
    
    .close-btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    
    .widget-messages {
        padding: 12px;
        gap: 14px;
    }
    
    .message {
        gap: 8px;
        max-width: 95%;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
        border-radius: 10px;
        flex-shrink: 0;
    }
    
    .message-content {
        padding: 10px 14px;
        border-radius: 14px;
        border-top-left-radius: 4px;
    }
    
    .message.user .message-content {
        border-radius: 14px;
        border-top-right-radius: 4px;
    }
    
    .message-content p {
        font-size: 15px;
        line-height: 1.45;
        margin-bottom: 8px;
    }
    
    /* Product cards - compact mobile */
    .products-grid {
        gap: 8px;
        margin-top: 12px;
    }
    
    .product-card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .product-card h4 {
        font-size: 14px;
        margin-bottom: 6px;
        -webkit-line-clamp: 2;
    }
    
    .product-meta {
        margin-bottom: 10px;
    }
    
    .product-vendor {
        font-size: 11px;
    }
    
    .product-price {
        font-size: 18px;
    }
    
    .product-link {
        font-size: 13px;
        padding: 10px 14px;
        border-radius: 8px;
    }
    
    /* Input area - compact */
    .widget-input {
        padding: 12px 16px;
    }
    
    .input-form {
        gap: 10px;
    }
    
    .input-form input {
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 12px;
    }
    
    .input-form button {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }
    
    .input-form button svg {
        width: 18px;
        height: 18px;
    }
    
    .powered-by {
        font-size: 11px;
        margin-top: 8px;
    }
    
    /* Loading dots - smaller */
    .loading-dot {
        width: 7px;
        height: 7px;
    }
    
    .typing-indicator span {
        width: 5px;
        height: 5px;
    }
}

/* ===== Scrollbar ===== */
.widget-messages::-webkit-scrollbar {
    width: 6px;
}

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

.widget-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.widget-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== Developer Panel ===== */
.dev-panel {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 9998;
}

.dev-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1f2937;
    border: 2px solid #374151;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dev-toggle:hover {
    background: #374151;
    transform: scale(1.05);
}

.dev-content {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 12px;
    padding: 16px;
    min-width: 280px;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dev-panel.open .dev-content {
    display: block;
}

.dev-content h3 {
    color: #f3f4f6;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #374151;
}

.dev-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.dev-row label {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 500;
}

.dev-row select {
    background: #111827;
    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #f3f4f6;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.dev-row select:hover {
    border-color: #6b7280;
}

.dev-row select:focus {
    outline: none;
    border-color: #f26522;
}

.dev-status {
    color: #6b7280;
    font-size: 11px;
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid #374151;
}

.dev-status.active {
    color: #10b981;
}

/* Hide dev panel on mobile */
@media (max-width: 480px) {
    .dev-panel {
        display: none;
    }
}
