/* AI Chatbot Pro - Frontend Widget Styles */

.aicbp-widget {
    --aicbp-primary: #4F46E5;
    --aicbp-primary-dark: #4338CA;
    --aicbp-bg: #ffffff;
    --aicbp-text: #1F2937;
    --aicbp-muted: #6B7280;
    --aicbp-border: #E5E7EB;
    --aicbp-user-bg: #4F46E5;
    --aicbp-bot-bg: #F3F4F6;

    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--aicbp-text);
}

.aicbp-widget * {
    box-sizing: border-box;
}

.aicbp-bottom-right {
    bottom: 20px;
    right: 20px;
}
.aicbp-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Launcher button */
.aicbp-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aicbp-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}
.aicbp-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
.aicbp-launcher:focus {
    outline: 3px solid rgba(79, 70, 229, 0.4);
    outline-offset: 2px;
}

/* Chat window */
.aicbp-window {
    display: none;
    position: absolute;
    bottom: 78px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--aicbp-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    flex-direction: column;
    animation: aicbp-slide-up 0.25s ease-out;
}
.aicbp-bottom-right .aicbp-window { right: 0; }
.aicbp-bottom-left  .aicbp-window { left: 0; }

.aicbp-widget.aicbp-open .aicbp-window { display: flex; }

@keyframes aicbp-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.aicbp-header {
    background: var(--aicbp-primary);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.aicbp-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.aicbp-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.aicbp-title {
    font-weight: 600;
    font-size: 16px;
}
.aicbp-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}
.aicbp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22C55E;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
    animation: aicbp-pulse 2s infinite;
}
@keyframes aicbp-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}
.aicbp-minimize {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
}
.aicbp-minimize:hover {
    background: rgba(255,255,255,0.15);
}

/* Messages area */
.aicbp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: #FAFAFA;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.aicbp-messages::-webkit-scrollbar {
    width: 6px;
}
.aicbp-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 3px;
}

.aicbp-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: aicbp-fade-in 0.2s ease;
}
@keyframes aicbp-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aicbp-msg-bot {
    background: var(--aicbp-bot-bg);
    color: var(--aicbp-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.aicbp-msg-user {
    background: var(--aicbp-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.aicbp-msg-error {
    background: #FEE2E2;
    color: #991B1B;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.aicbp-msg p {
    margin: 0 0 6px 0;
}
.aicbp-msg p:last-child {
    margin-bottom: 0;
}
.aicbp-msg a {
    color: inherit;
    text-decoration: underline;
}

/* Sources list */
.aicbp-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
    font-size: 12px;
}
.aicbp-sources-label {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--aicbp-muted);
}
.aicbp-sources a {
    display: block;
    color: var(--aicbp-primary);
    text-decoration: none;
    padding: 2px 0;
}
.aicbp-sources a:hover {
    text-decoration: underline;
}

/* Typing indicator */
.aicbp-typing {
    align-self: flex-start;
    background: var(--aicbp-bot-bg);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    margin: 0 16px 12px 16px;
    display: inline-flex;
    gap: 4px;
    width: fit-content;
}
.aicbp-typing span {
    width: 8px;
    height: 8px;
    background: var(--aicbp-muted);
    border-radius: 50%;
    animation: aicbp-bounce 1.4s infinite ease-in-out;
}
.aicbp-typing span:nth-child(1) { animation-delay: -0.32s; }
.aicbp-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes aicbp-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* Input form */
.aicbp-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--aicbp-border);
    background: #fff;
    flex-shrink: 0;
}
.aicbp-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--aicbp-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    color: var(--aicbp-text);
    background: #fff;
}
.aicbp-input:focus {
    border-color: var(--aicbp-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.aicbp-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aicbp-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.aicbp-send:hover:not(:disabled) {
    filter: brightness(0.9);
}
.aicbp-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
.aicbp-footer {
    text-align: center;
    padding: 6px 0;
    font-size: 11px;
    color: var(--aicbp-muted);
    background: #fff;
    border-top: 1px solid var(--aicbp-border);
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .aicbp-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
    .aicbp-bottom-right, .aicbp-bottom-left {
        bottom: 15px;
    }
    .aicbp-bottom-right { right: 15px; }
    .aicbp-bottom-left  { left: 15px; }
}
