/* ============================================
   CUSTOMER CHAT WIDGET - Floating bubble + chat window
   ============================================ */

/* Container */
.chat-widget-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Floating Action Button ---- */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9999;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.chat-fab-icon {
    width: 26px;
    height: 26px;
}
.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
}
.chat-fab-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
}
.chat-fab-status.online {
    background: #22c55e;
}
.chat-fab-status.offline {
    background: #9ca3af;
}

/* ---- Chat Window ---- */
.chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: chatSlideUp 0.25s ease-out;
}

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

/* ---- Chat Header ---- */
.chat-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-header-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.chat-header-status.online { background: #4ade80; }
.chat-header-status.offline { background: #9ca3af; }
.chat-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
.chat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.2;
}
.chat-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    padding: 4px;
    border-radius: 6px;
    transition: opacity 0.15s, background 0.15s;
}
.chat-header-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* ---- Messages Area ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Welcome state */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    flex: 1;
}

/* Date divider */
.chat-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
}
.chat-date-divider span {
    font-size: 11px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 10px;
    border-radius: 10px;
}

/* Messages */
.chat-msg {
    max-width: 82%;
    display: flex;
    flex-direction: column;
}
.chat-msg-sent {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg-received {
    align-self: flex-start;
    align-items: flex-start;
}
.chat-msg-sender {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 2px;
    padding-left: 4px;
}
.chat-msg-bubble {
    padding: 8px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    width: fit-content;
    max-width: 100%;
}
.chat-msg-sent .chat-msg-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-received .chat-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.chat-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
    padding: 0 4px;
}

/* ---- Input Area ---- */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
    transition: border-color 0.15s;
}
.chat-input:focus {
    border-color: #93c5fd;
    background: #fff;
}
.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-send-btn:hover {
    background: #1d4ed8;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        bottom: 8px;
        right: 8px;
        border-radius: 12px;
    }
    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}
