/* Cookiy CRM — Agent Chat Sidebar (Apple HIG Light Mode) */

/* ── FAB Button ── */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 50px;
    border: none;
    background: var(--tint-blue, #007AFF);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,122,255,0.30);
    transition: all 0.2s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,122,255,0.40); }
.chat-fab.hidden { display: none; }
.chat-fab-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

/* ── Sidebar Panel ── */
.chat-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 370px;
    height: 100vh;
    z-index: 350;
    background: var(--glass-surface, rgba(255,255,255,0.72));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(0,0,0,0.06);
    box-shadow: -4px 0 24px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}
.chat-sidebar.open { right: 0; }

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    background: var(--system-bg-secondary, #F2F2F7);
}
.chat-agent-info { display: flex; align-items: center; gap: 10px; }
.chat-agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}
.chat-agent-name { font-weight: 600; font-size: 0.9rem; color: var(--label-primary, #000000); }
.chat-agent-role { font-size: 0.7rem; color: var(--label-secondary, rgba(60,60,67,0.60)); }
.chat-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--label-tertiary, rgba(60,60,67,0.30));
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.chat-close:hover { color: var(--label-primary, #000000); }

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

.chat-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    word-break: break-word;
}
.chat-msg.agent {
    align-self: flex-start;
    background: var(--system-bg-secondary, #F2F2F7);
    color: var(--label-primary, #000000);
    border-bottom-left-radius: 4px;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--tint-blue, #007AFF);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg .msg-data {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.04);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'SF Mono', Menlo, monospace;
    white-space: pre-wrap;
}
.chat-msg .msg-card {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--system-bg-tertiary, #FFFFFF);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 8px;
    font-size: 0.78rem;
}
.chat-msg .msg-card strong { color: var(--tint-blue, #007AFF); }
.chat-msg .msg-card .card-row { display: flex; justify-content: space-between; margin-top: 2px; }
.chat-msg .msg-escalation {
    margin-top: 6px;
    padding: 6px 10px;
    background: rgba(255,204,0,0.12);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--tint-orange, #FF9500);
}

/* ── Input ── */
.chat-input-area {
    display: flex;
    padding: 12px 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
    gap: 8px;
    background: var(--system-bg-secondary, #F2F2F7);
}
.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--system-bg-tertiary, #FFFFFF);
    color: var(--label-primary, #000000);
}
.chat-input-area input::placeholder { color: var(--label-tertiary, rgba(60,60,67,0.30)); }
.chat-input-area input:focus { outline: none; border-color: rgba(0,122,255,0.50); box-shadow: 0 0 0 3px rgba(0,122,255,0.12); }
.chat-send-btn {
    padding: 10px 16px;
    background: var(--tint-blue, #007AFF);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: inherit;
}
.chat-send-btn:hover { background: #0071EB; }

/* ── Typing indicator ── */
.chat-typing { font-size: 0.75rem; color: var(--label-tertiary, rgba(60,60,67,0.30)); padding: 4px 14px; font-style: italic; }

/* ── Mobile ── */
@media (max-width: 768px) {
    .chat-sidebar { width: 100%; right: -100%; }
    .chat-sidebar.open { right: 0; }
    .chat-fab { bottom: 16px; right: 16px; padding: 10px 14px; }
    .chat-fab-name { display: none; }
}
