/* ============================================
   FACEBOOK-STYLE CHAT WIDGET
   ============================================ */

/* Chat Float Button with Badge */
.btn-chat-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--bg-btn);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999;
    border: none;
}

    .btn-chat-float:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    }

    .btn-chat-float svg {
        width: 28px;
        height: 28px;
        color: var(--hotel-accent);
    }

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    animation: badgePulse 2s infinite;
}

    .chat-badge.show {
        display: flex;
    }

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
}

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .chat-widget.show {
        display: flex;
        animation: chatSlideUp 0.3s ease;
    }

    .chat-widget.minimized {
        height: 60px;
    }

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-widget-header {
    background: var(--bg-btn);
    color: var(--txt-btn);
    padding: var(--px-12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    height: var(--px-108);
    padding-top: var(--px-36);
}

.chat-widget-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #059669;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-agent-info {
    flex: 1;
    min-width: 0;
}

.chat-agent-name {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-agent-status {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
}

.chat-widget-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

    .chat-header-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .chat-header-btn svg {
        width: 18px;
        height: 18px;
        color: white;
    }

/* Chat Body */
.chat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget.minimized .chat-widget-body {
    display: none;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageSlideIn 0.2s ease;
    width: max-content;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.own {
    align-self: flex-end;
}

.chat-message.other {
    align-self: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    max-width: unset;
}

.chat-message.own .message-bubble {
    background: var(--bg-btn);
    color: var(--txt-btn);
    border-bottom-right-radius: 4px;
}

.chat-message.other .message-bubble {
    background: #e5e7eb;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.own .message-time {
    text-align: right;
}

/* Date Divider */
.chat-date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
}

.chat-date-line {
    flex: 1;
    height: 1px;
    background: #d1d5db;
}

.chat-date-text {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #e5e7eb;
    border-radius: 18px;
    width: fit-content;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7280;
    animation: typingDot 1.4s infinite;
}

    .typing-dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .typing-dot:nth-child(3) {
        animation-delay: 0.4s;
    }

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    flex: 1;
}

.chat-empty-icon {
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.chat-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
}

.chat-empty-text {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Loading State */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    flex: 1;
}

.chat-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chat-loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: #6b7280;
}

/* Chat Footer */
.chat-widget-footer {
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-widget.minimized .chat-widget-footer {
    display: none;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-text-input {
    flex: 1;
    padding: 16px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    transition: border-color 0.2s;
}

    .chat-text-input:focus {
        outline: none;
        border-color: var(--hotel-primary-light);
    }

    .chat-text-input::placeholder {
        color: #9ca3af;
    }

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-btn);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

    .chat-send-btn:hover:not(:disabled) {
        background: #059669;
    }

    .chat-send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .chat-send-btn svg {
        width: 20px;
        height: 20px;
        color: white;
    }

/* Scrollbar Styling */
.chat-widget-body::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

    .chat-widget-body::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
    }

/* ============================================
   MOBILE RESPONSIVE (Fullscreen)
   ============================================ */

@media (max-width: 640px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

        .chat-widget.minimized {
            height: 60px;
            bottom: 70px;
            left: auto;
            right: 20px;
            width: 250px;
            border-radius: 16px;
        }

    .btn-chat-float {
        bottom: 80px;
    }

    .chat-widget-header {
        border-radius: 0;
    }

    .chat-message {
        max-width: 80%;
    }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .chat-widget {
        width: 360px;
        height: 500px;
    }
}

/* Connection Status Indicator */
.chat-connection-status {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    color: white;
    display: none;
}

    .chat-connection-status.reconnecting {
        display: block;
        background: #f59e0b;
    }

    .chat-connection-status.disconnected {
        display: block;
        background: #ef4444;
    }
