/* ============================================================
   CHAT.CSS — Chat Interface, Messages, Input
   Used by: /dashboard
   ============================================================ */

.chat-container {
    display: flex;
    height: calc(100vh - 220px);
    min-height: 400px;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

@media (max-width: 900px) {
    /* Mobile: body padding-top=90px, page-header-box~80px, sub-header~36px, content padding~16px */
    .chat-container {
        height: calc(100vh - 240px);
        min-height: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

@media (max-width: 480px) {
    .chat-container {
        height: calc(100vh - 260px);
        min-height: 0;
    }
}

/* ── Agents Top Panel ── */
.agents-top-section {
    display: flex;
    height: 200px;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}
@media (max-width: 900px) {
    .agents-top-section { display: none !important; }
}

.chat-container-desktop { flex-direction: column; }

/* ── Chat Sidebar (agent list) ── */
.chat-sidebar {
    width: 250px;
    background: var(--secondary-bg);
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0;
}
.chat-sidebar h3 { margin-bottom: 1rem; color: var(--primary-color); font-size: 1rem; }

@media (max-width: 900px) {
    .chat-sidebar { display: none; }
}

/* ── Agent Info Panel ── */
.agent-info-panel {
    width: 300px;
    background: var(--secondary-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.25rem;
    overflow-y: auto;
    flex-shrink: 0;
}
@media (max-width: 900px) {
    .agent-info-panel { display: none !important; }
}

/* ── Chat Main ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--secondary-bg);
    min-width: 0;
}

.chat-header {
    padding: 0.875rem 1rem;
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* ── Messages ── */
.chat-messages {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    margin: auto;
    padding: 2rem;
}
.welcome-message i { font-size: 3.5rem; color: var(--primary-color); margin-bottom: 1rem; display: block; }

.message { max-width: 80%; animation: fadeIn 0.2s ease; }
.message.user { align-self: flex-end; }
.message.agent { align-self: flex-start; }

.message-header { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem; }

.message-content {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 0.75rem;
}
.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}
.agent .message-content {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

/* ── Active Agent Banner ── */
.active-agent-banner {
    padding: 0.5rem 1rem;
    background: rgba(0,123,255,0.08);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ── Chat Input ── */
.chat-input-container {
    padding: 0.875rem 1rem;
    background: var(--tertiary-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    resize: none;
    min-height: 44px;
    max-height: 150px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}
#chat-input:focus { outline: none; border-color: var(--primary-color); }

#send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    flex-shrink: 0;
    height: 44px;
}
#send-btn:hover { background: #0056b3; }
#send-btn:disabled { background: #6c757d; cursor: not-allowed; }

/* ── Agent Select (mobile dropdown) ── */
.agent-select {
    display: none;
    width: 100%;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-primary);
}
@media (max-width: 900px) {
    .agent-select { display: block; }
}

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    align-self: flex-start;
}
.typing-indicator span {
    width: 8px; height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}
