/* ===== FLOATING CHAT WIDGET ===== */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007aff 0%, #0062cc 100%);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 122, 255, 0.5);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff3b30;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #007aff 0%, #0062cc 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.chat-header-info p {
    margin: 0.25rem 0 0 0;
    font-size: 0.8125rem;
    opacity: 0.9;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
}

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

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

/* Chat Welcome */
.chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.chat-welcome i {
    font-size: 3rem;
    color: #007aff;
    margin-bottom: 1rem;
}

.chat-welcome h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #1f2937;
}

.chat-welcome p {
    margin: 0;
    font-size: 0.875rem;
}

/* Chat Message Bubble */
.chat-message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: messageFadeIn 0.3s ease;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Customer's OWN messages - RIGHT side (blue) */
.chat-message.user {
    flex-direction: row-reverse;
}

/* Admin's replies to customer - LEFT side (white) */
.chat-message.admin {
    flex-direction: row;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-message-avatar.admin {
    background: linear-gradient(135deg, #007aff, #0062cc);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-message-content {
    max-width: 75%;
}

.chat-message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Customer's OWN messages - RIGHT side - BLUE */
.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #007aff, #0062cc);
    color: white;
    border-top-right-radius: 4px;
}

/* Admin's replies to customer - LEFT side - WHITE */
.chat-message.admin .chat-message-bubble {
    background: white;
    color: #1f2937;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

/* Chat Input Container */
.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
}

/* Chat Sign-in Prompt */
.chat-signin-prompt {
    text-align: center;
    padding: 1rem;
}

.chat-signin-prompt p {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.chat-signin-btn {
    padding: 0.625rem 1.25rem;
    background: white;
    border: 1.5px solid #e5e5ea;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #1f2937;
}

.chat-signin-btn:hover {
    background: #f9fafb;
    border-color: #007aff;
}

/* Chat Form */
.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-form textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1.5px solid #e5e5ea;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-form textarea:focus {
    border-color: #007aff;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #007aff, #0062cc);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 48px);
        height: calc(100vh - 140px);
        right: -12px;
    }

    .chat-widget {
        right: 12px;
        bottom: 12px;
    }
}
