/**
 * CSBAG Budget Dashboard - AI Chatbot Widget Styles
 *
 * Floating chatbot widget with smooth animations
 * Mobile-responsive design
 * Brand colors: CSBAG Orange #f36624
 */

/* Google Fonts - Roboto */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap');

/* ============================================================================
   GLOBAL CHATBOT STYLES
   ============================================================================ */

.csbag-chatbot-panel,
.csbag-chatbot-bubble,
.csbag-chatbot-input,
.csbag-chatbot-suggestion {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================================
   CHATBOT FLOATING BUTTON
   ============================================================================ */

.csbag-chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: auto;
    height: 52px;
    padding: 0 20px 0 16px;
    border-radius: 26px;
    background: linear-gradient(135deg, #f36624 0%, #d15418 100%);
    box-shadow: 0 4px 12px rgba(243, 102, 36, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    border: none;
}

.csbag-chatbot-button:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 16px rgba(243, 102, 36, 0.5);
}

.csbag-chatbot-button:active {
    transform: scale(0.98);
}

.csbag-chatbot-button svg {
    width: 24px;
    height: 24px;
    color: white;
    flex-shrink: 0;
}

.csbag-chatbot-button-text {
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.csbag-chatbot-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* Notification badge */
.csbag-chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #F1416C;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.csbag-chatbot-badge.show {
    display: flex;
}

/* ============================================================================
   CHATBOT PANEL
   ============================================================================ */

.csbag-chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    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);
    z-index: 9999;
    overflow: hidden;
}

.csbag-chatbot-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.csbag-chatbot-header {
    background: linear-gradient(135deg, #f36624 0%, #d15418 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
}

.csbag-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.csbag-chatbot-header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.csbag-chatbot-header-icon svg {
    width: 20px;
    height: 20px;
}

.csbag-chatbot-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.csbag-chatbot-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0 0;
}

.csbag-chatbot-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;
}

.csbag-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.csbag-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #F9FAFB;
}

.csbag-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.csbag-chatbot-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

/* Message Bubble */
.csbag-chatbot-message {
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.csbag-chatbot-message.user {
    display: flex;
    justify-content: flex-end;
}

.csbag-chatbot-message.bot {
    display: flex;
    justify-content: flex-start;
}

.csbag-chatbot-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.csbag-chatbot-message.user .csbag-chatbot-bubble {
    background: #f36624;
    color: white;
    border-bottom-right-radius: 4px;
}

.csbag-chatbot-message.bot .csbag-chatbot-bubble {
    background: white;
    color: #1F2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Formatted Text within Bubbles */
.csbag-chatbot-bubble strong {
    font-weight: 600;
    color: #111827;
}

.csbag-chatbot-bubble em {
    font-style: italic;
    color: #374151;
}

.csbag-chatbot-bubble ol,
.csbag-chatbot-bubble ul {
    margin: 8px 0;
    padding-left: 24px;
}

.csbag-chatbot-bubble ol {
    list-style-type: decimal;
}

.csbag-chatbot-bubble ul {
    list-style-type: disc;
}

.csbag-chatbot-bubble li {
    margin: 4px 0;
    line-height: 1.6;
}

.csbag-chatbot-bubble br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* User bubble - different colors for formatted text */
.csbag-chatbot-message.user .csbag-chatbot-bubble strong {
    font-weight: 600;
    color: white;
}

.csbag-chatbot-message.user .csbag-chatbot-bubble em {
    font-style: italic;
    color: rgba(255, 255, 255, 0.95);
}

/* Typing Indicator */
.csbag-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.csbag-chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

.csbag-chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.csbag-chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* SQL Query Display */
.csbag-chatbot-sql {
    background: #1F2937;
    color: #10B981;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-top: 8px;
    overflow-x: auto;
}

/* Data Table */
.csbag-chatbot-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.csbag-chatbot-table th {
    background: #F3F4F6;
    padding: 8px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #6B7280;
}

.csbag-chatbot-table td {
    padding: 8px;
    border-top: 1px solid #E5E7EB;
}

/* Error Message */
.csbag-chatbot-error {
    background: #FEF2F2;
    color: #DC2626;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #DC2626;
    margin-top: 8px;
    font-size: 13px;
}

/* Input Container */
.csbag-chatbot-input-container {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    align-items: center;
}

.csbag-chatbot-input {
    flex: 1;
    border: 1px solid #D1D5DB;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.csbag-chatbot-input:focus {
    border-color: #f36624;
}

.csbag-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f36624;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.csbag-chatbot-send:hover {
    background: #d15418;
    transform: scale(1.05);
}

.csbag-chatbot-send:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
    transform: scale(1);
}

.csbag-chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Welcome Message */
.csbag-chatbot-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #6B7280;
}

.csbag-chatbot-welcome-icon {
    width: 60px;
    height: 60px;
    background: #f36624;
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.csbag-chatbot-welcome-icon svg {
    width: 30px;
    height: 30px;
}

.csbag-chatbot-welcome h3 {
    font-size: 18px;
    color: #1F2937;
    margin: 0 0 8px 0;
}

.csbag-chatbot-welcome p {
    font-size: 14px;
    margin: 0 0 20px 0;
}

.csbag-chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 300px;
    margin: 0 auto;
}

.csbag-chatbot-suggestion {
    background: white;
    border: 1px solid #E5E7EB;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    text-align: left;
}

.csbag-chatbot-suggestion:hover {
    border-color: #f36624;
    background: #FFF4F0;
    transform: translateX(4px);
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .csbag-chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .csbag-chatbot-header {
        border-radius: 0;
    }

    .csbag-chatbot-button {
        bottom: 16px;
        right: 16px;
        height: 48px;
        padding: 0 16px 0 12px;
        gap: 8px;
    }

    .csbag-chatbot-button-text {
        font-size: 14px;
    }

    .csbag-chatbot-button svg {
        width: 20px;
        height: 20px;
    }

    .csbag-chatbot-bubble {
        max-width: 85%;
    }
}
