/**
 * AGORA Chatbot Widget Styles
 *
 * A clean, modern floating chat widget that matches AGORA Ministries' brand.
 * Uses a warm dark blue palette with gold/amber accents.
 */

/* ─── CSS Variables ──────────────────────────────────────────────── */
:root {
    --agora-primary: #1a1a2e;
    --agora-primary-light: #16213e;
    --agora-accent: #b71c1c;
    --agora-accent-hover: #d32f2f;
    --agora-text: #f0f0f0;
    --agora-text-dark: #1a1a2e;
    --agora-bg-chat: #ffffff;
    --agora-bg-messages: #f7f8fa;
    --agora-bg-user-msg: #1a1a2e;
    --agora-bg-bot-msg: #ffffff;
    --agora-border: #e1e5eb;
    --agora-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --agora-shadow-toggle: 0 4px 20px rgba(26, 26, 46, 0.35);
    --agora-radius: 16px;
    --agora-radius-sm: 12px;
    --agora-radius-msg: 18px;
    --agora-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --agora-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --agora-chat-width: 380px;
    --agora-chat-height: 540px;
}

/* ─── Container ──────────────────────────────────────────────────── */
.agora-chatbot {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--agora-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

.agora-chatbot *,
.agora-chatbot *::before,
.agora-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.agora-chatbot--right {
    right: 24px;
}

.agora-chatbot--left {
    left: 24px;
}

/* ─── Toggle Button ──────────────────────────────────────────────── */
.agora-chatbot__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agora-primary) 0%, var(--agora-primary-light) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--agora-shadow-toggle);
    transition: transform var(--agora-transition), box-shadow var(--agora-transition);
    position: relative;
    overflow: hidden;
}

.agora-chatbot__toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agora-accent) 0%, var(--agora-accent-hover) 100%);
    opacity: 0;
    transition: opacity var(--agora-transition);
}

.agora-chatbot__toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(26, 26, 46, 0.45);
}

.agora-chatbot__toggle:hover::before {
    opacity: 1;
}

.agora-chatbot__toggle:active {
    transform: scale(0.95);
}

.agora-chatbot__icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
    position: relative;
    z-index: 1;
    transition: transform var(--agora-transition), opacity var(--agora-transition);
}

.agora-chatbot__icon--chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.agora-chatbot__icon--close {
    position: absolute;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

/* When panel is open, swap icons */
.agora-chatbot.is-open .agora-chatbot__icon--chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.agora-chatbot.is-open .agora-chatbot__icon--close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Pulse animation on the toggle button */
.agora-chatbot__toggle::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--agora-accent);
    opacity: 0;
    animation: agora-pulse 3s ease-in-out infinite;
}

.agora-chatbot.is-open .agora-chatbot__toggle::after {
    animation: none;
    opacity: 0;
}

@keyframes agora-pulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

/* ─── Chat Panel ─────────────────────────────────────────────────── */
.agora-chatbot__panel {
    position: absolute;
    bottom: 76px;
    width: var(--agora-chat-width);
    height: var(--agora-chat-height);
    max-height: calc(100vh - 140px);
    background: var(--agora-bg-chat);
    border-radius: var(--agora-radius);
    box-shadow: var(--agora-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity var(--agora-transition),
                visibility var(--agora-transition),
                transform var(--agora-transition);
}

.agora-chatbot--right .agora-chatbot__panel {
    right: 0;
    transform-origin: bottom right;
}

.agora-chatbot--left .agora-chatbot__panel {
    left: 0;
    transform-origin: bottom left;
}

.agora-chatbot.is-open .agora-chatbot__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ─── Header ─────────────────────────────────────────────────────── */
.agora-chatbot__header {
    background: linear-gradient(135deg, var(--agora-primary) 0%, var(--agora-primary-light) 100%);
    color: var(--agora-text);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.agora-chatbot__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agora-chatbot__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agora-accent) 0%, var(--agora-accent-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #ffffff;
    flex-shrink: 0;
}

.agora-chatbot__header-text {
    display: flex;
    flex-direction: column;
}

.agora-chatbot__header-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.agora-chatbot__header-subtitle {
    font-size: 12px;
    opacity: 0.75;
}

.agora-chatbot__close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--agora-transition);
}

.agora-chatbot__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.agora-chatbot__close svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

/* ─── Messages Area ──────────────────────────────────────────────── */
.agora-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--agora-bg-messages);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.agora-chatbot__messages::-webkit-scrollbar {
    width: 5px;
}

.agora-chatbot__messages::-webkit-scrollbar-track {
    background: transparent;
}

.agora-chatbot__messages::-webkit-scrollbar-thumb {
    background: #c5c9d2;
    border-radius: 10px;
}

/* ─── Message Bubbles ────────────────────────────────────────────── */
.agora-chatbot__message {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: var(--agora-radius-msg);
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: agora-message-in 0.3s ease-out;
    line-height: 1.5;
    font-size: 13.5px;
}

@keyframes agora-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bot messages */
.agora-chatbot__message--bot {
    align-self: flex-start;
    background: var(--agora-bg-bot-msg);
    color: var(--agora-text-dark);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* User messages */
.agora-chatbot__message--user {
    align-self: flex-end;
    background: var(--agora-bg-user-msg);
    color: var(--agora-text);
    border-bottom-right-radius: 6px;
}

/* Links inside bot messages */
.agora-chatbot__message--bot a {
    color: #b71c1c;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.agora-chatbot__message--bot a:hover {
    color: #d32f2f;
}

/* Error messages */
.agora-chatbot__message--error {
    align-self: center;
    max-width: 90%;
    background: #fef3f2;
    color: #b42318;
    border-radius: var(--agora-radius-sm);
    font-size: 12.5px;
    text-align: center;
    border: 1px solid #fecdca;
}

/* ─── Typing Indicator ───────────────────────────────────────────── */
.agora-chatbot__typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 18px;
    background: var(--agora-bg-bot-msg);
    border-radius: var(--agora-radius-msg);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    animation: agora-message-in 0.3s ease-out;
}

.agora-chatbot__typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9da3ad;
    animation: agora-typing-bounce 1.4s ease-in-out infinite;
}

.agora-chatbot__typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.agora-chatbot__typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes agora-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ─── Input Area ─────────────────────────────────────────────────── */
.agora-chatbot__input-area {
    padding: 12px 16px 10px;
    background: var(--agora-bg-chat);
    border-top: 1px solid var(--agora-border);
    flex-shrink: 0;
}

.agora-chatbot__form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--agora-bg-messages);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    border: 1px solid var(--agora-border);
    transition: border-color var(--agora-transition), box-shadow var(--agora-transition);
}

.agora-chatbot__form:focus-within {
    border-color: var(--agora-accent);
    box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.15);
}

.agora-chatbot__input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-family: var(--agora-font);
    color: var(--agora-text-dark);
    padding: 8px 0;
    min-width: 0;
}

.agora-chatbot__input::placeholder {
    color: #9da3ad;
}

.agora-chatbot__send {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agora-primary) 0%, var(--agora-primary-light) 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--agora-transition), opacity var(--agora-transition);
}

.agora-chatbot__send:hover {
    transform: scale(1.05);
}

.agora-chatbot__send:active {
    transform: scale(0.92);
}

.agora-chatbot__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.agora-chatbot__send svg {
    width: 16px;
    height: 16px;
    color: #ffffff;
    margin-left: 2px;
}

.agora-chatbot__powered-by {
    text-align: center;
    font-size: 10.5px;
    color: #9da3ad;
    margin-top: 8px;
    letter-spacing: 0.3px;
}

.agora-chatbot__disclaimer {
    text-align: center;
    font-size: 9.5px;
    color: #b0b5bd;
    margin-top: 3px;
    line-height: 1.3;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .agora-chatbot {
        bottom: 16px;
    }

    .agora-chatbot--right {
        right: 16px;
    }

    .agora-chatbot--left {
        left: 16px;
    }

    .agora-chatbot__panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        bottom: 72px;
    }

    .agora-chatbot--right .agora-chatbot__panel {
        right: 0;
    }

    .agora-chatbot--left .agora-chatbot__panel {
        left: 0;
    }

    .agora-chatbot__toggle {
        width: 54px;
        height: 54px;
    }

    .agora-chatbot__icon {
        width: 24px;
        height: 24px;
    }
}
