/**
 * ActProof.ai - AI Assistant Sidebar Styles
 */

/* ============================================
   Toggle Button
   ============================================ */

/* Signup-style pill – smaller, right side, always in footer area */
.ai-assistant-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.85) 0%, rgba(67, 56, 202, 0.8) 50%, rgba(79, 70, 229, 0.75) 100%);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 9999px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 2px 12px -2px rgba(88, 28, 135, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    z-index: 999;
}

.ai-assistant-toggle:hover {
    background: linear-gradient(135deg, rgba(107, 33, 168, 0.9) 0%, rgba(99, 102, 241, 0.85) 100%);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px -4px rgba(88, 28, 135, 0.45);
}

.ai-assistant-toggle.active {
    background: linear-gradient(135deg, rgba(107, 33, 168, 0.9) 0%, rgba(99, 102, 241, 0.85) 100%);
    border-color: rgba(139, 92, 246, 0.5);
}

.ai-assistant-toggle svg {
    width: 16px;
    height: 16px;
}

.toggle-label {
    display: none;
}

@media (min-width: 768px) {
    .toggle-label {
        display: inline;
    }
}

/* ============================================
   Sidebar
   ============================================ */

.ai-assistant-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(30, 27, 75, 0.98) 100%);
    border-left: 1px solid rgba(124, 58, 237, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
}

.ai-assistant-sidebar.open {
    right: 0;
}

@media (max-width: 480px) {
    .ai-assistant-sidebar {
        width: 100vw;
        right: -100vw;
    }
}

/* ============================================
   Sidebar Header
   ============================================ */

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-title svg {
    color: var(--primary-light);
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-close-sidebar,
.btn-reset-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 9999px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close-sidebar:hover,
.btn-reset-chat:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    color: var(--text-primary);
}

/* ============================================
   Sidebar Content
   ============================================ */

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* Suggestions Section */
.suggestions-section,
.triage-section {
    margin-bottom: 1.5rem;
}

.suggestions-section h4,
.triage-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.suggestion-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 9999px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    color: var(--text-primary);
    box-shadow: 0 2px 8px -2px rgba(88, 28, 135, 0.3);
}

.suggestion-btn svg {
    flex-shrink: 0;
    color: var(--primary-light);
}

.triage-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.triage-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    color: var(--warning);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.triage-btn:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
    border-color: var(--warning);
    transform: translateX(4px);
}

.triage-btn svg {
    flex-shrink: 0;
}

/* ============================================
   Chat Messages
   ============================================ */

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 200px;
}

.welcome-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.welcome-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2) 0%, rgba(124, 58, 237, 0.05) 100%);
    border-radius: 16px;
}

.welcome-icon svg {
    color: var(--primary-light);
}

.welcome-message p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-message small {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

/* Chat Message */
.chat-message {
    padding: 1rem;
    border-radius: 12px;
    max-width: 95%;
}

.chat-message.user {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-message.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.message-content {
    font-size: 0.875rem;
    line-height: 1.6;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.message-content .article-ref {
    display: inline;
    padding: 0.125rem 0.375rem;
    background: rgba(124, 58, 237, 0.2);
    border-radius: 4px;
    color: var(--primary-light);
    font-weight: 500;
    cursor: help;
    position: relative;
}

.message-content .article-ref:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 250px;
    padding: 0.75rem;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.message-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sources-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.source-tag {
    padding: 0.25rem 0.5rem;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--primary-light);
}

/* Loading Animation */
.chat-message.loading .message-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.loading-dots {
    display: flex;
    gap: 0.375rem;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
    0%, 60%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   Chat Input
   ============================================ */

.chat-input-container {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid rgba(124, 58, 237, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.chat-form {
    display: flex;
    align-items: flex-end;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 12px;
    padding: 0.75rem;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

/* Signup-style pill */
.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.85) 0%, rgba(67, 56, 202, 0.8) 50%, rgba(79, 70, 229, 0.75) 100%);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 9999px;
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    box-shadow: 0 2px 12px -2px rgba(88, 28, 135, 0.35);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    background: linear-gradient(135deg, rgba(107, 33, 168, 0.9) 0%, rgba(99, 102, 241, 0.85) 100%);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px -4px rgba(88, 28, 135, 0.45);
}

.btn-send svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   Inline Help
   ============================================ */

.has-inline-help {
    cursor: help;
    position: relative;
}

.has-inline-help .help-icon {
    margin-left: 0.25rem;
    color: var(--primary-light);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.has-inline-help:hover .help-icon {
    opacity: 1;
}

/* Article reference in alerts */
.alert-article.has-inline-help,
.issue-article.has-inline-help {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.alert-article.has-inline-help:hover,
.issue-article.has-inline-help:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--primary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .ai-assistant-toggle {
        bottom: 1rem;
        right: 1rem;
        padding: 0.5rem 0.75rem;
    }

    .sidebar-content {
        padding: 1rem;
    }

    .suggestions-grid {
        grid-template-columns: 1fr;
    }
}
