/* css/chatbot.css - Clean & Fast Edition */
:root {
    --cb-primary: #3b82f6;
    --cb-primary-hover: #2563eb;
    --cb-bg: #ffffff;
    --cb-panel: #f8fafc;
    --cb-border: #e2e8f0;
    --cb-text: #1e293b;
    --cb-text-light: #64748b;
    --cb-user-msg: #3b82f6;
    --cb-bot-msg: #f1f5f9;
    --cb-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --cb-primary: #60a5fa;
    --cb-primary-hover: #3b82f6;
    --cb-bg: #0f172a;
    --cb-panel: #1e293b;
    --cb-border: #334155;
    --cb-text: #f8fafc;
    --cb-text-light: #94a3b8;
    --cb-user-msg: #3b82f6;
    --cb-bot-msg: #1e293b;
    --cb-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

.acadbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: var(--font-body), system-ui, -apple-system, sans-serif;
}

/* ── Trigger Button ── */
.acadbot-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cb-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
    color: #fff;
    padding: 0;
}

.acadbot-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.acadbot-trigger svg {
    width: 28px;
    height: 28px;
}

/* ── Chat Window ── */
.acadbot-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 48px);
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--cb-shadow);
}

.acadbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

@media (max-width: 480px) {
    .acadbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 76px;
        right: -8px;
    }
}

/* ── Header ── */
.acadbot-header {
    padding: 16px 20px;
    background: var(--cb-panel);
    border-bottom: 1px solid var(--cb-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo-wrap {
    width: 36px;
    height: 36px;
    background: var(--cb-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.header-logo-wrap svg {
    width: 20px;
    height: 20px;
}

.acadbot-header-info {
    flex: 1;
}

.acadbot-header-info h3 {
    margin: 0 0 2px 0;
    font-size: 16px;
    color: var(--cb-text);
    font-weight: 600;
}

.status-badge {
    font-size: 12px;
    color: var(--cb-text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-badge::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--cb-text-light);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.close-btn:hover {
    background: var(--cb-border);
    color: var(--cb-text);
}

/* ── Messages ── */
.acadbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--cb-border) transparent;
}

.acadbot-messages::-webkit-scrollbar {
    width: 6px;
}
.acadbot-messages::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 3px;
}

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.5;
    word-break: break-word;
    animation: msgIn 0.3s ease-out forwards;
}

.msg a {
    color: inherit;
    text-decoration: underline;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-bot {
    align-self: flex-start;
    background: var(--cb-bot-msg);
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--cb-border);
}

.msg-user {
    align-self: flex-end;
    background: var(--cb-user-msg);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg-bot.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #f87171;
}

[data-theme="dark"] .msg-bot.error {
    background: rgba(153, 27, 27, 0.2);
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.4);
}

/* ── Input Area ── */
.acadbot-input-area {
    padding: 16px 20px;
    background: var(--cb-panel);
    border-top: 1px solid var(--cb-border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.acadbot-input-area input {
    flex: 1;
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 24px;
    padding: 12px 16px;
    color: var(--cb-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.acadbot-input-area input:focus {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.acadbot-send {
    width: 42px;
    height: 42px;
    background: var(--cb-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.acadbot-send svg {
    width: 20px;
    height: 20px;
    margin-right: 2px; /* visual center adjustment */
}

.acadbot-send:hover {
    background: var(--cb-primary-hover);
    transform: scale(1.05);
}

/* ── Typing ── */
.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: var(--cb-bot-msg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    gap: 4px;
    border: 1px solid var(--cb-border);
    margin: 0 20px 10px 20px;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--cb-text-light);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
