/* ==========================================================================
   AptSoft Chatbot - Scoped Stylesheet (Gradient Theme)
   ========================================================================== */

:root {
    --apt-cb-primary: #be123c; /* Base fallback */
    --apt-cb-gradient: linear-gradient(135deg, #be123c, #6d28d9);
    --apt-cb-bg: #ffffff;
    --apt-cb-text: #1f2937;
    --apt-cb-text-light: #6b7280;
    --apt-cb-border: #e5e7eb;
    --apt-cb-user-msg: #6d28d9;
    --apt-cb-bot-msg: #f3f4f6;
    --apt-cb-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --apt-cb-radius: 12px;
    --apt-cb-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Floating Toggle Button */
.apt-cb-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--apt-cb-shadow);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.apt-cb-toggle:hover, .apt-cb-toggle:focus {
    transform: scale(1.05);
    opacity: 0.95;
    outline: none;
}

.apt-cb-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: opacity 0.2s ease;
}

/* Chat Window */
.apt-cb-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 360px;
    max-height: 600px;
    height: calc(100vh - 120px);
    background-color: var(--apt-cb-bg);
    border-radius: var(--apt-cb-radius);
    box-shadow: var(--apt-cb-shadow);
    display: flex;
    flex-direction: column;
    z-index: 99998;
    font-family: var(--apt-cb-font);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid var(--apt-cb-border);
}

.apt-cb-window.apt-cb-active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Header */
.apt-cb-header {
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: var(--apt-cb-radius);
    border-top-right-radius: var(--apt-cb-radius);
}

.apt-cb-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.apt-cb-header-title::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    background-color: #4ade80; /* Online indicator */
    border-radius: 50%;
}

.apt-cb-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apt-cb-close:hover {
    opacity: 1;
}

/* Chat Area */
.apt-cb-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #fafafa;
}

/* Scrollbar styling */
.apt-cb-body::-webkit-scrollbar { width: 6px; }
.apt-cb-body::-webkit-scrollbar-track { background: transparent; }
.apt-cb-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.apt-cb-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: apt-cb-fade-in 0.3s ease;
}

@keyframes apt-cb-fade-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.apt-cb-msg p { margin: 0 0 8px 0; }
.apt-cb-msg p:last-child { margin: 0; }
.apt-cb-msg ul { margin: 0; padding-left: 20px; }

.apt-cb-msg-bot {
    background-color: var(--apt-cb-bot-msg);
    color: var(--apt-cb-text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.apt-cb-msg-user {
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* Suggestions Chips */
.apt-cb-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.apt-cb-chip {
    background: white;
    border: 1px solid var(--apt-cb-border);
    color: #6d28d9;
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apt-cb-chip:hover {
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white;
    border-color: transparent;
}

/* Input Area */
.apt-cb-footer {
    padding: 12px 16px;
    background-color: white;
    border-top: 1px solid var(--apt-cb-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.apt-cb-input {
    flex: 1;
    border: 1px solid var(--apt-cb-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--apt-cb-font);
    resize: none;
    max-height: 100px;
    min-height: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.apt-cb-input:focus {
    border-color: #6d28d9;
}

.apt-cb-send {
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.apt-cb-send:hover:not(:disabled) {
    opacity: 0.9;
}

.apt-cb-send:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
}

.apt-cb-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Typing Indicator */
.apt-cb-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background-color: var(--apt-cb-bot-msg);
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
}

.apt-cb-dot {
    width: 6px;
    height: 6px;
    background-color: var(--apt-cb-text-light);
    border-radius: 50%;
    animation: apt-cb-bounce 1.4s infinite ease-in-out both;
}

.apt-cb-dot:nth-child(1) { animation-delay: -0.32s; }
.apt-cb-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes apt-cb-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Dynamic CTA Button inside chat */
.apt-cb-cta-btn {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, #be123c, #6d28d9) !important;
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.apt-cb-cta-btn:hover {
    opacity: 0.9;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .apt-cb-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: none;
        z-index: 999999;
    }
    .apt-cb-header {
        border-radius: 0;
    }
    .apt-cb-toggle {
        bottom: 20px;
        right: 20px;
    }
}