/* =============================================
   AI ASSESSOR PANEL
   ============================================= */

/* Backdrop */
.ai-assessor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-assessor-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Panel */
.ai-assessor-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-primary, #0a0a0f);
    border-left: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-assessor-panel.open {
    right: 0;
}

/* Header */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    background: var(--glass-bg, rgba(15,17,23,0.72));
    backdrop-filter: saturate(180%) blur(20px);
    flex-shrink: 0;
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary, #e4e5ea);
    letter-spacing: -0.02em;
}

.ai-panel-title svg {
    color: #6c8aff;
}

.ai-context-badge {
    font-size: 0.6rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--hover-bg, rgba(108, 138, 255, 0.12));
    color: var(--accent-blue, #8ba2ff);
    letter-spacing: 0.02em;
}

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

.ai-panel-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary, #8b8fa3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-panel-btn:hover {
    background: var(--hover-bg, rgba(108, 138, 255, 0.08));
    color: var(--text-primary, #e4e5ea);
}

/* Setup Screen */
.ai-setup {
    padding: 40px 24px;
    text-align: center;
    flex-shrink: 0;
}

.ai-setup-icon {
    margin: 0 auto 16px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: var(--hover-bg, rgba(108, 138, 255, 0.08));
    color: var(--accent-blue, #6c8aff);
}

.ai-setup h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #e4e5ea);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.ai-setup p {
    font-size: 0.75rem;
    color: var(--text-secondary, #8b8fa3);
    line-height: 1.5;
    margin: 0 0 20px;
}

.ai-key-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-key-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-radius: 8px;
    background: var(--bg-secondary, #0f1117);
    color: var(--text-primary, #e4e5ea);
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    outline: none;
    transition: border-color 0.15s;
}

.ai-key-input:focus {
    border-color: var(--accent-blue, #6c8aff);
    box-shadow: 0 0 0 3px var(--hover-bg, rgba(108, 138, 255, 0.1));
}

.ai-connect-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #6c8aff, #5470e0);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.ai-connect-btn:hover {
    background: linear-gradient(135deg, #8ba2ff, #6c8aff);
    transform: translateY(-1px);
}

.ai-connect-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-key-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--text-muted, #4e5263);
}

.ai-key-note svg {
    color: #34d399;
    flex-shrink: 0;
}

/* Provider Setup */
.ai-provider-setup {
    text-align: left;
}

.ai-provider-setup h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #e4e5ea);
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    text-align: center;
}

.ai-provider-setup > p {
    font-size: 0.72rem;
    color: var(--text-secondary, #8b8fa3);
    line-height: 1.5;
    margin: 0 0 16px;
    text-align: center;
}

.ai-provider-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-secondary, #0f1117);
    border-radius: 10px;
    padding: 3px;
}

.ai-provider-tab {
    flex: 1;
    padding: 7px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary, #8b8fa3);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-provider-tab:hover {
    color: var(--text-primary, #e4e5ea);
    background: var(--hover-bg, rgba(108, 138, 255, 0.06));
}

.ai-provider-tab.active {
    background: var(--accent-blue, #6c8aff);
    color: #fff;
    font-weight: 600;
}

.ai-provider-config {
    text-align: left;
}

.ai-model-select-group {
    margin-bottom: 12px;
}

.ai-model-select-group label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary, #8b8fa3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ai-model-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-radius: 8px;
    background: var(--bg-secondary, #0f1117);
    color: var(--text-primary, #e4e5ea);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8fa3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.ai-model-select:focus {
    border-color: var(--accent-blue, #6c8aff);
    box-shadow: 0 0 0 3px var(--hover-bg, rgba(108, 138, 255, 0.1));
}

.ai-model-select option {
    background: var(--bg-secondary, #0f1117);
    color: var(--text-primary, #e4e5ea);
}

/* Quick Actions */
.ai-quick-actions {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    flex-shrink: 0;
}

.ai-quick-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted, #4e5263);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.ai-quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.ai-quick-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    border-radius: 8px;
    background: var(--bg-secondary, #0f1117);
    color: var(--text-secondary, #8b8fa3);
    font-size: 0.68rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.ai-quick-btn:hover {
    background: var(--hover-bg, rgba(108, 138, 255, 0.06));
    border-color: var(--hover-border, rgba(108, 138, 255, 0.15));
    color: var(--text-primary, #e4e5ea);
}

.ai-quick-btn svg {
    flex-shrink: 0;
    color: #6c8aff;
}

/* Messages Area */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.ai-messages::-webkit-scrollbar-thumb {
    background: var(--hover-border, rgba(108, 138, 255, 0.2));
    border-radius: 2px;
}

/* Welcome */
.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    flex: 1;
}

.ai-welcome-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--hover-bg, rgba(108, 138, 255, 0.06));
    color: var(--accent-blue, #6c8aff);
    margin-bottom: 12px;
}

.ai-welcome p {
    font-size: 0.75rem;
    color: var(--text-secondary, #8b8fa3);
    line-height: 1.5;
    max-width: 300px;
}

/* Message Bubbles */
.ai-message {
    display: flex;
    gap: 10px;
    animation: ai-fade-in 0.2s ease;
}

@keyframes ai-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message-user {
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--hover-bg, rgba(108, 138, 255, 0.1));
    color: var(--accent-blue, #6c8aff);
    flex-shrink: 0;
}

.ai-message-user .ai-message-content {
    background: var(--hover-bg, rgba(108, 138, 255, 0.12));
    border: 1px solid var(--hover-border, rgba(108, 138, 255, 0.15));
    color: var(--text-primary, #e4e5ea);
    border-radius: 12px 12px 4px 12px;
    max-width: 85%;
}

.ai-message-assistant .ai-message-content {
    background: var(--bg-secondary, #0f1117);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    color: var(--text-primary, #e4e5ea);
    border-radius: 12px 12px 12px 4px;
    max-width: 85%;
}

.ai-message-content {
    padding: 10px 14px;
    font-size: 0.78rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4 {
    margin: 12px 0 6px;
    color: var(--text-primary, #e4e5ea);
    letter-spacing: -0.02em;
}

.ai-message-content h2 { font-size: 0.9rem; }
.ai-message-content h3 { font-size: 0.85rem; }
.ai-message-content h4 { font-size: 0.8rem; }

.ai-message-content p {
    margin: 0 0 8px;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

.ai-message-content ul {
    margin: 4px 0 8px;
    padding-left: 18px;
}

.ai-message-content li {
    margin-bottom: 4px;
}

.ai-message-content code {
    background: var(--hover-bg, rgba(108, 138, 255, 0.08));
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: #8ba2ff;
}

.ai-message-content pre {
    background: var(--bg-primary, #0a0a0f);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary, #e4e5ea);
}

.ai-message-content strong {
    color: var(--text-primary, #e4e5ea);
    font-weight: 600;
}

/* System Messages */
.ai-system-message {
    text-align: center;
    font-size: 0.7rem;
    padding: 6px 12px;
    border-radius: 8px;
    animation: ai-fade-in 0.2s ease;
}

.ai-system-info {
    color: var(--accent-blue, #6c8aff);
    background: var(--hover-bg, rgba(108, 138, 255, 0.06));
}

.ai-system-error {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: ai-fade-in 0.2s ease;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bg-secondary, #0f1117);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    border-radius: 12px 12px 12px 4px;
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c8aff;
    animation: ai-dot-bounce 1.4s infinite ease-in-out;
}

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

@keyframes ai-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.ai-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border, rgba(255,255,255,0.05));
    background: var(--glass-bg, rgba(15,17,23,0.72));
    backdrop-filter: saturate(180%) blur(20px);
    flex-shrink: 0;
}

.ai-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    border-radius: 10px;
    background: var(--bg-secondary, #0f1117);
    color: var(--text-primary, #e4e5ea);
    font-size: 0.8rem;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
    max-height: 120px;
}

.ai-input:focus {
    border-color: var(--focus-border, rgba(108, 138, 255, 0.3));
    box-shadow: 0 0 0 3px var(--hover-bg, rgba(108, 138, 255, 0.06));
}

.ai-input::placeholder {
    color: var(--text-muted, #4e5263);
}

.ai-send-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6c8aff, #5470e0);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #8ba2ff, #6c8aff);
    transform: translateY(-1px);
}

.ai-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-spin 0.6s linear infinite;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

.ai-input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 0.6rem;
    color: var(--text-muted, #4e5263);
}

.ai-token-count {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.58rem;
}

/* Contextual AI Button (placed in objective rows, POA&M, etc.) */
.ai-assess-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--hover-border, rgba(108, 138, 255, 0.15));
    border-radius: 6px;
    background: var(--hover-bg, rgba(108, 138, 255, 0.06));
    color: var(--accent-blue, #6c8aff);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ai-assess-btn:hover {
    background: var(--hover-bg, rgba(108, 138, 255, 0.12));
    border-color: var(--focus-border, rgba(108, 138, 255, 0.3));
    color: var(--accent-blue, #8ba2ff);
    transform: translateY(-1px);
}

.ai-assess-btn svg {
    width: 13px;
    height: 13px;
}

/* FAB (Floating Action Button) */
.ai-fab {
    position: fixed;
    bottom: 72px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--hover-border, rgba(108, 138, 255, 0.2));
    border-radius: 14px;
    background: var(--nav-active-bg, linear-gradient(135deg, rgba(108, 138, 255, 0.15), rgba(84, 112, 224, 0.1)));
    backdrop-filter: saturate(180%) blur(20px);
    color: var(--accent-blue, #6c8aff);
    cursor: pointer;
    z-index: 100000;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.ai-fab:hover {
    background: var(--nav-active-bg, linear-gradient(135deg, rgba(108, 138, 255, 0.25), rgba(84, 112, 224, 0.15)));
    border-color: var(--focus-border, rgba(108, 138, 255, 0.35));
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-glow, rgba(108, 138, 255, 0.15));
}

.ai-fab svg {
    width: 20px;
    height: 20px;
}

.ai-fab-tooltip {
    position: absolute;
    right: 52px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-secondary, #0f1117);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    color: var(--text-secondary, #8b8fa3);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.ai-fab:hover .ai-fab-tooltip {
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-assessor-panel {
        width: 100vw;
        right: -100vw;
    }

    .ai-quick-grid {
        grid-template-columns: 1fr;
    }

    .ai-fab {
        bottom: 80px;
        right: 12px;
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .ai-fab-tooltip {
        display: none;
    }
}

@media (max-width: 480px) {
    .ai-message-content {
        max-width: 92%;
        font-size: 0.75rem;
    }

    .ai-quick-btn {
        font-size: 0.65rem;
        padding: 6px 8px;
    }
}
