/**
 * AfroAI Chat Widget - Base Styles
 * Additional styles are injected dynamically based on configuration
 */

/* Reset and base styles */
.afroai-widget-button,
.afroai-chat-window,
.afroai-chat-window * {
    box-sizing: border-box;
}

/* Ensure widget elements are above other content */
.afroai-widget-button {
    z-index: 999999 !important;
}

.afroai-chat-window {
    z-index: 1000000 !important;
}

/* Smooth transitions */
.afroai-chat-window {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.afroai-chat-window:not(.open) {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.afroai-chat-window.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

/* Scrollbar styling for messages */
.afroai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.afroai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.afroai-chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.afroai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .afroai-chat-window {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
    }

    .afroai-chat-header {
        border-radius: 0 !important;
    }
}

/* Header Actions */
.afroai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.afroai-chat-maximize,
.afroai-chat-close {
    border-radius: 4px;
    transition: background-color 0.2s;
}

.afroai-chat-maximize:hover,
.afroai-chat-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Maximized State */
.afroai-chat-window.maximized {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    right: 20px !important;
    bottom: 20px !important;
    width: calc(100vw - 40px) !important;
    height: calc(100vh - 40px) !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 12px !important;
    z-index: 1000001 !important;
}

/* Accessibility */
.afroai-widget-button:focus,
.afroai-chat-input input:focus,
.afroai-chat-input button:focus,
.afroai-chat-maximize:focus,
.afroai-chat-close:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* HTML Content Styling in Messages */
.afroai-message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    background: white;
}

.afroai-message-bubble table th,
.afroai-message-bubble table td {
    padding: 6px 8px;
    text-align: left;
    border: 1px solid #d1d5db;
}

.afroai-message-bubble table th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.afroai-message-bubble table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.afroai-message-bubble table tbody tr:hover {
    background-color: #f3f4f6;
}

.afroai-message-bubble p {
    margin: 4px 0;
}

.afroai-message-bubble ul,
.afroai-message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.afroai-message-bubble li {
    margin: 4px 0;
}

.afroai-message-bubble h1,
.afroai-message-bubble h2,
.afroai-message-bubble h3,
.afroai-message-bubble h4,
.afroai-message-bubble h5,
.afroai-message-bubble h6 {
    margin: 8px 0 4px 0;
    font-weight: 600;
}

.afroai-message-bubble h1 { font-size: 18px; }
.afroai-message-bubble h2 { font-size: 16px; }
.afroai-message-bubble h3 { font-size: 15px; }
.afroai-message-bubble h4 { font-size: 14px; }
.afroai-message-bubble h5 { font-size: 13px; }
.afroai-message-bubble h6 { font-size: 12px; }

.afroai-message-bubble strong,
.afroai-message-bubble b {
    font-weight: 600;
}

.afroai-message-bubble em,
.afroai-message-bubble i {
    font-style: italic;
}

.afroai-message-bubble code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.afroai-message-bubble pre {
    background: #f3f4f6;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.afroai-message-bubble pre code {
    background: none;
    padding: 0;
}

.afroai-message-bubble blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 12px;
    margin: 8px 0;
    color: #6b7280;
}

.afroai-message-bubble a {
    color: #2563eb;
    text-decoration: underline;
}

.afroai-message-bubble a:hover {
    color: #1e40af;
}

.afroai-message-bubble.afroai-streaming {
    position: relative;
}

/* Print styles */
@media print {
    .afroai-widget-button,
    .afroai-chat-window {
        display: none !important;
    }
}
