/* ========================================
   Global Chat Widget Styles
   Palette: Tailwind Slate + Amber accent
   ======================================== */

/* --- Container --- */
.chat-widget-container {
    position: fixed;
    bottom: 10rem;
    right: 1.5rem;
    z-index: 9999;
    font-family: inherit;
}

/* --- FAB Button --- */
.chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
    transition: all 0.2s ease;
    position: relative;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    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;
    line-height: 1;
}

/* --- Chat Panel --- */
.chat-panel {
    position: fixed;
    bottom: calc(10rem + 70px);
    right: 1.5rem;
    width: 580px;
    height: 880px;
    max-height: calc(100vh - 10rem - 90px);
    background: #1e293b; /* slate-800 */
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #334155; /* slate-700 */
}

@media (max-width: 640px) {
    .chat-panel {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    .chat-widget-container {
        bottom: 1rem;
        right: 1rem;
    }
}

/* --- Header --- */
.chat-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: #0f172a; /* slate-900 */
    border-bottom: 1px solid #334155;
    gap: 10px;
    min-height: 56px;
}

.chat-header-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    color: #ffffff;
}

.chat-back-btn,
.chat-close-btn {
    background: none;
    border: none;
    color: #94a3b8; /* slate-400 */
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

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

/* --- Tabs --- */
.chat-tabs {
    display: flex;
    border-bottom: 1px solid #334155;
    background: #0f172a;
}

.chat-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.chat-tab:hover {
    color: #e2e8f0; /* slate-200 */
}

.chat-tab-active {
    color: #f59e0b; /* amber-500 */
    border-bottom-color: #f59e0b;
}

.chat-tab-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* --- Search --- */
.chat-search-bar {
    padding: 10px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.chat-search-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    color: #0f172a; /* slate-900 */
    outline: none;
    transition: all 0.15s;
}

.chat-search-input::placeholder {
    color: #64748b; /* slate-500 */
}

.chat-search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.5); /* ring-2 ring-amber-500/50 */
    border-color: #f59e0b;
}

.chat-new-group-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.15s;
    display: flex;
}

.chat-new-group-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f59e0b;
}

/* --- Conversation List --- */
.chat-conversation-list,
.chat-contact-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.chat-conversation-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    color: #ffffff;
}

.chat-conversation-item:hover {
    background: rgba(51, 65, 85, 0.3); /* slate-700/30 */
}

.chat-conv-avatar {
    flex-shrink: 0;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #475569; /* slate-600 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
}

.chat-avatar-group {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.chat-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

/* --- Online indicator --- */
.chat-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.chat-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #22c55e; /* green-500 */
    border-radius: 50%;
    border: 2px solid #1e293b; /* match panel bg */
}

.chat-offline-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #64748b; /* slate-500 */
    border-radius: 50%;
    border: 2px solid #1e293b;
}

.chat-online-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #22c55e;
    color: #0f172a;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #1e293b;
}

.chat-conv-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-conv-name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

.chat-conv-time {
    font-size: 12px;
    color: #64748b;
    flex-shrink: 0;
}

.chat-conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-conv-preview {
    font-size: 13px;
    color: #94a3b8;
    flex: 1;
    min-width: 0;
}

.chat-unread-badge {
    background: #f59e0b;
    color: #0f172a;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

/* --- Contact List --- */
.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    color: #ffffff;
}

.chat-contact-item:hover {
    background: rgba(51, 65, 85, 0.3);
}

.chat-contact-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    gap: 2px;
}

.chat-contact-name {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
}

.chat-contact-detail {
    font-size: 12px;
    color: #64748b;
}

/* --- Conversation View --- */
.chat-conversation-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Messages Area --- */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.chat-date-separator {
    text-align: center;
    margin: 12px 0;
}

.chat-date-separator span {
    background: #334155;
    color: #94a3b8;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 12px;
}

.chat-system-message {
    text-align: center;
    padding: 6px;
}

.chat-system-message span {
    font-size: 13px;
    color: #64748b;
    font-style: italic;
}

/* --- Message Bubbles --- */
.chat-message {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.chat-message-own {
    align-self: flex-end;
    background: #475569; /* slate-600 */
    border-bottom-right-radius: 4px;
}

.chat-message-other {
    align-self: flex-start;
    background: #334155; /* slate-700 */
    border-bottom-left-radius: 4px;
}

.chat-msg-sender {
    font-size: 12px;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 3px;
}

.chat-msg-body {
    font-size: 14px;
    color: #ffffff;
    line-height: 1.5;
}

.chat-msg-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    justify-content: flex-end;
}

.chat-msg-time {
    font-size: 11px;
    color: #64748b;
}

.chat-msg-edited {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}

/* --- Forwarded & Reply --- */
.chat-msg-forwarded {
    font-size: 12px;
    color: #38bdf8; /* sky-400 */
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-msg-reply-preview {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    margin-bottom: 6px;
    align-items: flex-start;
}

.chat-reply-bar {
    width: 3px;
    min-height: 28px;
    background: #f59e0b;
    border-radius: 2px;
    flex-shrink: 0;
}

.chat-reply-sender {
    font-size: 12px;
    font-weight: 600;
    color: #f59e0b;
    display: block;
}

.chat-reply-text {
    font-size: 12px;
    color: #94a3b8;
    display: block;
}

/* --- Files --- */
.chat-msg-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.chat-msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 12px;
    object-fit: cover;
}

.chat-msg-image-link {
    display: block;
}

.chat-msg-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #38bdf8;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s;
}

.chat-msg-file-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- Reactions --- */
.chat-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.chat-reaction-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    color: #ffffff;
}

.chat-reaction-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.chat-reaction-active {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
}

/* --- Message Actions --- */
.chat-msg-actions {
    position: absolute;
    top: -10px;
    right: 6px;
    display: flex;
    gap: 2px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 3px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.chat-message-other .chat-msg-actions {
    right: auto;
    left: 6px;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* --- Emoji Picker --- */
.chat-emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 8px;
    display: flex;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.chat-emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 8px;
    transition: background 0.15s;
}

.chat-emoji-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* --- Typing --- */
.chat-typing-indicator {
    padding: 6px 20px 10px;
    font-size: 13px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-typing-dots {
    display: flex;
    gap: 3px;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: chat-typing-bounce 1.4s infinite both;
}

.chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* --- Reply Bar Input --- */
.chat-reply-bar-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.06);
    border-top: 1px solid rgba(245, 158, 11, 0.2);
}

/* --- Attachments Preview --- */
.chat-attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid #334155;
}

.chat-attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 10px;
    border-radius: 8px;
    max-width: 180px;
    color: #ffffff;
}

/* --- Message Input --- */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 16px 14px;
    background: #0f172a;
    border-top: 1px solid #334155;
}

.chat-attach-btn {
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.15s;
    display: flex;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.chat-message-input {
    flex: 1;
    background: rgba(51, 65, 85, 0.5); /* slate-700/50 */
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: #ffffff;
    outline: none;
    resize: none;
    line-height: 1.45;
    max-height: 120px;
    overflow-y: auto;
    transition: all 0.15s;
}

.chat-message-input::placeholder {
    color: #64748b;
}

.chat-message-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.5);
    border-color: #f59e0b;
}

.chat-send-btn {
    background: #d97706; /* amber-600 */
    color: #ffffff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #b45309; /* amber-700 */
}

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

/* --- Edit textarea --- */
.chat-edit-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: #ffffff;
    outline: none;
    resize: none;
}

/* --- Empty state --- */
.chat-empty-state {
    padding: 32px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Group form --- */
.chat-group-form {
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
}

.chat-group-members-list {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.chat-group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    cursor: pointer;
    border-radius: 8px;
    color: #ffffff;
}

.chat-group-member-item:hover {
    background: rgba(51, 65, 85, 0.3);
}

.chat-checkbox {
    accent-color: #f59e0b;
    width: 16px;
    height: 16px;
}

.chat-group-actions {
    display: flex;
    gap: 10px;
}

.chat-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

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

.chat-btn-primary {
    background: #d97706; /* amber-600 */
    color: #ffffff;
}

.chat-btn-primary:hover:not(:disabled) {
    background: #b45309; /* amber-700 */
}

.chat-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

.chat-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

/* --- Forward modal --- */
.chat-forward-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: 16px;
}

.chat-forward-modal {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    width: 90%;
    max-height: 450px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-forward-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #334155;
    color: #ffffff;
}

.chat-forward-list {
    overflow-y: auto;
    flex: 1;
}

/* --- Load more button --- */
.chat-load-more-btn {
    font-size: 13px;
    color: #38bdf8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.15s;
}

.chat-load-more-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    color: #7dd3fc;
}

/* --- Scrollbar --- */
.chat-messages-area::-webkit-scrollbar,
.chat-conversation-list::-webkit-scrollbar,
.chat-contact-list::-webkit-scrollbar,
.chat-group-members-list::-webkit-scrollbar {
    width: 5px;
}

.chat-messages-area::-webkit-scrollbar-track,
.chat-conversation-list::-webkit-scrollbar-track,
.chat-contact-list::-webkit-scrollbar-track,
.chat-group-members-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb,
.chat-conversation-list::-webkit-scrollbar-thumb,
.chat-contact-list::-webkit-scrollbar-thumb,
.chat-group-members-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.chat-messages-area::-webkit-scrollbar-thumb:hover,
.chat-conversation-list::-webkit-scrollbar-thumb:hover,
.chat-contact-list::-webkit-scrollbar-thumb:hover,
.chat-group-members-list::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
