/**
 * HaggleBot Stylesheet
 * Version: 1.0.0 (Chips UI Fix & Mobile Side Spacing)
 */

:root {
    --hb-primary: #4f46e5;
    --hb-primary-hover: #3730a3;
    --hb-bg-light: #f9fafb;
    --hb-text-dark: #111827;
    --hb-text-muted: #6b7280;
    --hb-border: #e5e7eb;
    --hb-text-color: #ffffff;
    --hb-border-color: #e5e7eb;
    --hb-border-radius: 16px;
    --hb-border-size: 0px;
    --hb-font-size: 14px;
    --hb-modal-width: 420px;
    
    --hb-btn-bg: #ffffff;
    --hb-btn-text-color: #4f46e5;
    --hb-btn-border-color: #4f46e5;
    --hb-btn-border-size: 2px;
    --hb-btn-border-radius: 8px;
    --hb-btn-padding: 12px 24px;
    --hb-btn-font-size: 16px;
}

/* Trigger Button Styles */
.haggle-trigger-btn {
    background-color: var(--hb-btn-bg) !important;
    color: var(--hb-btn-text-color) !important;
    border: var(--hb-btn-border-size) solid var(--hb-btn-border-color) !important;
    border-radius: var(--hb-btn-border-radius) !important;
    padding: var(--hb-btn-padding) !important;
    font-size: var(--hb-btn-font-size) !important;
    font-weight: 600; 
    cursor: pointer;
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); 
    font-family: 'Inter', sans-serif;
}

.haggle-trigger-btn:hover { 
    opacity: 0.9; 
    transform: translateY(-2px); 
}

/* Modal Overlay & Card */
.hb-modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(17, 24, 39, 0.6); 
    backdrop-filter: blur(4px);
    display: flex; 
    justify-content: center; 
    align-items: center;
    opacity: 0; 
    visibility: hidden; 
    transition: all 0.3s ease; 
    z-index: 999999;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}

.hb-modal-overlay.active { 
    opacity: 1; 
    visibility: visible; 
}

.hb-modal-card {
    background: #ffffff; 
    width: 100%; 
    max-width: var(--hb-modal-width) !important;
    border-radius: var(--hb-border-radius) !important;
    border: var(--hb-border-size) solid var(--hb-border-color) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
    overflow: hidden;
    transform: scale(0.9); 
    transition: all 0.3s ease; 
    display: flex; 
    flex-direction: column; 
    max-height: 90vh;
    font-size: var(--hb-font-size) !important;
    box-sizing: border-box;
}

.hb-modal-overlay.active .hb-modal-card { 
    transform: scale(1); 
}

/* Header */
.hb-header { 
    background-color: var(--hb-primary); 
    color: var(--hb-text-color) !important; 
    padding: 16px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.hb-bot-info { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.hb-avatar { 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    background-color: #ffffff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 20px; 
    border: 2px solid #ffffff; 
    overflow: hidden; 
    flex-shrink: 0;
}

.hb-avatar img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 50%; 
}

.hb-bot-details h3 { 
    font-size: 16px; 
    font-weight: 600; 
    margin: 0; 
    color: var(--hb-text-color) !important; 
}

.hb-bot-details span { 
    font-size: 12px; 
    opacity: 0.8; 
    color: var(--hb-text-color) !important; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
}

.hb-status-dot { 
    width: 8px; 
    height: 8px; 
    background-color: #10b981; 
    border-radius: 50%; 
    display: inline-block; 
}

.hb-close-btn { 
    background: none; 
    border: none; 
    color: var(--hb-text-color) !important; 
    font-size: 24px; 
    cursor: pointer; 
    opacity: 0.8; 
}


.hb-close-btn:hover { 
    background: none; 
    border: none; 
    color: var(--hb-text-color) !important; 
    font-size: 24px; 
    cursor: pointer; 
    opacity: 0.8; 
}

/* Bargain Meter */
.hb-meter-container { 
    background: #e5e7eb; 
    height: 6px; 
    width: 100%; 
    position: relative; 
    overflow: hidden; 
}

.hb-meter-bar { 
    height: 100%; 
    width: 0%; 
    background: #ef4444; 
    transition: width 0.3s ease, background 0.3s ease; 
}

/* Product Card */
.hb-product-card { 
    background-color: var(--hb-bg-light); 
    padding: 12px 16px; 
    border-bottom: 1px solid var(--hb-border); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.hb-product-img { 
    width: 48px; 
    height: 48px; 
    border-radius: 6px; 
    object-fit: cover; 
    background-color: #e5e7eb; 
    flex-shrink: 0;
}

.hb-product-info h4 { 
    font-size: 14px; 
    color: var(--hb-text-dark); 
    font-weight: 600; 
    margin: 0 0 2px 0; 
}

.hb-product-price { 
    font-size: 13px; 
    color: var(--hb-text-muted); 
}

.hb-product-price span { 
    color: var(--hb-primary); 
    font-weight: 700; 
}

/* Chat Body */
.hb-chat-body { 
    padding: 16px; 
    height: 280px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    background-color: #ffffff; 
    flex-grow: 1;
}

.hb-bubble { 
    max-width: 85%; 
    padding: 12px 16px; 
    font-size: var(--hb-font-size) !important; 
    line-height: 1.5; 
    border-radius: 16px; 
    box-sizing: border-box; 
    word-break: break-word;
}

.hb-bot-bubble { 
    background-color: #f3f4f6; 
    color: var(--hb-text-dark); 
    align-self: flex-start; 
    border-bottom-left-radius: 4px; 
}

.hb-user-bubble { 
    background-color: var(--hb-primary); 
    color: var(--hb-text-color) !important; 
    align-self: flex-end; 
    border-bottom-right-radius: 4px; 
}

/* 🔧 FIXED: QUICK OFFER CHIPS CSS OVERLAP BUG */
.hb-chips-container { 
    display: flex !important; 
    align-items: center !important;
    gap: 8px !important; 
    padding: 10px 16px !important; 
    background-color: var(--hb-bg-light) !important; 
    overflow-x: auto !important; 
    white-space: nowrap !important;
    border-top: 1px solid var(--hb-border) !important; 
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hb-chips-container::-webkit-scrollbar {
    display: none;
}

.hb-chip-btn { 
    background: #ffffff !important; 
    border: 1.5px solid var(--hb-primary) !important; 
    color: var(--hb-primary) !important; 
    padding: 6px 14px !important; 
    font-size: 12px !important; 
    font-weight: 600 !important; 
    line-height: 1.2 !important;
    border-radius: 20px !important; 
    cursor: pointer !important; 
    white-space: nowrap !important; 
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important; 
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    height: auto !important;
}

.hb-chip-btn:hover { 
    background: var(--hb-primary) !important; 
    color: #ffffff !important; 
}

/* Footer & Inputs */
.hb-footer { 
    padding: 12px 16px 16px 16px; 
    background-color: var(--hb-bg-light); 
    display: flex; 
    gap: 10px; 
}

.hb-input-group { 
    position: relative; 
    flex: 1; 
}

.hb-currency { 
    position: absolute; 
    left: 14px; 
    top: 50%; 
    transform: translateY(-50%); 
    font-weight: 600; 
    color: var(--hb-text-muted); 
    z-index: 2; 
    pointer-events: none; 
}

.hb-input { 
    width: 100%; 
    padding: 12px 12px 12px 38px !important; 
    border: 1px solid var(--hb-border); 
    border-radius: 8px; 
    font-size: var(--hb-font-size) !important; 
    outline: none; 
    box-sizing: border-box; 
}

.hb-send-btn { 
    background-color: var(--hb-primary); 
    color: var(--hb-text-color) !important; 
    border: none; 
    padding: 0 20px; 
    border-radius: 8px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: background 0.2s; 
    flex-shrink: 0;
}

/* Action Cards & Coupon */
.hb-card-box { 
    background: #ffffff; 
    border: 2px dashed var(--hb-primary); 
    border-radius: 8px; 
    padding: 14px; 
    text-align: center; 
    margin-top: 6px; 
    width: 100%; 
    box-sizing: border-box; 
}

.hb-coupon-code { 
    background-color: var(--hb-bg-light); 
    padding: 8px 12px; 
    font-size: 18px; 
    font-weight: 700; 
    color: var(--hb-primary); 
    letter-spacing: 2px; 
    border-radius: 4px; 
    margin: 8px 0; 
    display: inline-block; 
}

.hb-btn-action { 
    background-color: var(--hb-primary); 
    color: var(--hb-text-color) !important; 
    border: none; 
    padding: 10px 14px; 
    font-size: 13px; 
    font-weight: 600; 
    border-radius: 6px; 
    cursor: pointer; 
    width: 100%; 
    margin-top: 6px; 
    text-decoration: none; 
    display: inline-block; 
    box-sizing: border-box; 
}

.hb-btn-checkout { 
    background-color: #10b981 !important; 
    color: #ffffff !important; 
}

.hb-timer-badge { 
    display: inline-flex; 
    align-items: center; 
    gap: 4px; 
    background-color: #fee2e2; 
    color: #dc2626; 
    font-size: 12px; 
    font-weight: 600; 
    padding: 4px 8px; 
    border-radius: 12px; 
    margin-top: 8px; 
}

/* 📱 FIXED: MOBILE RESPONSIVE UX WITH SIDE SPACING */
@media (max-width: 640px) {
    .hb-modal-overlay {
        align-items: flex-end; 
        padding: 12px; /* Side and bottom margins */
    }
    
    .hb-modal-card {
        max-width: 100% !important;
        width: calc(100% - 24px) !important; /* Spacing on left & right */
        margin: 0 auto 10px auto !important;
        height: auto !important;
        max-height: 85dvh !important;
        border-radius: var(--hb-border-radius) !important; /* Retains rounded corners on mobile */
        border: var(--hb-border-size) solid var(--hb-border-color) !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3) !important;
    }

    .hb-chat-body {
        height: 250px !important;
        max-height: 50vh !important;
        padding: 14px;
    }

    .hb-footer {
        padding: 12px 14px 14px 14px;
    }
}