/**
 * NSEMM RAG AI Assistant Frontend Styles
 */

.nsemm-ai-assistant {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    margin: 3rem 0;
    box-shadow: 0 8px 30px rgba(28, 59, 112, 0.1);
    border: 2px solid #D9FFEC;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.ai-assistant-header {
    text-align: center;
    margin-bottom: 2rem;
}

.ai-assistant-title {
    font-family: 'Sora', sans-serif;
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 700;
    color: #1C3B70;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.ai-assistant-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    color: #2B2A2A;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.ai-notice {
    background: #E3F2FD;
    color: #1565C0;
    padding: 1rem 1.5rem;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    justify-content: center;
    flex-wrap: wrap;
    border: 2px solid #90CAF9;
    text-align: center;
}

.ai-notice a {
    color: #0D47A1;
    text-decoration: underline;
    font-weight: 700;
}

.ai-notice a:hover {
    color: #1976D2;
}

.ai-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ai-query-section {
    margin-bottom: 2rem;
}

.ai-input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.ai-input-group.focused {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
}

#ai-question {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid #AEBCD4;
    border-radius: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box;
}

#ai-question:focus {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
    transform: translateY(-1px);
}

#ai-question::placeholder {
    color: #999;
    font-style: italic;
}

#ai-submit {
    background: #1976D2;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

#ai-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

#ai-submit:hover:not(:disabled) {
    background: #1565C0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(25, 118, 210, 0.3);
}

#ai-submit:hover:not(:disabled)::before {
    left: 100%;
}

#ai-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

#ai-submit:active:not(:disabled) {
    transform: translateY(0);
}

.loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.character-count {
    text-align: right;
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    transition: color 0.3s ease;
}

.ai-response {
    background: linear-gradient(145deg, #E8F5E8, #F0FFF0);
    border-radius: 20px;
    padding: 2rem;
    margin: 2rem 0;
    border: 2px solid #4CAF50;
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.2);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Rainbow animation removed for cleaner look */

.response-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: #1C3B70;
    font-size: 1.1rem;
}

.knowledge-icon {
    font-size: 1.1rem;
    margin-right: 0.25rem;
}

.response-content {
    line-height: 1.7;
    color: #2B2A2A;
    font-size: 0.95rem;
    text-align: left;
    margin-bottom: 1.5rem;
}

.response-content p {
    margin-bottom: 1.2rem;
    text-align: left;
}

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

.response-content strong {
    color: #1C3B70;
    font-weight: 600;
}

.response-content ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
    text-align: left;
}

.response-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    text-align: left;
}

.response-sources {
    background: rgba(255, 255, 255, 0.8);
    padding: 1rem;
    border-radius: 15px;
    margin: 1.5rem 0;
    border: 1px solid #E0E0E0;
    backdrop-filter: blur(10px);
}

.response-sources strong {
    color: #1C3B70;
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.source-link {
    color: #1976D2;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.25rem 0.75rem;
    background: rgba(25, 118, 210, 0.1);
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1px solid rgba(25, 118, 210, 0.2);
}

.source-link:hover {
    background: rgba(25, 118, 210, 0.2);
    color: #1565C0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

.no-sources {
    color: #666;
    font-style: italic;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
}

.response-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(76, 175, 80, 0.3);
    text-align: center;
}

.response-footer small {
    color: #4CAF50;
    font-weight: 600;
    font-size: 0.9rem;
}

.ai-suggestions {
    margin-top: 2rem;
}

.ai-suggestions h4 {
    font-family: 'Sora', sans-serif;
    color: #1C3B70;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-align: center;
}

.suggestion-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.suggestion-pill {
    background: #E1E1E1;
    color: #2B2A2A;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.suggestion-pill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.suggestion-pill:hover {
    background: #AEBCD4;
    color: #1C3B70;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(174, 188, 212, 0.3);
}

.suggestion-pill:hover::before {
    left: 100%;
}

.safeguarding-redirect {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(145deg, #FFEBEE, #FFCDD2);
    border-radius: 15px;
    border: 2px solid #F44336;
}

.safeguarding-redirect h4 {
    color: #D32F2F;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.safeguarding-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.safeguarding-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.safeguarding-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    transition: left 0.5s;
}

.safeguarding-btn.primary {
    background: #dc3545;
    color: white;
}

.safeguarding-btn.secondary {
    background: #1C3B70;
    color: white;
}

.safeguarding-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    color: white;
}

.safeguarding-btn:hover::before {
    left: 100%;
}

.error-message {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(145deg, #FFF3E0, #FFE0B2);
    border-radius: 15px;
    border: 2px solid #FF9800;
}

.error-message h4 {
    color: #F57C00;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.error-message p {
    color: #E65100;
    margin-bottom: 1rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.error-btn {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    background: #FF9800;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.error-btn.secondary {
    background: #607D8B;
}

.error-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nsemm-ai-assistant {
        padding: 1.5rem;
        margin: 2rem 0;
        border-radius: 1rem;
    }

    .ai-input-group {
        gap: 0.75rem;
    }

    #ai-submit {
        align-self: stretch;
        justify-content: center;
    }

    .suggestion-pills {
        justify-content: center;
    }

    .safeguarding-actions,
    .error-actions {
        flex-direction: column;
        align-items: center;
    }

    .source-links {
        flex-direction: column;
        gap: 0.25rem;
    }

    .source-link {
        text-align: center;
    }

    .ai-notice {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .nsemm-ai-assistant {
        padding: 1rem;
        margin: 1rem 0;
    }

    .ai-assistant-title {
        font-size: 1.8rem;
    }

    .ai-assistant-subtitle {
        font-size: 1rem;
    }

    .suggestion-pill {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Print Styles */
@media print {
    .nsemm-ai-assistant {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .ai-query-section,
    .ai-suggestions {
        display: none;
    }

    .loading-spinner,
    .safeguarding-btn,
    .error-btn {
        display: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .nsemm-ai-assistant {
        border: 3px solid #000;
    }

    #ai-question {
        border: 2px solid #000;
    }

    #ai-submit {
        background: #000;
        border: 2px solid #000;
    }

    .ai-response {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation: none;
        border: 2px solid currentColor;
        border-top: 2px solid transparent;
    }
}

/* Focus Styles for Accessibility */
.nsemm-ai-assistant *:focus {
    outline: 2px solid #1976D2;
    outline-offset: 2px;
}

.nsemm-ai-assistant *:focus:not(:focus-visible) {
    outline: none;
}

/* Screen Reader Only Content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Action Button Styles */

/* Action Buttons */
.ai-action-button {
    margin: 1.5rem 0;
    text-align: center;
}

.nsemm-action-btn {
    display: inline-block;
    background: linear-gradient(135deg, #1976D2, #1565C0);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 25px;
    text-decoration: none;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(25, 118, 210, 0.3);
    position: relative;
    overflow: hidden;
}

.nsemm-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.nsemm-action-btn:hover {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(25, 118, 210, 0.4);
    color: white;
}

.nsemm-action-btn:hover::before {
    left: 100%;
}

/* Live Chat Suggestions */
.ai-live-chat-suggest {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(145deg, #E8F5E8, #F0FFF0);
    border-radius: 15px;
    border: 2px solid #4CAF50;
    text-align: center;
}

.ai-live-chat-suggest p {
    margin-bottom: 1rem;
    color: #1C3B70;
    font-weight: 600;
}

.nsemm-live-chat-btn, .nsemm-contact-btn {
    display: inline-block;
    background: #4CAF50;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0 0.5rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.nsemm-contact-btn {
    background: #FF9800;
}

.nsemm-live-chat-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    color: white;
}

.nsemm-contact-btn:hover {
    background: #F57C00;
    transform: translateY(-1px);
    color: white;
}

/* Follow-up Questions */
.ai-follow-up-questions {
    margin: 2rem 0 1rem 0;
    padding: 1.5rem;
    background: linear-gradient(145deg, #FFF3E0, #FFFDE7);
    border-radius: 15px;
    border: 2px solid #FFB74D;
}

.ai-follow-up-questions p {
    margin-bottom: 1rem;
    color: #1C3B70;
    font-weight: 600;
    text-align: center;
}

.follow-up-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.follow-up-pill {
    background: #FFE0B2;
    color: #E65100;
    border: 2px solid #FFB74D;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.follow-up-pill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.follow-up-pill:hover {
    background: #FF9800;
    color: white;
    border-color: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.follow-up-pill:hover::before {
    left: 100%;
}

/* Enhanced Response Structure */
.response-content {
    line-height: 1.7;
    color: #2B2A2A;
    font-size: 0.95rem;
    text-align: left;
    margin-bottom: 1.5rem;
}

.response-content p:first-child {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1C3B70;
}

/* Enhanced Source Display */
.response-sources {
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 15px;
    margin: 1.5rem 0;
    border: 1px solid #E0E0E0;
    backdrop-filter: blur(10px);
}

.response-sources strong {
    color: #1C3B70;
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.source-link {
    color: #1976D2;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.25rem 0.75rem;
    background: rgba(25, 118, 210, 0.1);
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1px solid rgba(25, 118, 210, 0.2);
    position: relative;
}

.source-link.keystone {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
    color: #2E7D32;
    font-weight: 600;
}

.source-link.keystone::after {
    content: '⭐';
    margin-left: 0.25rem;
    font-size: 0.8rem;
}

.source-link:hover {
    background: rgba(25, 118, 210, 0.2);
    color: #1565C0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

.source-link.keystone:hover {
    background: rgba(76, 175, 80, 0.2);
    color: #1B5E20;
}

/* Conversational Response Styling */
.ai-response::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #1C3B70;
    /* Animation removed for cleaner look */
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    .ai-action-button {
        margin: 1rem 0;
    }

    .nsemm-action-btn {
        display: block;
        width: 100%;
        text-align: center;
        padding: 1rem;
        font-size: 1.1rem;
    }

    .follow-up-pills {
        flex-direction: column;
        align-items: center;
    }

    .follow-up-pill {
        width: 100%;
        text-align: center;
        max-width: 300px;
    }

    .ai-live-chat-suggest {
        padding: 1rem 0.5rem;
    }

    .nsemm-live-chat-btn, .nsemm-contact-btn {
        display: block;
        width: 80%;
        margin: 0.5rem auto;
        text-align: center;
        padding: 0.75rem;
    }

    .source-links {
        flex-direction: column;
        gap: 0.25rem;
    }

    .source-link {
        text-align: center;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    .nsemm-action-btn::before,
    .follow-up-pill::before {
        transition: none;
    }

    .ai-response::before {
        animation: none;
        background: linear-gradient(90deg, #4CAF50, #2196F3);
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .nsemm-action-btn {
        border: 3px solid #000;
        background: #000;
    }

    .follow-up-pill {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }

    .ai-live-chat-suggest {
        border: 3px solid #000;
    }
}

/* Focus States for Better Accessibility */
.nsemm-action-btn:focus,
.follow-up-pill:focus,
.nsemm-live-chat-btn:focus,
.nsemm-contact-btn:focus {
    outline: 3px solid #1976D2;
    outline-offset: 2px;
}

/* Animation for new responses */
.ai-response.new-response {
    animation: slideInFromBottom 0.6s ease-out;
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Contact Us Button under all responses */
.ai-contact-section {
    margin-top: 1rem;
    text-align: center;
}

.ai-contact-button {
    background: linear-gradient(135deg, #1C3B70 0%, #2A4A8A 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 8px rgba(28, 59, 112, 0.3);
    border: 2px solid transparent;
}

.ai-contact-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(28, 59, 112, 0.4);
    background: linear-gradient(135deg, #2A4A8A 0%, #1C3B70 100%);
}

.ai-contact-button:active {
    transform: translateY(0);
}

.ai-contact-button:focus {
    outline: 2px solid #FACD00;
    outline-offset: 2px;
}

.contact-icon {
    display: none; /* Hide the icon with yellow circle */
}

.contact-text {
    font-weight: 600;
}

.contact-arrow {
    font-size: 1em;
    transition: transform 0.3s ease;
}

.ai-contact-button:hover .contact-arrow {
    transform: translateX(3px);
}

/* Response Actions Container */
.response-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 1rem;
}

.action-button {
    background: linear-gradient(135deg, #FACD00 0%, #F5C500 100%) !important;
    color: #1C3B70 !important;
    text-decoration: none !important;
    border-radius: 25px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    box-shadow: 0 2px 8px rgba(250, 205, 0, 0.3);
    border: 2px solid transparent;
    margin: 0 0.5rem;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(250, 205, 0, 0.4);
    background: linear-gradient(135deg, #F5C500 0%, #FACD00 100%) !important;
    color: #1C3B70 !important;
    text-decoration: none !important;
}

.action-button:active {
    transform: translateY(0);
}

.action-button:focus {
    outline: 2px solid #1C3B70;
    outline-offset: 2px;
    color: #1C3B70 !important;
    text-decoration: none !important;
}

/* All action buttons now use the same styling */

/* Override any theme interference with action buttons */
a.action-button,
a.action-button:link,
a.action-button:visited {
    background: linear-gradient(135deg, #FACD00 0%, #F5C500 100%) !important;
    color: #1C3B70 !important;
    text-decoration: none !important;
    border-bottom: none !important;
    text-underline-offset: unset !important;
}

a.action-button:hover,
a.action-button:focus {
    background: linear-gradient(135deg, #F5C500 0%, #FACD00 100%) !important;
    color: #1C3B70 !important;
    text-decoration: none !important;
    border-bottom: none !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .response-actions {
        align-items: center;
    }
    
    .action-buttons {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .action-button {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
}