/* =============================================================
   Chat ERP Panel — پنل چت در ERP
   ============================================================= */

/* ── Layout ─────────────────────────────────────────── */
.chat-support-wrap {
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-support-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

/* ── Rooms Panel ─────────────────────────────────────── */
.chat-rooms-panel {
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}
.chat-rooms-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
.chat-rooms-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    flex: 1;
    color: #1e293b;
}
.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
}

/* ── Room Item ───────────────────────────────────────── */
.chat-room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background .12s;
}
.chat-room-item:hover   { background: #eff6ff; }
.chat-room-item.active  { background: #dbeafe; border-right: 3px solid #3b82f6; }
.chat-room-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}
.chat-room-info { flex: 1; min-width: 0; }
.chat-room-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-room-last {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-room-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}
.chat-unread-badge {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ── Status Badges ───────────────────────────────────── */
.chat-status-badge {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.chat-status--open    { background:#d1fae5; color:#065f46; }
.chat-status--pending { background:#fef3c7; color:#92400e; }
.chat-status--closed  { background:#f1f5f9; color:#64748b; }

/* آنلاین */
.chat-online-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: chatPulse 2s infinite;
}
@keyframes chatPulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Conversation Panel ──────────────────────────────── */
.chat-conversation-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

/* ── Conv Header ─────────────────────────────────────── */
.chat-conv-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
}
.chat-conv-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.chat-conv-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-conv-info strong { font-size: 13px; }
.chat-conv-info small  { font-size: 11px; margin-top: 1px; }

/* ── Messages ────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8fafc;
}
.chat-msg {
    display: flex;
    flex-direction: column;
    animation: chatIn .2s ease;
}
@keyframes chatIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }

.chat-msg--in  { align-items: flex-end; }
.chat-msg--out { align-items: flex-start; }
.chat-msg--system { align-items: center; }

.chat-sender-name { font-size: 10px; color: #94a3b8; margin-bottom: 2px; }

.chat-bubble {
    max-width: 72%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 12px;
    line-height: 1.6;
    word-break: break-word;
}
.chat-msg--in  .chat-bubble { background: #fff; border: 1px solid #e2e8f0; color: #1e293b; border-bottom-right-radius: 4px; }
.chat-msg--out .chat-bubble { background: #3b82f6; color: #fff; border-bottom-left-radius: 4px; }
.chat-msg--system .chat-bubble { background: transparent; color: #94a3b8; font-size: 11px; text-align: center; border: none; }

.chat-time {
    display: block;
    font-size: 10px;
    opacity: .6;
    text-align: left;
    margin-top: 3px;
}

/* ── Input Area ──────────────────────────────────────── */
.chat-input-area {
    padding: 10px 14px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}
.chat-textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color .15s;
    direction: rtl;
}
.chat-textarea:focus { border-color: #3b82f6; }
.chat-send-btn {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background .15s;
}
.chat-send-btn:hover { background: #1d4ed8; }
