/* ═══════════════════════════════════════════════════════════════════
   Fluid Chat — Real-time Chat Widget Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Floating Action Button ──────────────────────────────────────── */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(102, 126, 234, 0.55);
}

.chat-fab--active {
    transform: rotate(90deg) scale(1.05);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4d6a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1a1a2e;
}

/* ── Chat Panel ──────────────────────────────────────────────────── */
.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: min(400px, calc(100vw - 48px));
    height: min(560px, calc(100vh - 140px));
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.06);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.chat-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────────── */
.chat-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
}

.chat-panel-title {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
}

.chat-back-btn,
.chat-close-btn {
    background: rgba(255,255,255,0.06);
    border: none;
    color: #aaa;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.chat-back-btn:hover,
.chat-close-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ── Body ────────────────────────────────────────────────────────── */
.chat-panel-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.chat-panel-body::-webkit-scrollbar {
    width: 4px;
}

.chat-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
}

.chat-loading,
.chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 14px;
    padding: 40px 20px;
    text-align: center;
}

/* ── Room List ───────────────────────────────────────────────────── */
.chat-room-list {
    padding: 8px;
}

.chat-room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-room-item:hover {
    background: rgba(255,255,255,0.06);
}

.chat-room-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.chat-room-info {
    flex: 1;
    min-width: 0;
}

.chat-room-name {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-meta {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.chat-room-unread {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #667eea;
    flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────────────────── */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    min-height: 100%;
    justify-content: flex-end;
}

.chat-empty-messages {
    text-align: center;
    color: #666;
    font-size: 14px;
    padding: 60px 20px;
}

.chat-date-separator {
    text-align: center;
    color: #555;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 12px 0 6px;
}

.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 85%;
    animation: chatMsgIn 0.2s ease;
}

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

.chat-message--own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message--system {
    align-self: center;
    max-width: 100%;
}

.chat-message--system span {
    font-size: 12px;
    color: #555;
    font-style: italic;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.chat-msg-bubble {
    padding: 8px 14px;
    border-radius: 16px 16px 16px 4px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
}

.chat-message--own .chat-msg-bubble {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25), rgba(118, 75, 162, 0.2));
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 16px 16px 4px 16px;
}

.chat-msg-author {
    font-size: 11px;
    font-weight: 600;
    color: #8ea0f4;
    margin-bottom: 2px;
}

.chat-msg-text {
    font-size: 14px;
    color: #d8d8e8;
    line-height: 1.45;
    word-break: break-word;
}

.chat-message--own .chat-msg-text {
    color: #e8e8ff;
}

.chat-msg-time {
    font-size: 10px;
    color: #555;
    margin-top: 2px;
    text-align: right;
}

/* ── Input Area ──────────────────────────────────────────────────── */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    align-items: flex-end;
    background: rgba(0,0,0,0.15);
}

#chat-message-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

#chat-message-input:focus {
    outline: none;
    border-color: #667eea;
}

#chat-message-input::placeholder {
    color: #555;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Toast ────────────────────────────────────────────────────────── */
.chat-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(40px);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 350px;
    text-align: center;
    pointer-events: none;
}

.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chat-toast--info {
    background: #1a1a2e;
    color: #e0e0ff;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.chat-toast--error {
    background: #2e1a1a;
    color: #ffe0e0;
    border: 1px solid rgba(234, 102, 102, 0.3);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .chat-panel--open + .chat-fab {
        display: none;
    }
}
