/* ==========================================================================
   ArtGallery Chatbot Widget Styles
   ========================================================================== */

/* ---- Variables ---- */
.ag-chatbot {
    --chat-primary: #1a1a2e;
    --chat-accent: #e94560;
    --chat-accent-hover: #c73652;
    --chat-bg: #ffffff;
    --chat-bg-light: #f8f8f8;
    --chat-text: #2d2d2d;
    --chat-text-light: #6b6b6b;
    --chat-border: #e5e5e5;
    --chat-user-bubble: #1a1a2e;
    --chat-bot-bubble: #f0f0f5;
    --chat-radius: 12px;
    --chat-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    --chat-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Container ---- */
.ag-chatbot {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--chat-text);
}

.ag-chat-right {
    right: 24px;
}

.ag-chat-left {
    left: 24px;
}

/* ---- Toggle Button ---- */
.ag-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
    cursor: pointer;
    border: none;
    transition: all var(--chat-transition);
    position: relative;
}

.ag-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(233, 69, 96, 0.5);
}

.ag-chat-toggle:active {
    transform: scale(0.95);
}

.ag-chat-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition);
}

.ag-chat-toggle-close {
    display: none;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
}

.ag-toggle-active .ag-chat-toggle-icon {
    display: none;
}

.ag-toggle-active .ag-chat-toggle-close {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Notification badge */
.ag-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #22c55e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: ag-badge-pulse 2s ease infinite;
}

@keyframes ag-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ---- Chat Window ---- */
.ag-chat-window {
    position: absolute;
    bottom: 72px;
    width: 380px;
    max-height: 600px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all var(--chat-transition);
}

.ag-chat-right .ag-chat-window {
    right: 0;
}

.ag-chat-left .ag-chat-window {
    left: 0;
}

.ag-chat-open {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}

/* ---- Header ---- */
.ag-chat-header {
    background: var(--chat-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ag-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ag-chat-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ag-chat-title {
    font-weight: 600;
    font-size: 15px;
}

.ag-chat-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ag-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: ag-status-blink 3s ease infinite;
}

@keyframes ag-status-blink {
    0%, 90%, 100% { opacity: 1; }
    95% { opacity: 0.3; }
}

.ag-chat-minimize {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.ag-chat-minimize:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ---- Quick Actions ---- */
.ag-chat-quick-actions {
    padding: 12px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-bg-light);
}

.ag-quick-btn {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--chat-text-light);
    background: #fff;
    border: 1px solid var(--chat-border);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ag-quick-btn:hover {
    border-color: var(--chat-accent);
    color: var(--chat-accent);
    background: rgba(233, 69, 96, 0.05);
}

/* ---- Messages Area ---- */
.ag-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    scroll-behavior: smooth;
}

.ag-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ag-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ag-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

/* ---- Message Bubbles ---- */
.ag-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: ag-message-in 0.3s ease;
}

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

.ag-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ag-message-bot {
    align-self: flex-start;
}

.ag-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ag-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.ag-message-user .ag-message-bubble {
    background: var(--chat-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ag-message-bot .ag-message-bubble {
    background: var(--chat-bot-bubble);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.ag-message-bubble strong {
    font-weight: 600;
}

.ag-message-bubble br {
    display: block;
    margin: 2px 0;
}

/* Source labels */
.ag-source-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.ag-source-ai {
    background: #ede9fe;
    color: #7c3aed;
}

.ag-source-wc {
    background: #ecfdf5;
    color: #059669;
}

/* ---- Typing Indicator ---- */
.ag-chat-typing {
    padding: 0 16px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ag-typing-bubble {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--chat-bot-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.ag-typing-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: ag-typing-dot 1.4s ease infinite;
}

.ag-typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.ag-typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ---- Escalation Buttons ---- */
.ag-escalation-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    animation: ag-message-in 0.3s ease;
}

.ag-escalate-btn {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    border: 1px solid var(--chat-border);
    background: #fff;
    color: var(--chat-text);
}

.ag-escalate-btn:hover {
    transform: translateX(4px);
}

.ag-escalate-ai:hover {
    border-color: #7c3aed;
    color: #7c3aed;
    background: #faf5ff;
}

.ag-escalate-human:hover {
    border-color: #059669;
    color: #059669;
    background: #ecfdf5;
}

.ag-escalate-email:hover {
    border-color: var(--chat-accent);
    color: var(--chat-accent);
    background: rgba(233, 69, 96, 0.05);
}

/* ---- Input Area ---- */
.ag-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-bg);
}

.ag-chat-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: var(--chat-bg-light);
    color: var(--chat-text);
}

.ag-chat-input:focus {
    border-color: var(--chat-accent);
    background: #fff;
}

.ag-chat-input:disabled {
    opacity: 0.5;
}

.ag-chat-input::placeholder {
    color: #aaa;
}

.ag-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ag-chat-send:hover {
    background: var(--chat-accent-hover);
    transform: scale(1.05);
}

.ag-chat-send:active {
    transform: scale(0.95);
}

/* ---- Footer ---- */
.ag-chat-footer {
    text-align: center;
    padding: 6px 12px;
    font-size: 10.5px;
    color: var(--chat-text-light);
    background: var(--chat-bg-light);
    border-top: 1px solid var(--chat-border);
    opacity: 0.7;
}

.ag-chat-footer strong {
    color: var(--chat-text);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 480px) {
    .ag-chatbot {
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
    }

    .ag-chat-toggle {
        position: fixed;
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .ag-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-height: 100vh;
        border-radius: 0;
    }

    .ag-chat-messages {
        max-height: calc(100vh - 180px);
    }
}

/* ---- Print ---- */
@media print {
    .ag-chatbot {
        display: none !important;
    }
}
