/**
 * Chat Button - Jivo style bar
 * Fixed at bottom right, horizontal bar (desktop)
 * Floating circle button (mobile)
 */

.sh-chat-btn {
    position: fixed;
    bottom: 0;
    right: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    min-width: 280px;
    border: none;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    box-shadow:
        0 -4px 20px rgba(0, 0, 0, 0.15),
        0 -1px 3px rgba(0, 0, 0, 0.08);
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
    opacity: 0;
    animation: sh-chat-btn-appear 0.5s ease 0.3s forwards;
}

.sh-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 -8px 32px rgba(0, 0, 0, 0.2),
        0 -2px 6px rgba(0, 0, 0, 0.1);
}

.sh-chat-btn:active {
    transform: translateY(0);
}

.sh-chat-btn__text {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    letter-spacing: -0.01em;
}

.sh-chat-btn__brand {
    display: flex;
    align-items: center;
}

.sh-chat-btn__logo {
    width: 60px;
    height: 18px;
}

/* Mobile floating icon - hidden on desktop */
.sh-chat-btn__icon {
    display: none;
    width: 24px;
    height: 24px;
    color: #fff;
    flex-shrink: 0;
}

/* Appear animation */
@keyframes sh-chat-btn-appear {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sh-chat-btn {
        animation: none;
        opacity: 1;
    }
    .sh-chat-btn:hover {
        transform: none;
    }
}

/* ==========================================================================
   MOBILE: Floating Circle Button
   ========================================================================== */
@media (max-width: 599px) {
    .sh-chat-btn {
        /* Reset bar styles */
        bottom: 20px;
        right: 16px;
        left: auto;
        min-width: auto;
        padding: 0;
        gap: 0;
        
        /* Circle button */
        width: 56px;
        height: 56px;
        border-radius: 50%;
        justify-content: center;
        
        /* Dark slate color like chat header */
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        box-shadow:
            0 4px 16px rgba(30, 41, 59, 0.4),
            0 2px 6px rgba(0, 0, 0, 0.15);
        
        /* Animation */
        animation: sh-chat-btn-appear 0.5s ease 0.3s forwards;
    }
    
    .sh-chat-btn:hover {
        transform: scale(1.05);
        box-shadow:
            0 6px 24px rgba(30, 41, 59, 0.5),
            0 3px 8px rgba(0, 0, 0, 0.2);
    }
    
    .sh-chat-btn:active {
        transform: scale(0.95);
    }
    
    /* Hide text and brand on mobile */
    .sh-chat-btn__text,
    .sh-chat-btn__brand {
        display: none;
    }
    
    /* Show chat icon on mobile */
    .sh-chat-btn__icon {
        display: block;
    }
    
    /* Soft pulse animation with green accent */
    .sh-chat-btn::after {
        content: '';
        position: absolute;
        inset: -4px;
        border-radius: 50%;
        border: 2px solid rgba(16, 185, 129, 0.4);
        animation: sh-chat-pulse 3s ease-in-out infinite;
        pointer-events: none;
    }
}

/* Pulse animation for mobile button */
@keyframes sh-chat-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.08);
        opacity: 0;
    }
}

/* Safe area for devices with home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 599px) {
        .sh-chat-btn {
            bottom: calc(20px + env(safe-area-inset-bottom));
        }
    }
}

/* Account pages: raise chat button above bottom nav */
@media (max-width: 599px) {
    .is-account-page .sh-chat-btn {
        bottom: 60px;
    }
}

/* ========================================
   UNREAD BADGE
   ======================================== */

.sh-chat-btn__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
    animation: sh-badge-pulse 2s ease-in-out infinite;
}

@keyframes sh-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@media (max-width: 599px) {
    .sh-chat-btn__badge {
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        font-size: 10px;
        line-height: 18px;
        padding: 0 5px;
    }
}

/* ========================================
   TOAST NOTIFICATION
   ======================================== */

.sh-chat-toast {
    position: fixed;
    bottom: 80px;
    right: 24px;
    z-index: 1001;
    max-width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.15),
        0 1px 4px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: 
        opacity 0.3s ease,
        visibility 0.3s ease,
        transform 0.3s ease;
    cursor: pointer;
}

.sh-chat-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.sh-chat-toast__content {
    padding: 12px 16px;
}

.sh-chat-toast__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.sh-chat-toast__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sh-chat-toast__name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.sh-chat-toast__close {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 20px;
    line-height: 24px;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.sh-chat-toast__close:hover {
    color: #64748b;
}

.sh-chat-toast__message {
    font-size: 14px;
    color: #475569;
    line-height: 1.4;
    padding-left: 42px;
}

@media (max-width: 599px) {
    .sh-chat-toast {
        bottom: 90px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
    
    .sh-chat-toast__content {
        padding: 10px 14px;
    }
    
    .sh-chat-toast__avatar {
        width: 28px;
        height: 28px;
    }
    
    .sh-chat-toast__message {
        padding-left: 38px;
        font-size: 13px;
    }
    
    /* Account pages: raise toast above bottom nav */
    .is-account-page .sh-chat-toast {
        bottom: 130px;
    }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 599px) {
        .is-account-page .sh-chat-btn {
            bottom: calc(60px + env(safe-area-inset-bottom));
        }
        
        .is-account-page .sh-chat-toast {
            bottom: calc(130px + env(safe-area-inset-bottom));
        }
    }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    .sh-chat-btn::after {
        animation: none;
        opacity: 0;
    }
}

/* ========================================
   PROACTIVE TEASER MESSAGE
   ======================================== */

.sh-chat-teaser {
    position: fixed;
    bottom: 70px;
    right: 24px;
    z-index: 999;
    max-width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.96);
    transition: 
        opacity 0.3s ease,
        visibility 0.3s ease,
        transform 0.3s ease;
    cursor: pointer;
}

.sh-chat-teaser.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.sh-chat-teaser.is-hiding {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
}

.sh-chat-teaser__close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 50%;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.sh-chat-teaser__close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #64748b;
}

.sh-chat-teaser__content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    padding-right: 32px;
}

.sh-chat-teaser__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #f1f5f9;
}

.sh-chat-teaser__body {
    flex: 1;
    min-width: 0;
}

.sh-chat-teaser__name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.sh-chat-teaser__text {
    margin: 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
}

/* Subtle arrow pointing to chat button */
.sh-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 32px;
    width: 16px;
    height: 16px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.05);
    border-radius: 0 0 4px 0;
}

/* Mobile styles */
@media (max-width: 599px) {
    .sh-chat-teaser {
        bottom: 90px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
    
    .sh-chat-teaser__content {
        padding: 14px;
        padding-right: 36px;
        gap: 10px;
    }
    
    .sh-chat-teaser__avatar {
        width: 36px;
        height: 36px;
    }
    
    .sh-chat-teaser__name {
        font-size: 12px;
    }
    
    .sh-chat-teaser__text {
        font-size: 13px;
        line-height: 1.4;
    }
    
    .sh-chat-teaser::after {
        right: 28px;
    }
    
    /* Account pages: raise teaser above bottom nav */
    .is-account-page .sh-chat-teaser {
        bottom: 130px;
    }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 599px) {
        .sh-chat-teaser {
            bottom: calc(90px + env(safe-area-inset-bottom));
        }
        
        .is-account-page .sh-chat-teaser {
            bottom: calc(130px + env(safe-area-inset-bottom));
        }
    }
}

/* Reduce motion preference for teaser */
@media (prefers-reduced-motion: reduce) {
    .sh-chat-teaser {
        transition: opacity 0.15s ease, visibility 0.15s ease;
        transform: none !important;
    }
}
