/* ============================================
   AI StudyHub - AI Panel Styles
   ============================================ */

.ai-panel {
    position: fixed;
    right: 16px;
    top: calc(var(--topnav-height) + 8px);
    bottom: calc(var(--bottom-toolbar-height) + 8px);
    width: var(--ai-panel-width);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    z-index: var(--z-ai-panel);
    overflow: hidden;
    animation: slideInRight 0.3s ease;
    resize: horizontal;
    min-width: 300px;
    max-width: 600px;
}
.ai-panel.active { display: flex; }

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--gradient-primary);
    color: white;
    cursor: move;
}
.ai-panel-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: var(--font-size-sm);
}
.ai-panel-actions { display: flex; gap: var(--space-xs); }
.ai-panel-actions .btn-icon { color: rgba(255,255,255,0.8); }
.ai-panel-actions .btn-icon:hover { color: white; background: rgba(255,255,255,0.15); }

/* Quick Actions */
.ai-quick-actions {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    flex-shrink: 0;
}
.ai-quick-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}
.ai-quick-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.ai-quick-btn .material-icons { font-size: 14px; }

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.ai-message {
    display: flex;
    gap: var(--space-sm);
    animation: fadeIn 0.3s ease;
}
.ai-message.user { flex-direction: row-reverse; }

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ai-avatar .material-icons { color: white; font-size: 18px; }
.ai-message.user .ai-avatar { background: var(--gradient-secondary); }

.ai-bubble {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    font-size: var(--font-size-sm);
    line-height: 1.6;
}
.ai-message.user .ai-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}
.ai-message:not(.user) .ai-bubble {
    border-bottom-left-radius: var(--radius-sm);
}

.ai-bubble ul { padding-left: var(--space-lg); margin-top: var(--space-xs); }
.ai-bubble li { margin-bottom: 4px; }
.ai-bubble p { margin-bottom: var(--space-xs); }
.ai-bubble p:last-child { margin-bottom: 0; }

.ai-speak-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-sm);
    padding: 3px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 11px;
    transition: all var(--transition-fast);
}
.ai-speak-btn .material-icons { font-size: 15px; }
.ai-speak-btn:hover { border-color: var(--primary); color: var(--primary); }
.ai-speak-btn.speaking { border-color: var(--primary); color: var(--primary); background: var(--primary-50); animation: pulse 1.4s infinite; }

.ai-bubble pre {
    background: var(--code-bg);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    margin: var(--space-sm) 0;
}

/* AI typing indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: var(--space-sm);
}
.ai-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat Input */
.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-color);
}
.ai-input-actions { display: flex; gap: 2px; }
.ai-chat-input textarea {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    resize: none;
    font-size: var(--font-size-sm);
}

/* FAB Button */
.ai-fab {
    position: fixed;
    right: 24px;
    bottom: calc(var(--bottom-toolbar-height) + 24px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-ai-panel);
    transition: all var(--transition-fast);
    animation: pulse 2s infinite;
}
.ai-fab:hover { transform: scale(1.1); }
.ai-fab .material-icons { font-size: 28px; }
@keyframes pulse {
    0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(79,70,229,0.4); }
    50% { box-shadow: var(--shadow-lg), 0 0 0 12px rgba(79,70,229,0); }
}
