/**
 * AI Chat Sidebar Styles
 *
 * Contains: AI sidebar, chat messages, input area
 * Used by: ai-chat.js
 */

/* ===== AI Sidebar ===== */
.ai-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: #1e1e1e;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease-out;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.ai-sidebar.open {
    transform: translateX(0);
}

body.ai-sidebar-open .app-container {
    margin-right: 380px;
    transition: margin-right 0.25s ease-out;
}

.ai-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #252526;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.ai-sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #cccccc;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-sidebar-title svg {
    stroke: var(--accent-blue);
}

.ai-sidebar-actions {
    display: flex;
    gap: 4px;
}

.ai-sidebar-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #858585;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-sidebar-btn:hover {
    background: #3c3c3c;
    color: #cccccc;
}

.ai-sidebar-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #1e1e1e;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.ai-sidebar-footer {
    padding: 12px 16px;
    background: #252526;
    border-top: 1px solid #333;
    flex-shrink: 0;
}

.ai-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #3c3c3c;
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid #4a4a4a;
    transition: border-color 0.15s ease;
}

.ai-input-wrapper:focus-within {
    border-color: var(--accent-blue);
}

.ai-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.ai-input-wrapper textarea::placeholder {
    color: #6e6e6e;
}

.ai-input-wrapper textarea:focus {
    outline: none;
}

.ai-send-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-blue);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: #4a4a4a;
    cursor: not-allowed;
    transform: none;
}

.ai-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.ai-sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ===== AI Messages ===== */
.ai-message {
    font-size: 14px;
    line-height: 1.6;
    color: #e0e0e0;
}

.ai-message-system {
    background: #2d2d30;
    color: #9e9e9e;
    align-self: center;
    max-width: 90%;
    text-align: center;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.ai-message-user {
    background: var(--accent-blue);
    color: white;
    align-self: flex-end;
    max-width: 85%;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    margin-bottom: 4px;
    font-size: 14px;
}

.ai-message-user + .ai-message-assistant {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #333;
}

.ai-message-assistant {
    background: transparent;
    color: #e0e0e0;
    align-self: stretch;
    text-align: left;
    max-width: 100%;
    padding: 12px 4px;
    border: none;
    border-radius: 0;
    line-height: 1.7;
}

.ai-message-assistant h1,
.ai-message-assistant h2,
.ai-message-assistant h3 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
    color: #ffffff;
}

.ai-message-assistant h1:first-child,
.ai-message-assistant h2:first-child,
.ai-message-assistant h3:first-child {
    margin-top: 0;
}

.ai-message-assistant h1 { font-size: 1.35rem; }
.ai-message-assistant h2 { font-size: 1.15rem; }
.ai-message-assistant h3 { font-size: 1rem; }

.ai-message-assistant p {
    margin: 0.6em 0;
}

.ai-message-assistant p:first-child { margin-top: 0; }
.ai-message-assistant p:last-child { margin-bottom: 0; }

.ai-message-assistant strong {
    font-weight: 600;
    color: #ffffff;
}

.ai-message-assistant em {
    font-style: italic;
    color: #b0b0b0;
}

.ai-message-assistant code {
    font-family: var(--font-mono);
    background: #2d2d30;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
    color: #4ec9b0;
    border: 1px solid var(--border-subtle);
}

.ai-message-assistant ul,
.ai-message-assistant ol {
    margin: 0.75em 0;
    padding-left: 1.5em;
}

.ai-message-assistant li {
    margin: 0.35em 0;
    line-height: 1.6;
}

.ai-message-assistant ul { list-style-type: disc; }
.ai-message-assistant ol { list-style-type: decimal; }

.ai-message-assistant blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 3px solid var(--accent-blue);
    background: var(--bg-tertiary);
    border-radius: 0 6px 6px 0;
    color: var(--text-secondary);
}

.ai-message-assistant hr {
    margin: 1.25em 0;
    border: none;
    border-top: 1px solid #333;
}

.ai-message-assistant a {
    color: #4fc3f7;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.ai-message-assistant a:hover {
    border-bottom-color: #4fc3f7;
}

.ai-message-streaming::after {
    content: '▋';
    display: inline;
    animation: cursor-blink 0.8s steps(2) infinite;
    color: var(--accent-blue);
    font-weight: 400;
    margin-left: 2px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.ai-message-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    align-self: center;
    text-align: center;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
}

.ai-message-status {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: #fbbf24;
    align-self: center;
    text-align: center;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-message-status .status-icon {
    width: 14px;
    height: 14px;
    border: 2px solid #fbbf24;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
