/**
 * AI Assistant Chat Widget Styles
 * For Sangguniang Panlungsod Minutes Search
 * Supports: English, Tagalog, Bisaya
 */

/* ============================================
   AI Chat Button (Floating)
   ============================================ */
.ai-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
}

.ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(37, 99, 235, 0.5);
}

.ai-chat-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.ai-chat-button .chat-icon {
    display: block;
}

.ai-chat-button .close-icon {
    display: none;
}

.ai-chat-button.active .chat-icon {
    display: none;
}

.ai-chat-button.active .close-icon {
    display: block;
}

/* Pulse animation for attention */
.ai-chat-button::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    70% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ============================================
   AI Chat Widget Container
   ============================================ */
.ai-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.ai-chat-widget.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* ============================================
   Chat Header
   ============================================ */
.ai-chat-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.ai-chat-header-info {
    flex: 1;
}

.ai-chat-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.ai-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Chat Messages Area
   ============================================ */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
}

.ai-chat-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-message.assistant {
    align-self: flex-start;
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-chat-message.user .ai-message-avatar {
    background: #e0e7ff;
    color: #3730a3;
}

.ai-chat-message.assistant .ai-message-avatar {
    background: #2563eb;
    color: white;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.ai-chat-message.user .ai-message-content {
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant .ai-message-content {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Typing indicator */
.ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ============================================
   Welcome Screen
   ============================================ */
.ai-chat-welcome {
    text-align: center;
    padding: 30px 20px;
}

.ai-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ai-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.ai-welcome-text {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 20px;
}

/* Quick action buttons */
.ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0 10px;
}

.ai-quick-action {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quick-action:hover {
    background: #f1f5f9;
    border-color: #2563eb;
    color: #2563eb;
}

/* ============================================
   Chat Input Area
   ============================================ */
.ai-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.ai-chat-disclaimer {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 12px;
    font-style: italic;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.ai-chat-input:focus {
    border-color: #2563eb;
}

.ai-chat-input::placeholder {
    color: #94a3b8;
}

.ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover:not(:disabled) {
    background: #1d4ed8;
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.ai-chat-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ============================================
   Language Selector
   ============================================ */
.ai-language-selector {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}

.ai-lang-btn {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-lang-btn:hover {
    background: #f1f5f9;
}

.ai-lang-btn.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .ai-chat-button {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }

    .ai-quick-actions {
        flex-direction: column;
    }

    .ai-quick-action {
        width: 100%;
    }
}

/* ============================================
   Message Content Formatting
   ============================================ */
.ai-message-content ul,
.ai-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-message-content li {
    margin: 4px 0;
}

.ai-message-content strong {
    font-weight: 600;
}

.ai-message-content p {
    margin: 8px 0;
}

.ai-message-content p:first-child {
    margin-top: 0;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

/* Document reference links */
.ai-message-content .doc-link {
    display: inline-block;
    background: #e0e7ff;
    color: #3730a3;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin: 4px 4px 4px 0;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-message-content .doc-link:hover {
    background: #c7d2fe;
}

/* Keyword highlight - yellow shading for search matches */
.ai-keyword-highlight {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.2);
}

/* Enhanced highlight for exact phrase matches */
.ai-phrase-highlight,
.ai-keyword-highlight.exact-phrase {
    background: linear-gradient(135deg, #fef08a 0%, #facc15 100%);
    color: #713f12;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(234, 179, 8, 0.3);
    border: 1px solid rgba(234, 179, 8, 0.4);
}

/* Animation for highlighted text */
.ai-keyword-highlight,
.ai-phrase-highlight {
    transition: all 0.2s ease;
}

.ai-keyword-highlight:hover,
.ai-phrase-highlight:hover {
    background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
    transform: scale(1.02);
}

/* Error message styling */
.ai-message-error {
    background: #fef2f2 !important;
    border: 1px solid #fecaca;
}

.ai-message-error .ai-message-content {
    color: #991b1b;
}
