/**
 * Blog AI Chat Widget Styles
 * Modern, responsive design with smooth animations
 */

:root {
    --bac-primary-color: #2563eb;
    --bac-secondary-color: #1e40af;
    --bac-text-color: #1f2937;
    --bac-background-color: #ffffff;
    --bac-font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bac-border-radius: 12px;
    --bac-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --bac-shadow-hover: 0 15px 50px rgba(0, 0, 0, 0.2);
}

/* Floating Widget */
.bac-floating-widget {
    position: fixed;
    z-index: 999999;
    font-family: var(--bac-font-family);
}

.bac-floating-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.bac-floating-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

.bac-floating-widget[data-position="top-right"] {
    top: 20px;
    right: 20px;
}

.bac-floating-widget[data-position="top-left"] {
    top: 20px;
    left: 20px;
}

/* Toggle Button */
.bac-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bac-primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--bac-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bac-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--bac-shadow-hover);
}

.bac-toggle-btn svg {
    width: 28px;
    height: 28px;
}

.bac-icon-close {
    display: none;
}

.bac-floating-widget.bac-open .bac-icon-chat {
    display: none;
}

.bac-floating-widget.bac-open .bac-icon-close {
    display: block;
}

/* Chat Panel */
.bac-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bac-background-color);
    border-radius: var(--bac-border-radius);
    box-shadow: var(--bac-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bac-floating-widget.bac-open .bac-chat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat Header */
.bac-chat-header {
    padding: 10px 20px;
    background: var(--bac-primary-color);
    color: white;
    border-radius: var(--bac-border-radius) var(--bac-border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bac-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bac-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.bac-avatar-default {
    background: var(--bac-primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.bac-bubble-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.bac-brand-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.bac-status {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.bac-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.bac-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bac-close-btn svg {
    width: 20px;
    height: 20px;
}

/* Chat Body */
.bac-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.bac-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages */
.bac-message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
}

.bac-message-avatar.bac-avatar-default {
    background: var(--bac-primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.bac-message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-out;
}

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

.bac-message-assistant {
    align-self: flex-start;
}

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

.bac-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.bac-message-content {
    max-width: 75%;
}

.bac-message-text {
    padding: 12px 16px;
    border-radius: var(--bac-border-radius);
    line-height: 1.5;
    font-size: 14px;
    /* Ensure padding is respected */
    box-sizing: border-box;
    display: block;
    text-align: left;
}

.bac-message-assistant .bac-message-text {
    background: #f3f4f6;
    color: var(--bac-text-color);
}

.bac-message-user .bac-message-text {
    background: var(--bac-primary-color);
    color: white;
    font-weight: 500;
    padding: 12px 16px !important;
    text-align: left;
    word-wrap: break-word;
}

/* Citations */
.bac-citations {
    margin-top: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.bac-citations-label {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bac-citations-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bac-citations-list li {
    font-size: 13px;
}

.bac-citations-list a {
    color: var(--bac-primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.bac-citations-list a:hover {
    color: var(--bac-secondary-color);
    text-decoration: underline;
}

/* Loading Indicator */
.bac-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.bac-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Suggested Prompts */
.bac-suggested-prompts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.bac-prompt-btn {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    color: var(--bac-text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.bac-prompt-btn:hover {
    border-color: var(--bac-primary-color);
    background: #f9fafb;
    transform: translateX(4px);
}

/* Chat Footer */
.bac-chat-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

.bac-privacy-notice {
    margin: 0 0 12px 0;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

.bac-input-form {
    display: flex;
    gap: 8px;
}

.bac-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: var(--bac-border-radius);
    font-size: 14px;
    font-family: var(--bac-font-family);
    outline: none;
    transition: border-color 0.2s;
}

.bac-input:focus {
    border-color: var(--bac-primary-color);
}

.bac-send-btn {
    padding: 12px;
    background: var(--bac-primary-color);
    border: none;
    border-radius: var(--bac-border-radius);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.bac-send-btn:hover {
    background: var(--bac-secondary-color);
    transform: translateY(-2px);
}

.bac-send-btn svg {
    width: 20px;
    height: 20px;
}

.bac-powered-by {
    margin: 8px 0 0 0;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
}

/* Inline Chat */
.bac-inline-chat {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bac-background-color);
    border: 1px solid #e5e7eb;
    border-radius: var(--bac-border-radius);
    overflow: hidden;
}

.bac-inline-chat .bac-chat-body {
    flex: 1;
}

.bac-inline-chat .bac-chat-footer {
    padding: 16px;
}

.bac-inline-container {
    margin: 20px 0;
}

.bac-inline-header {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.bac-inline-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--bac-text-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Full screen on mobile for ALL positions */
    .bac-floating-widget .bac-chat-panel {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    
    .bac-floating-widget.bac-open .bac-chat-panel {
        transform: none !important;
    }
    
    /* No border-radius on header/footer on mobile */
    .bac-chat-header {
        border-radius: 0 !important;
    }
    
    .bac-toggle-btn {
        width: 56px;
        height: 56px;
    }
    
    .bac-message-content {
        max-width: 85%;
    }
}

/* Scrollbar Styling */
.bac-messages::-webkit-scrollbar {
    width: 6px;
}

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

.bac-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.bac-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
