/**
 * NormScout Reusable Chat Component
 * Can be used in homepage, develope page, workspace, etc.
 *
 * Usage:
 * 1. Include this CSS file
 * 2. Use class names: .ns-chat-container, .ns-chat-messages, etc.
 * 3. Initialize with chat-component.js
 */

/* ========================================
   Agent Color System - Single Source of Truth
   ======================================== */

:root {
    /* Compliance Expert - Blue Theme */
    --agent-compliance-primary: #2048D5;
    --agent-compliance-light: #eff6ff;
    --agent-compliance-border: #bfdbfe;
    --agent-compliance-text: #1d4ed8;

    /* General Assistant - Green Theme */
    --agent-general-primary: #10b981;
    --agent-general-light: #f0fdf4;
    --agent-general-border: #bbf7d0;
    --agent-general-text: #15803d;

    /* Technical Advisor - Orange Theme */
    --agent-technical-primary: #f97316;
    --agent-technical-light: #fff7ed;
    --agent-technical-border: #fed7aa;
    --agent-technical-text: #c2410c;

    /* Development Assistant - Purple Theme */
    --agent-development-primary: #8b5cf6;
    --agent-development-light: #f5f3ff;
    --agent-development-border: #ddd6fe;
    --agent-development-text: #7c3aed;
}

/* Chat Container */
.ns-chat-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(56, 105, 250, 0.1);
}

/* Messages Area */
.ns-chat-messages {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

.ns-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ns-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.ns-chat-messages::-webkit-scrollbar-thumb {
    background: #3869FA;
    border-radius: 10px;
}

/* Message Bubbles */
.ns-message {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    border-radius: 12px;
    line-height: 1.6;
    animation: ns-slideIn 0.3s ease;
}

@keyframes ns-slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ns-message strong {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.ns-message p {
    margin: 0;
}

/* User Message (Purple Gradient) */
.ns-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    max-width: 85%;
}

.ns-message.user strong {
    color: rgba(255, 255, 255, 0.9);
}

.ns-message.user p {
    color: white;
}

/* Assistant Message (Light Gray - default/compliance) */
.ns-message.assistant {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    margin-right: auto;
    max-width: 95%;
}

.ns-message.assistant strong {
    color: #2048D5;
}

.ns-message.assistant p {
    color: #1a1a1a;
}

/* Agent-specific colors for assistant messages */

/* Compliance Expert - Blue (default) */
.ns-message.assistant.agent-compliance {
    background: var(--agent-compliance-light);
    border: 1px solid var(--agent-compliance-border);
}

.ns-message.assistant.agent-compliance strong {
    color: var(--agent-compliance-text);
}

/* General Assistant - Green */
.ns-message.assistant.agent-general {
    background: var(--agent-general-light);
    border: 1px solid var(--agent-general-border);
}

.ns-message.assistant.agent-general strong {
    color: var(--agent-general-text);
}

/* Technical Advisor - Orange */
.ns-message.assistant.agent-technical {
    background: var(--agent-technical-light);
    border: 1px solid var(--agent-technical-border);
}

.ns-message.assistant.agent-technical strong {
    color: var(--agent-technical-text);
}

/* Development Assistant - Purple */
.ns-message.assistant.agent-development {
    background: var(--agent-development-light);
    border: 1px solid var(--agent-development-border);
}

.ns-message.assistant.agent-development strong {
    color: var(--agent-development-text);
}

/* Input Group */
.ns-input-group {
    display: flex;
    gap: 0.75rem;
}

.ns-input-group input,
.ns-input-group textarea {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
    resize: vertical;
}

.ns-input-group input:focus,
.ns-input-group textarea:focus {
    outline: none;
    border-color: #3869FA;
    box-shadow: 0 0 0 3px rgba(56, 105, 250, 0.1);
}

.ns-input-group button {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #3869FA 0%, #2048D5 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ns-input-group button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 105, 250, 0.3);
}

.ns-input-group button:active {
    transform: translateY(0);
}

.ns-input-group button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Progress Button (The Beautiful One!) */
.ns-progress-btn {
    display: block;
    width: 100%;
    padding: 1.25rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
}

.ns-progress-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.ns-progress-btn:active {
    transform: translateY(0);
}

.ns-progress-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.ns-progress-btn.analyzing {
    background: #e5e7eb;
    cursor: wait;
}

/* The Magic Progress Bar */
.ns-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(135deg, #3869FA 0%, #2048D5 100%);
    width: 0%;
    transition: width 0.3s ease;
    z-index: 0;
}

.ns-progress-text {
    position: relative;
    z-index: 1;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ns-progress-btn.analyzing .ns-progress-text {
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    animation: ns-pulse-text 2s ease-in-out infinite;
}

@keyframes ns-pulse-text {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

/* Markdown content styles for chat messages - mirrors product description styles */
.ns-message .md-content {
    line-height: 1.6;
}

.ns-message .md-content p {
    margin-bottom: 16px;
    line-height: 1.7;
}

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

.ns-message .md-content h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 24px 0 16px;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.ns-message .md-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 20px 0 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ns-message .md-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 16px 0 10px;
}

.ns-message .md-content h1:first-child,
.ns-message .md-content h2:first-child,
.ns-message .md-content h3:first-child {
    margin-top: 0;
}

.ns-message .md-content ul,
.ns-message .md-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.ns-message .md-content li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.ns-message .md-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
}

.ns-message .md-content pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.ns-message .md-content pre code {
    background: none;
    padding: 0;
}

.ns-message .md-content a {
    color: inherit;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.ns-message .md-content a:hover {
    opacity: 0.8;
}

.ns-message .md-content strong {
    font-weight: 600;
}

.ns-message .md-content em {
    font-style: italic;
}

.ns-message .md-content blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding-left: 16px;
    margin: 12px 0;
    font-style: italic;
    opacity: 0.9;
}

.ns-message .md-content hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

/* Agent-specific heading colors */
.ns-message.assistant.agent-compliance .md-content h1,
.ns-message.assistant.agent-compliance .md-content h2,
.ns-message.assistant.agent-compliance .md-content h3 {
    color: var(--agent-compliance-text);
}

.ns-message.assistant.agent-general .md-content h1,
.ns-message.assistant.agent-general .md-content h2,
.ns-message.assistant.agent-general .md-content h3 {
    color: var(--agent-general-text);
}

.ns-message.assistant.agent-technical .md-content h1,
.ns-message.assistant.agent-technical .md-content h2,
.ns-message.assistant.agent-technical .md-content h3 {
    color: var(--agent-technical-text);
}

.ns-message.assistant.agent-development .md-content h1,
.ns-message.assistant.agent-development .md-content h2,
.ns-message.assistant.agent-development .md-content h3 {
    color: var(--agent-development-text);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ns-chat-container {
        padding: 1.5rem;
    }

    .ns-message.user {
        margin-left: 0;
        max-width: 100%;
    }

    .ns-message.assistant {
        margin-right: 0;
        max-width: 100%;
    }

    .ns-input-group {
        flex-direction: column;
    }

    .ns-input-group button {
        width: 100%;
    }
}
