/* =========================================
   AI Assistant Panel Styles (v6.1 - Light Theme & Slide)
   ========================================= */

/* AI Mode Tab Highlight */
.mode-btn.ai-mode-btn.active {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    border-color: transparent;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.mode-btn.ai-mode-btn .icon {
    font-size: 1.1rem;
}

/* AI Panel Layout (Right Side) */
.lab-ai-panel {
    width: 360px;
    background: #ffffff;
    /* Light Theme */
    /* Light Theme */
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: absolute;
    /* Fixed on left */
    left: 0;
    top: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
    z-index: 100;

    /* Animation: Slide out to left default */
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    /* Ignore clicks when hidden */
    visibility: hidden;
}

/* Shown state */
.lab-workspace.ai-active .lab-ai-panel {
    transform: translateX(0);
    pointer-events: auto;
    visibility: visible;
}

/* Header inside Panel */
.ai-panel-header {
    padding: 15px 20px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-title {
    font-weight: 700;
    color: #1e293b;
    /* Dark text */
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.ai-settings-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.ai-settings-btn:hover {
    color: #6366f1;
    background: #f8fafc;
}

/* Header Controls Container */
.ai-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Model Selection Dropdown */
.ai-model-select {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #334155;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-model-select:hover {
    border-color: #6366f1;
}

.ai-model-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* Sub-mode Switcher */
.ai-mode-switcher {
    padding: 10px 15px;
    background: #f8fafc;
    display: flex;
    gap: 5px;
    border-bottom: 1px solid #f1f5f9;
}

.ai-submode-btn {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-weight: 500;
}

.ai-submode-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

/* Chat History Area */
.ai-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f8fafc;
    /* Light background */
}

/* Scrollbar for chat */
.ai-chat-history::-webkit-scrollbar {
    width: 5px;
}

.ai-chat-history::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 3px;
}

/* Chat Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* AI Bubble (Left) */
.chat-bubble.ai-bubble {
    align-self: flex-start;
    background: #ffffff;
    color: #334155;
    border-bottom-left-radius: 2px;
    border: 1px solid #e2e8f0;
}

/* User Bubble (Right) */
.chat-bubble.user-bubble {
    align-self: flex-end;
    background: #6366f1;
    /* Indigo */
    color: white;
    border-bottom-right-radius: 2px;
}

/* System/Action Bubble */
.chat-bubble.system-bubble {
    align-self: center;
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    width: 100%;
    text-align: center;
    padding: 5px;
    font-size: 0.8rem;
    box-shadow: none;
}

/* Input Area */
.ai-input-area {
    padding: 15px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#aiChatInput {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1e293b;
    padding: 10px 12px;
    font-family: inherit;
    resize: none;
    min-height: 60px;
    max-height: 180px;
    transition: border-color 0.2s;
    font-size: 0.95rem;
}

#aiChatInput:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
}

.ai-send-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-send-btn:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

/* Workspace Adjustment when AI Panel is open */
.lab-workspace {
    position: relative;
    overflow: hidden;
}

.lab-workspace.ai-active .lab-viewport {
    /* Viewport shrinks when AI panel is active (Left Panel) */
    width: calc(100% - 360px);
    margin-left: 360px;
    /* Shift content to right */
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.lab-viewport {
    width: 100%;
    margin-left: 0;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* v5.71: Usage Meter */
.ai-usage-meter {
    padding: 10px 15px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.usage-bar-container {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #84cc16);
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 3px;
}

.usage-bar.warning {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.usage-bar.danger {
    background: #ef4444;
}

.usage-text {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    font-weight: 500;
}

/* v5.71: AI Thinking Animation */
.ai-thinking .thinking-dots {
    font-style: italic;
    color: #94a3b8;
}