/* ===== Agent Chat Widget ===== */

/* ── Floating Bubble ── */
.agent-bubble {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p, #6366f1), var(--a, #d946ef));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 24px rgba(99,102,241,0.4);
    transition: transform 0.25s, box-shadow 0.25s;
}
.agent-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(99,102,241,0.55);
}
.agent-bubble.open { display: none; }

/* ── Chat Panel ── */
.agent-panel {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 1001;
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 560px;
    max-height: calc(100vh - 6rem);
    border-radius: 1.25rem;
    background: #0f1729;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.agent-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.agent-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.agent-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--p, #6366f1), var(--a, #d946ef));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.agent-header-info { flex: 1; }
.agent-header-info h4 { font-size: 0.9rem; font-weight: 700; color: #fff; margin: 0; }
.agent-header-info p { font-size: 0.7rem; color: rgba(255,255,255,0.4); margin: 0; }
.agent-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    transition: color 0.15s;
}
.agent-close-btn:hover { color: #fff; }

/* ── Messages Area ── */
.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.agent-messages::-webkit-scrollbar { width: 4px; }
.agent-messages::-webkit-scrollbar-track { background: transparent; }
.agent-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Message Bubbles ── */
.agent-msg {
    max-width: 88%;
    padding: 0.65rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
    word-wrap: break-word;
    animation: agentMsgIn 0.2s ease;
}
@keyframes agentMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.agent-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--p, #6366f1), var(--a, #d946ef));
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}
.agent-msg.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
    border-bottom-left-radius: 0.25rem;
}
.agent-msg.bot.system {
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    align-self: center;
    text-align: center;
    max-width: 95%;
}

/* ── Typing Indicator ── */
.agent-typing {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    align-self: flex-start;
}
.agent-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    animation: agentTyping 1.2s infinite;
}
.agent-typing span:nth-child(2) { animation-delay: 0.15s; }
.agent-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes agentTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Confirmation Card ── */
.agent-confirm-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
}
.agent-confirm-card .agent-confirm-title {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 0.5rem;
}
.agent-confirm-card .agent-confirm-data {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}
.agent-confirm-card .agent-confirm-data span {
    color: var(--p, #6366f1);
    font-weight: 600;
}
.agent-confirm-btns {
    display: flex;
    gap: 0.5rem;
}
.agent-confirm-btns button {
    flex: 1;
    padding: 0.45rem 0;
    border-radius: 0.5rem;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.agent-confirm-btns button:hover { opacity: 0.85; }
.agent-confirm-btns .agent-btn-confirm {
    background: linear-gradient(135deg, var(--p, #6366f1), var(--a, #d946ef));
    color: #fff;
}
.agent-confirm-btns .agent-btn-cancel {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.6);
}

/* ── Search Results ── */
.agent-search-results {
    margin-top: 0.5rem;
}
.agent-search-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: background 0.15s;
}
.agent-search-item:hover {
    background: rgba(255,255,255,0.08);
}
.agent-search-item .agent-search-primary {
    font-weight: 600;
    color: var(--p, #6366f1);
}
.agent-search-item .agent-search-secondary {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    margin-top: 0.15rem;
}
.agent-no-results {
    text-align: center;
    color: rgba(255,255,255,0.35);
    font-size: 0.8rem;
    padding: 1rem 0;
}

/* ── Input Area ── */
.agent-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-shrink: 0;
    background: rgba(255,255,255,0.02);
}
.agent-input-area textarea {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.75rem;
    padding: 0.6rem 0.85rem;
    color: #fff;
    font-size: 0.85rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.5;
    transition: border-color 0.15s;
}
.agent-input-area textarea::placeholder { color: rgba(255,255,255,0.25); }
.agent-input-area textarea:focus { border-color: var(--p, #6366f1); }
.agent-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p, #6366f1), var(--a, #d946ef));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}
.agent-send-btn:hover { opacity: 0.85; transform: scale(1.05); }
.agent-send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

/* ── Quick Actions ── */
.agent-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 0.5rem 0.5rem;
}
.agent-quick-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 1rem;
    padding: 0.3rem 0.7rem;
    color: rgba(255,255,255,0.6);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.agent-quick-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.3);
    color: rgba(255,255,255,0.9);
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .agent-panel {
        width: calc(100vw - 1rem);
        height: calc(100vh - 4rem);
        max-height: none;
        bottom: 0.5rem;
        left: 0.5rem;
        border-radius: 1rem;
    }
}
