/* ============================================================
   AgentPanel Chatbot – Flowbite-Style UI
   ============================================================ */

/* ---------- Root container ---------- */
#agentpanel-chatbot-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* ---------- Toggle button ---------- */
#agentpanel-chat-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1c64f2 0%, #6d28d9 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(28, 100, 242, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
#agentpanel-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(28, 100, 242, 0.55);
}
#agentpanel-chat-toggle svg {
    width: 26px;
    height: 26px;
    color: #fff;
    transition: transform 0.3s ease;
}
#agentpanel-chat-toggle.is-open svg {
    transform: rotate(90deg);
}

/* Notification dot */
#agentpanel-chat-toggle::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}

/* ---------- Chat window ---------- */
.agentpanel-chat-window {
    display: none;
    flex-direction: column;
    position: fixed !important;
    bottom: 90px !important;
    right: 24px !important;
    width: 384px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 110px);
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 999999;
    transform-origin: bottom right;
    animation: none;
}

.agentpanel-chat-window.open {
    display: flex;
    animation: chatbot-scale-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes chatbot-scale-in {
    from { opacity: 0; transform: scale(0.85) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- Header ---------- */
.agentpanel-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1c64f2 100%);
    flex-shrink: 0;
}

.agentpanel-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agentpanel-chat-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.agentpanel-chat-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
  
    border: 2px solid rgba(255,255,255,0.3);
    background: #fff;
}

/* Online dot on avatar */
.agentpanel-chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #1c64f2;
}

.agentpanel-chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.agentpanel-chat-header-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.agentpanel-chat-header-status {
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    gap: 4px;
}

.agentpanel-chat-header-status span.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #86efac;
    display: inline-block;
}

.agentpanel-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.agentpanel-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    transition: background 0.15s, color 0.15s;
}
.agentpanel-header-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.agentpanel-header-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Messages area ---------- */
#agentpanel-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
#agentpanel-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#agentpanel-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#agentpanel-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* ---------- Message rows ---------- */
.agentpanel-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
    animation: msg-appear 0.2s ease both;
}

@keyframes msg-appear {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Bot row: left-aligned */
.agentpanel-msg-row.bot {
    flex-direction: row;
}

/* User row: right-aligned */
.agentpanel-msg-row.user {
    flex-direction: row-reverse;
}

/* Small avatar for messages */
.agentpanel-msg-avatar {
  width: 32px;
    height: 32px;
    border-radius: 360px;
}

.agentpanel-msg-avatar.user-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e7ff;
    color: #4f46e5;
}
.agentpanel-msg-avatar.user-icon svg {
    width: 16px;
    height: 16px;
}

/* Bubble group */
.agentpanel-msg-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 75%;
}

.agentpanel-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    padding: 0 4px;
}
.agentpanel-msg-row.user .agentpanel-msg-sender {
    text-align: right;
}

/* Bubble */
.agentpanel-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    max-width: 100%;
}

/* Bot bubble */
.agentpanel-msg-row.bot .agentpanel-bubble {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* User bubble */
.agentpanel-msg-row.user .agentpanel-bubble {
    background: linear-gradient(135deg, #1c64f2 0%, #3b82f6 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(28,100,242,0.3);
}

/* Timestamp */
.agentpanel-msg-time {
    font-size: 10px;
    color: #9ca3af;
    padding: 0 4px;
}
.agentpanel-msg-row.user .agentpanel-msg-time {
    text-align: right;
}

/* ---------- Product card (inline) ---------- */
.agentpanel-product-card {
    display: block;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    margin: 6px 0;
    text-decoration: none;
    transition: box-shadow 0.15s, transform 0.15s;
    color: inherit;
}
.agentpanel-product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.agentpanel-product-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}
.agentpanel-product-card .card-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.agentpanel-product-card .card-cta {
    display: block;
    text-align: center;
    background: #1c64f2;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
}
.agentpanel-product-card:hover .card-cta {
    background: #1a56db;
}

/* ---------- Link card ---------- */
.agentpanel-link-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.agentpanel-link-card:hover {
    background: #f3f4f6;
}
.agentpanel-link-card .link-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #1c64f2;
}
.agentpanel-link-card .link-icon svg {
    width: 18px;
    height: 18px;
}
.agentpanel-link-card .link-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agentpanel-link-card .link-url {
    font-size: 11px;
    color: #1c64f2;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Typing indicator ---------- */
.agentpanel-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    width: fit-content;
}
.agentpanel-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing-dot 1.2s infinite ease-in-out;
}
.agentpanel-typing span:nth-child(1) { animation-delay: 0s; }
.agentpanel-typing span:nth-child(2) { animation-delay: 0.2s; }
.agentpanel-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
    0%, 60%, 100% { transform: translateY(0); background: #9ca3af; }
    30% { transform: translateY(-5px); background: #6b7280; }
}

/* ---------- Date separator ---------- */
.agentpanel-date-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: #9ca3af;
    margin: 4px 0;
}
.agentpanel-date-sep::before,
.agentpanel-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

/* ---------- Footer / Input area ---------- */
.agentpanel-chat-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

#agentpanel-chat-form {
    padding: 0;
    margin: 0;
}

/* Relative wrapper – button sits inside */
.agentpanel-input-row {
    position: relative;
    width: 100%;
}

/* Input */
#agentpanel-chat-input {
    display: block;
    width: 100%;
    padding: 12px 90px 12px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    color: #111827;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#agentpanel-chat-input:focus {
    border-color: #1c64f2;
    box-shadow: 0 0 0 3px rgba(28,100,242,0.12);
}
#agentpanel-chat-input::placeholder {
    color: #9ca3af;
}

/* Button inside input – absolute positioned */
button.agentpanel-send-btn{
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    height: 30px;
    border-radius: 6px;
    background: #1c64f2;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.25;
    white-space: nowrap;
   
    transition: background 0.15s;
    background-color: #1a56db;
    border: 0px solid #c36;
}
.agentpanel-send-btn:hover {
    background: #1a56db;
}
.agentpanel-send-btn:active {
    background: #1e40af;
}
.agentpanel-send-btn:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .agentpanel-chat-window {
        right: 16px !important;
        bottom: 80px !important;
        width: calc(100vw - 32px) !important;
        max-width: 400px !important;
        height: calc(100dvh - 100px) !important;
        max-height: 80dvh !important;
        border-radius: 16px !important;
        box-shadow: 0 8px 32px rgba(0,0,0,0.15) !important;
    }
    #agentpanel-chatbot-root {
        bottom: 16px;
        right: 16px;
    }
}



button#agentpanel-chat-close {
    padding: unset;
}