/* ==========================================================================
   LitsEdu AI Assistant - Design System & Widget Styles
   ========================================================================== */

:root {
    --ai-teal: #0ca6a3;
    --ai-teal-dark: #087f7d;
    --ai-teal-light: rgba(12, 166, 163, 0.1);
    --ai-orange: #dd642b;
    --ai-dark: #1e293b;
    --ai-gray: #64748b;
    --ai-light: #f8fafc;
    --ai-border: #e2e8f0;
    --ai-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
    --ai-radius: 16px;
    --ai-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   Floating Launcher Button
   -------------------------------------------------------------------------- */
.ai-widget-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-teal), var(--ai-teal-dark));
    color: #ffffff;
    border: none;
    outline: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(12, 166, 163, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 99999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-widget-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 30px rgba(12, 166, 163, 0.45);
}

.ai-widget-launcher .ai-launcher-icon-close {
    display: none;
    font-size: 22px;
}

.ai-widget-launcher.open {
    background: var(--ai-dark);
    box-shadow: 0 8px 24px rgba(30, 41, 59, 0.35);
}

.ai-widget-launcher.open .ai-launcher-icon-chat {
    display: none;
}

.ai-widget-launcher.open .ai-launcher-icon-close {
    display: block;
}

/* Badge Indicator */
.ai-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

/* --------------------------------------------------------------------------
   Floating Chat Container Window
   -------------------------------------------------------------------------- */
.ai-widget-container {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--ai-font);
}

.ai-widget-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.ai-widget-header {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-teal), var(--ai-teal-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(12, 166, 163, 0.3);
}

.ai-title-box h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #ffffff;
}

.ai-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.ai-status-dot {
    width: 7px;
    height: 7px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #cbd5e1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   Messages Body
   -------------------------------------------------------------------------- */
.ai-widget-body {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.ai-widget-body::-webkit-scrollbar {
    width: 5px;
}
.ai-widget-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Message Item */
.ai-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: aiMsgFadeIn 0.3s ease forwards;
}

@keyframes aiMsgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.bot {
    align-self: flex-start;
}

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ai-teal);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    position: relative;
    word-break: break-word;
}

.ai-message.bot .ai-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.ai-message.user .ai-msg-bubble {
    background: linear-gradient(135deg, var(--ai-teal), var(--ai-teal-dark));
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(12, 166, 163, 0.25);
}

/* Quick Suggestion Pills */
.ai-suggestions-wrapper {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-suggestion-pill {
    background: #ffffff;
    border: 1px solid rgba(12, 166, 163, 0.3);
    color: var(--ai-teal-dark);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-suggestion-pill:hover {
    background: var(--ai-teal);
    color: #ffffff;
    border-color: var(--ai-teal);
    transform: translateY(-1px);
}

/* Typing Indicator Animation */
.ai-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-top-left-radius: 4px;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiTypingBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; background: var(--ai-teal); }
}

/* --------------------------------------------------------------------------
   Input Footer
   -------------------------------------------------------------------------- */
.ai-widget-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.ai-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: all 0.2s ease;
}

.ai-input-form:focus-within {
    border-color: var(--ai-teal);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(12, 166, 163, 0.15);
}

.ai-chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13.5px;
    color: #1e293b;
    padding: 8px 0;
    font-family: inherit;
}

.ai-chat-input::placeholder {
    color: #94a3b8;
}

.ai-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ai-teal);
    color: #ffffff;
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: var(--ai-teal-dark);
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.ai-footer-credit {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    margin-top: 6px;
}

/* --------------------------------------------------------------------------
   Markdown Formatted Output inside .ai-response
   -------------------------------------------------------------------------- */
.ai-response {
    font-size: 13.5px;
    line-height: 1.6;
    color: #1e293b;
}

.ai-response .ai-heading {
    margin: 12px 0 6px;
    font-weight: 700;
    color: #0f172a;
}

.ai-response h1 { font-size: 18px; }
.ai-response h2 { font-size: 16px; }
.ai-response h3 { font-size: 14.5px; }

.ai-response strong {
    font-weight: 600;
    color: #0f172a;
}

.ai-response .ai-list {
    margin: 8px 0 10px;
    padding-left: 20px;
}

.ai-response .ai-list li {
    margin-bottom: 4px;
}

.ai-response .ai-blockquote {
    margin: 10px 0;
    padding: 8px 12px;
    border-left: 3px solid var(--ai-teal);
    background: #f0fdf4;
    border-radius: 4px;
    font-size: 13px;
    color: #334155;
}

.ai-response .ai-inline-code {
    padding: 2px 5px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: SFMono-Regular, Consolas, Monaco, monospace;
    font-size: 12px;
    color: #d97706;
}

.ai-response .ai-code-block {
    margin: 10px 0;
    padding: 12px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 8px;
    overflow-x: auto;
}

.ai-response .ai-code-block code {
    font-family: SFMono-Regular, Consolas, Monaco, monospace;
    font-size: 12px;
    white-space: pre;
}

.ai-error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Responsive Mobile Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .ai-widget-container {
        bottom: 80px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        height: calc(100vh - 100px);
    }
    
    .ai-widget-launcher {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 22px;
    }
}
