/* ServeGuru Pre-Owned Sewing Machines In-Site Private Chat & Privacy Shield CSS */
/* Mobile-first, Stripe/Linear grade aesthetics, 48px touch targets, zero spam */

:root {
    --sg-chat-primary: #013768;
    --sg-chat-accent: #15803d;
    --sg-chat-green: #25D366;
    --sg-chat-bg: #f8fafc;
    --sg-chat-border: #e2e8f0;
    --sg-chat-text: #0f172a;
    --sg-chat-muted: #64748b;
    --sg-chat-shadow: 0 16px 48px rgba(1, 55, 104, 0.22);
}

/* Floating Launcher Pill when active chat exists */
.sg-chat-floating-pill {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99990;
    background: linear-gradient(135deg, #013768 0%, #0d9488 100%);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(1, 55, 104, 0.35);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}
.sg-chat-floating-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(1, 55, 104, 0.45);
}
.sg-chat-floating-pill .unread-badge {
    background: #ef4444;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Mobile ergonomics - Stacks cleanly above WhatsApp floating button with zero overlap */
@media (max-width: 768px) {
    .sg-chat-floating-pill {
        bottom: 144px !important;
        right: 16px !important;
        padding: 9px 15px;
        font-size: 0.85rem;
    }
}

/* Chat Drawer Backdrop (Mobile only) */
.sg-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sg-chat-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Chat Drawer Widget */
.sg-chat-drawer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 390px;
    height: 600px;
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--sg-chat-shadow);
    border: 1px solid var(--sg-chat-border);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    transform: translateY(120%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.sg-chat-drawer.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Mobile full bottom-sheet behavior */
@media (max-width: 640px) {
    .sg-chat-drawer {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 88vh;
        max-height: 88vh;
        border-radius: 24px 24px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25);
    }
}

/* Drawer Header */
.sg-chat-header {
    background: #013768;
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    position: relative;
}
.sg-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.sg-chat-header-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}
.sg-chat-header-titles {
    flex: 1;
    min-width: 0;
}
.sg-chat-header-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.sg-chat-header-meta {
    font-size: 0.76rem;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.sg-chat-header-meta .price {
    font-weight: 800;
    color: #86efac;
}
.sg-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.sg-chat-btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}
.sg-chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Privacy Shield Notice Strip */
.sg-chat-shield-strip {
    background: #f0fdf4;
    border-bottom: 1px solid #dcfce7;
    padding: 7px 14px;
    font-size: 0.74rem;
    color: #166534;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-weight: 600;
}
.sg-chat-shield-strip svg {
    flex-shrink: 0;
    color: #16a34a;
}

/* Shared Contact Card (Revealed when seller unlocks phone) */
.sg-chat-contact-unlocked-card {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    border: 1.5px solid #86efac;
    border-radius: 12px;
    padding: 10px 14px;
    margin: 10px 14px 4px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}
.sg-chat-contact-unlocked-card .text {
    font-size: 0.78rem;
    color: #14532d;
    font-weight: 700;
}
.sg-chat-contact-unlocked-card .actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sg-chat-contact-btn {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sg-chat-contact-btn.call {
    background: #ffffff;
    color: #15803d;
    border: 1px solid #86efac;
}
.sg-chat-contact-btn.wa {
    background: #25D366;
    color: #ffffff;
}

/* Quick Intent Chips */
.sg-chat-chips-scroll {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    background: #ffffff;
    border-bottom: 1px solid var(--sg-chat-border);
    flex-shrink: 0;
    scrollbar-width: none;
}
.sg-chat-chips-scroll::-webkit-scrollbar {
    display: none;
}
.sg-chat-chip {
    white-space: nowrap;
    background: #f1f5f9;
    color: #334155;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.15s ease;
}
.sg-chat-chip:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* Messages Body */
.sg-chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubbles */
.sg-chat-bubble-row {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.sg-chat-bubble-row.buyer {
    align-items: flex-end;
}
.sg-chat-bubble-row.seller {
    align-items: flex-start;
}
.sg-chat-bubble-row.system {
    align-items: center;
}

.sg-chat-bubble {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}
.sg-chat-bubble.buyer {
    background: #013768;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(1, 55, 104, 0.15);
}
.sg-chat-bubble.seller {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.sg-chat-bubble.system {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 0.76rem;
    text-align: center;
    border-radius: 10px;
    max-width: 92%;
    padding: 7px 12px;
}

.sg-chat-meta-time {
    font-size: 0.68rem;
    margin-top: 3px;
    display: block;
}
.sg-chat-bubble.buyer .sg-chat-meta-time {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}
.sg-chat-bubble.seller .sg-chat-meta-time {
    color: #94a3b8;
    text-align: left;
}

/* Certified Guarantee Upsell inside Chat */
.sg-chat-certified-bar {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px dashed #0d9488;
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}
.sg-chat-certified-bar .text {
    font-size: 0.72rem;
    color: #0f766e;
    font-weight: 700;
    line-height: 1.25;
}
.sg-chat-certified-bar .btn-book {
    background: #0d9488;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 5px 9px;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
}

/* Chat Input Footer */
.sg-chat-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--sg-chat-border);
    flex-shrink: 0;
}
.sg-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sg-chat-input-row input {
    flex: 1;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    min-height: 44px;
}
.sg-chat-input-row input:focus {
    border-color: #013768;
    box-shadow: 0 0 0 3px rgba(1, 55, 104, 0.1);
}
.sg-chat-btn-send {
    background: #013768;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.sg-chat-btn-send:hover {
    background: #024a8b;
}
.sg-chat-btn-send:active {
    transform: scale(0.95);
}

/* Initial Buyer Auth Form (Simple 2-Field verification before first message) */
.sg-chat-auth-box {
    background: #ffffff;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}
.sg-chat-auth-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 4px;
}
.sg-chat-auth-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin-bottom: 14px;
    line-height: 1.35;
}
.sg-chat-auth-field {
    margin-bottom: 10px;
}
.sg-chat-auth-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 4px;
}
.sg-chat-auth-field input {
    width: 100%;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.88rem;
    outline: none;
    box-sizing: border-box;
}
.sg-chat-auth-field input:focus {
    border-color: #013768;
}
.sg-chat-auth-btn {
    width: 100%;
    background: #013768;
    color: #ffffff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.15s;
}
.sg-chat-auth-btn:hover {
    background: #024a8b;
}
