/* ==========================================
   AGENT CHAT MODAL STYLES (CRM 2026 NURIK)
   ========================================== */

/* Brand Logo Badge */
.brand {
    position: relative;
    cursor: pointer;
    text-decoration: none;
}
.brand-chat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #4ade80;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
}
.brand:hover .brand-chat-badge {
    background: rgba(34, 197, 94, 0.25);
    border-color: rgba(34, 197, 94, 0.6);
    transform: translateY(-1px);
}
.brand-chat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: agentPulseDot 2s infinite;
}

@keyframes agentPulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Modal Backdrop */
.agent-chat-modal {
    position: fixed;
    inset: 0;
    z-index: 13000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 13, 22, 0.68);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: agentModalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.agent-chat-modal[hidden] {
    display: none !important;
}

@keyframes agentModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Card */
.agent-chat-dialog {
    width: min(1080px, 96vw);
    height: min(84vh, 740px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: Manrope, system-ui, sans-serif;
    animation: agentModalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes agentModalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.agent-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    background: #0f172a;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.agent-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.agent-chat-title__icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}
.agent-chat-title h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #fff;
}
.agent-chat-title p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #94a3b8;
}
.agent-chat-close {
    appearance: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}
.agent-chat-close:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Body (Sidebar + Chat Pane) */
.agent-chat-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(300px, 360px) 1fr;
    background: #f8fafc;
}

/* Mobile Nav Tabs */
.agent-chat-mob-tabs {
    display: none;
    background: #1e293b;
    padding: 6px;
    gap: 6px;
}
.agent-chat-mob-tab {
    flex: 1;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font: 700 13px/1 Manrope, sans-serif;
    cursor: pointer;
}
.agent-chat-mob-tab.is-active {
    background: #0f172a;
    color: #fff;
}

/* Sidebar: Agent Directory */
.agent-chat-sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.agent-search-box {
    padding: 14px;
    border-bottom: 1px solid #f1f5f9;
}
.agent-search-input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font: 500 13px/1 Manrope, sans-serif;
    color: #0f172a;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}
.agent-search-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.agent-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.agent-card {
    appearance: none;
    width: 100%;
    border: 1.5px solid #f1f5f9;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
}
.agent-card:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
    transform: translateY(-1px);
}
.agent-card.is-selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.12);
}
.agent-card.is-ai-card {
    border-color: #fef08a;
    background: linear-gradient(135deg, #fffbeb, #ffffff);
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.12);
}
.agent-card.is-ai-card:hover {
    border-color: #eab308;
    background: #fef3c7;
}
.agent-card.is-ai-card.is-selected {
    border-color: #ca8a04;
    background: rgba(234, 179, 8, 0.12);
    box-shadow: 0 4px 16px rgba(202, 138, 4, 0.2);
}
.agent-card.is-ai-card .agent-devs {
    background: #fef08a;
    color: #854d0e;
}
.agent-card.is-ai-card.is-selected .agent-devs {
    background: #ca8a04;
    color: #ffffff;
}

.agent-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f172a, #334155);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.agent-avatar__dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}
.agent-info {
    min-width: 0;
    flex: 1;
}
.agent-name {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
}
.agent-role {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}
.agent-devs {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #1e293b;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.25;
    max-width: 100%;
    word-break: break-word;
}
.agent-card.is-selected .agent-devs {
    background: #22c55e;
    color: #fff;
}

/* Chat Pane */
.agent-chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f8fafc;
}
.agent-chat-head-selected {
    padding: 12px 18px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.agent-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.agent-header-name {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}
.agent-header-sub {
    font-size: 12px;
    color: #64748b;
    margin: 1px 0 0;
}

/* Messages List */
.agent-chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
}
.chat-bubble--agent {
    align-self: flex-start;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border-bottom-left-radius: 3px;
}
.chat-bubble--user {
    align-self: flex-end;
    background: #0f172a;
    color: #ffffff;
    border-bottom-right-radius: 3px;
}
.chat-bubble--system {
    align-self: center;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #15803d;
    font-weight: 700;
    text-align: center;
}
.chat-bubble-time {
    display: block;
    font-size: 10px;
    opacity: 0.65;
    margin-top: 4px;
    text-align: right;
}

/* Quick Prompts Chips */
.chat-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 18px 12px;
    max-height: 130px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.chat-quick-prompts::-webkit-scrollbar {
    width: 5px;
}
.chat-quick-prompts::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.chat-chip {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 999px;
    padding: 6.5px 14px;
    font: 600 12px/1.25 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    white-space: nowrap;
}
.chat-chip:hover {
    border-color: #eab308;
    background: #fefce8;
    color: #854d0e;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(234, 179, 8, 0.15);
}
.chat-chip:active {
    transform: translateY(0);
}

/* Input Form */
.agent-chat-form {
    padding: 14px 18px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.agent-form-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.agent-form-field {
    height: 38px;
    padding: 0 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font: 500 13px/1 Manrope, sans-serif;
    color: #0f172a;
    outline: none;
    box-sizing: border-box;
}
.agent-form-field:focus {
    border-color: #22c55e;
}
.agent-form-row {
    display: flex;
    gap: 10px;
}
.agent-form-textarea {
    flex: 1;
    height: 44px;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font: 500 13px/1.3 Manrope, sans-serif;
    color: #0f172a;
    outline: none;
    resize: none;
    box-sizing: border-box;
}
.agent-form-textarea:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.agent-form-send {
    appearance: none;
    height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font: 700 13px/1 Manrope, sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.agent-form-send:hover {
    opacity: 0.94;
    transform: translateY(-1px);
}

.chat-bubble--system.is-error {
    border-color: #ef4444;
    color: #b91c1c;
    background: #fef2f2;
}

/* Только AI: без списка агентов */
.agent-chat-dialog--ai-only .agent-chat-mob-tabs,
.agent-chat-dialog--ai-only .agent-chat-sidebar {
    display: none !important;
}
.agent-chat-dialog--ai-only .agent-chat-body {
    grid-template-columns: 1fr;
}
.agent-chat-dialog--ai-only .agent-chat-main {
    display: flex !important;
}

@media (max-width: 768px) {
    .agent-chat-dialog {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .agent-chat-mob-tabs {
        display: flex;
    }
    .agent-chat-body {
        grid-template-columns: 1fr;
    }
    .agent-chat-sidebar[data-mob-hide="1"] {
        display: none !important;
    }
    .agent-chat-main[data-mob-hide="1"] {
        display: none !important;
    }
    .agent-form-inputs {
        grid-template-columns: 1fr;
    }
}
