/**
 * Chat Widget Styles - Scoped specifically for storefront chat
 * Uses prefix: sf-chat-* to avoid conflicts
 */

/* Widget container - fixed to viewport */
.sf-chat-widget {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Toggle button */
.sf-chat-widget .sf-chat-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #064E3B 0%, #0f6b4a 100%);
    color: #fff;
    padding: 0.875rem;
    width: 56px;
    height: 56px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(6, 78, 59, 0.35);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sf-chat-widget .sf-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(6, 78, 59, 0.45);
}

.sf-chat-widget .sf-chat-toggle:active {
    transform: translateY(0);
}

/* Pulse indicator */
.sf-chat-widget .sf-chat-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: sf-chat-pulse-anim 2s infinite;
    position: absolute;
    top: 0;
    right: 0;
}

@keyframes sf-chat-pulse-anim {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Chat icon */
.sf-chat-widget .sf-chat-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.sf-chat-widget .sf-chat-toggle-text {
    display: none;
}

/* Badge for unread messages */
.sf-chat-widget .sf-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #B91C1C;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    animation: sf-chat-badge-pop 0.3s ease;
}

@keyframes sf-chat-badge-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Chat panel */
.sf-chat-widget .sf-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 0;
    width: min(380px, calc(100vw - 2rem));
    max-height: min(560px, calc(100vh - 8rem));
    border-radius: 1.25rem;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sf-chat-slide-up 0.3s ease;
}

@keyframes sf-chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat header */
.sf-chat-widget .sf-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #064E3B 0%, #0f6b4a 100%);
    color: #fff;
}

.sf-chat-widget .sf-chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sf-chat-widget .sf-chat-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sf-chat-widget .sf-chat-brand {
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0;
}

.sf-chat-widget .sf-chat-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.sf-chat-widget .sf-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: sf-chat-blink 1.5s infinite;
}

@keyframes sf-chat-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sf-chat-widget .sf-chat-close {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
}

.sf-chat-widget .sf-chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages container */
.sf-chat-widget .sf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.sf-chat-widget .sf-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

/* Date divider */
.sf-chat-widget .sf-chat-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
}

.sf-chat-widget .sf-chat-date-divider span {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    margin: 0;
}

/* Message bubbles */
.sf-chat-widget .sf-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.sf-chat-widget .sf-chat-message.visitor {
    align-self: flex-end;
    align-items: flex-end;
}

.sf-chat-widget .sf-chat-message.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.sf-chat-widget .sf-chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sf-chat-widget .sf-chat-bubble-admin {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sf-chat-widget .sf-chat-bubble-visitor {
    background: linear-gradient(135deg, #064E3B 0%, #0f6b4a 100%);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.sf-chat-widget .sf-chat-bubble p {
    margin: 0;
}

.sf-chat-widget .sf-chat-time {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

/* Form styles */
.sf-chat-widget .sf-chat-form {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.sf-chat-widget .sf-chat-form-intro {
    margin-bottom: 0.75rem;
}

.sf-chat-widget .sf-chat-form-intro p {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

.sf-chat-widget .sf-chat-field {
    margin-bottom: 0.75rem;
}

.sf-chat-widget .sf-chat-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.sf-chat-widget .sf-chat-input:focus {
    outline: none;
    border-color: #064E3B;
    box-shadow: 0 0 0 3px rgba(6, 78, 59, 0.1);
}

.sf-chat-widget .sf-chat-input::placeholder {
    color: #94a3b8;
}

.sf-chat-widget .sf-chat-textarea {
    resize: none;
    min-height: 80px;
}

.sf-chat-widget .sf-chat-honey {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.sf-chat-widget .sf-chat-submit {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #064E3B 0%, #0f6b4a 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.sf-chat-widget .sf-chat-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 78, 59, 0.35);
}

.sf-chat-widget .sf-chat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.sf-chat-widget .sf-chat-error {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    color: #dc2626;
    font-size: 0.8rem;
}

/* Send form */
.sf-chat-widget .sf-chat-send-form {
    padding: 0.75rem 1rem;
}

.sf-chat-widget .sf-chat-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.sf-chat-widget .sf-chat-input-group .sf-chat-textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
}

.sf-chat-widget .sf-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #064E3B 0%, #0f6b4a 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    padding: 0;
}

.sf-chat-widget .sf-chat-send-btn:hover {
    transform: scale(1.05);
}

.sf-chat-widget .sf-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing indicator */
.sf-chat-widget .sf-chat-typing {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: #f8fafc;
}

.sf-chat-widget .sf-chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: sf-chat-typing-bounce 1.4s infinite ease-in-out;
}

.sf-chat-widget .sf-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.sf-chat-widget .sf-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
.sf-chat-widget .sf-chat-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes sf-chat-typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile responsive */
@media (max-width: 640px) {
    .sf-chat-widget {
        right: 0.75rem;
        bottom: 0.75rem;
    }
    
    .sf-chat-widget .sf-chat-panel {
        width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 5.5rem);
    }
    
    .sf-chat-widget .sf-chat-icon {
        width: 1.4rem;
        height: 1.4rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .sf-chat-widget {
        right: 1.5rem;
        bottom: 1.5rem;
    }
}
