/**
 * AI Article Chat Widget Styles
 * 
 * @package Authority_Nexus_2026
 */

/* ===================================================================
   CSS VARIABLES
   =================================================================== */
:root {
    --chat-primary: #667eea;
    --chat-secondary: #764ba2;
    --chat-bg: #ffffff;
    --chat-text: #1a1a1a;
    --chat-text-light: #666666;
    --chat-border: #e0e0e0;
    --chat-user-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --chat-bot-bg: #f5f7fa;
    --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .nexus-chat-widget,
.dark-mode .nexus-chat-widget {
    --chat-bg: #1e293b;
    --chat-text: #e2e8f0;
    --chat-text-light: #94a3b8;
    --chat-border: #334155;
    --chat-bot-bg: #0f172a;
}

/* Chat Toggle Button - Enhanced with Label */
.nexus-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    min-width: 60px;
    height: 50px;
    padding: 0 18px;
    border-radius: 25px;
    background: var(--chat-user-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    box-shadow: var(--chat-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.is-rtl .nexus-chat-toggle {
    right: auto;
    left: 24px;
}

.nexus-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 50px rgba(102, 126, 234, 0.4);
}

.nexus-chat-toggle:active {
    transform: scale(0.95);
}

/* Button Label */
.chat-btn-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.nexus-chat-toggle .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ===================================================================
   CHAT PANEL
   =================================================================== */
.nexus-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 160px);
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    z-index: 9998;
    animation: chatSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.is-rtl .nexus-chat-panel {
    right: auto;
    left: 24px;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===================================================================
   CHAT HEADER
   =================================================================== */
.chat-header {
    background: var(--chat-user-bg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff !important;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.chat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
}

.chat-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===================================================================
   CHAT MESSAGES
   =================================================================== */
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chat-bg);
    min-height: 0;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

/* Message Bubbles */
.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.bot {
    align-self: flex-start;
}

.is-rtl .chat-message.user {
    align-self: flex-start;
}

.is-rtl .chat-message.bot {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: var(--chat-user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.is-rtl .chat-message.user .message-bubble {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

.chat-message.bot .message-bubble {
    background: var(--chat-bot-bg);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.is-rtl .chat-message.bot .message-bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

/* Add to FAQ Button */
.faq-add-hint {
    font-size: 12px;
    color: var(--chat-text-light);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 12px;
    text-align: center;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.add-faq-btn {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px dashed var(--chat-primary);
    color: var(--chat-primary);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.add-faq-btn:hover {
    background: var(--chat-primary);
    border-style: solid;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.add-faq-btn.added {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    border-style: solid;
    color: #fff;
    pointer-events: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bot-bg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chat-text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===================================================================
   CHAT INPUT AREA
   =================================================================== */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-bg);
    flex: 0 0 auto;
    min-height: 70px;
}

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--chat-bot-bg);
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    border: 1px solid var(--chat-border);
    transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
    border-color: var(--chat-primary);
}

#nexus-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    color: var(--chat-text);
    font-family: inherit;
    max-height: 100px;
    min-height: 24px;
}

#nexus-chat-input:focus {
    outline: none;
}

#nexus-chat-input::placeholder {
    color: var(--chat-text-light);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-user-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-footer {
    text-align: center;
    margin-top: 10px;
    font-size: 11px;
    color: var(--chat-text-light);
}

/* ===================================================================
   FAQ SECTION STYLES (أسئلة من الزوار)
   =================================================================== */
.nexus-faq-section {
    margin: 2.5rem 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 20px;
    overflow: hidden;
}

.nexus-faq-section .faq-title {
    font-size: 1.3rem;
    margin: 0;
    padding: 18px 24px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    border-radius: 16px 16px 0 0;
    letter-spacing: -0.01em;
}

.nexus-faq-section .faq-title::before {
    content: '';
    display: none;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-top: none;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    border: none;
    border-bottom: 1px solid var(--border-color, #e8e8e8);
    border-radius: 0;
    overflow: hidden;
    transition: background 0.2s;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item:hover {
    background: rgba(102, 126, 234, 0.04);
}

.faq-question {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    text-align: inherit;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    font-weight: 600;
    color: var(--heading-color, #121212);
    font-family: inherit;
    transition: all 0.2s;
}

.faq-question:hover {
    color: #667eea;
    padding-inline-start: 24px;
}

.faq-question .faq-icon {
    flex-shrink: 0;
    transition: transform 0.3s;
    color: var(--primary-color, #1a73e8);
}

.faq-answer {
    display: none;
    padding: 20px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-color, #1a1a1a);
    background: var(--card-bg, #fff);
    border-top: 1px solid var(--border-color, #e0e0e0);
}

/* Dark Mode for FAQ */
[data-theme="dark"] .nexus-faq-section,
.dark-mode .nexus-faq-section {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .faq-item,
.dark-mode .faq-item {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .faq-question,
.dark-mode .faq-question {
    background: #1e293b;
    color: #ffffff !important;
}

[data-theme="dark"] .faq-question:hover,
.dark-mode .faq-question:hover {
    background: #0f172a;
}

[data-theme="dark"] .faq-answer,
.dark-mode .faq-answer {
    background: #1e293b;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .faq-answer p,
.dark-mode .faq-answer p {
    color: #e2e8f0 !important;
}

/* FAQ Chat Badge - Questions from AI Chat */
.faq-chat-badge,
.ai-chat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    margin-inline-start: 10px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.faq-item.from-ai-chat {
    border-color: rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
}

.faq-item.from-ai-chat .faq-question {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

.faq-item.from-ai-chat:hover {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
}

/* Dark Mode Badge */
[data-theme="dark"] .faq-chat-badge,
.dark-mode .faq-chat-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] .faq-item.from-ai-chat,
.dark-mode .faq-item.from-ai-chat {
    border-color: rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

[data-theme="dark"] .faq-item.from-ai-chat .faq-question,
.dark-mode .faq-item.from-ai-chat .faq-question {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 480px) {
    .nexus-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .is-rtl .nexus-chat-toggle {
        right: auto;
        left: 16px;
    }

    .nexus-chat-panel {
        bottom: 80px;
        right: 12px;
        left: 12px;
        width: auto;
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 16px;
    }

    .is-rtl .nexus-chat-panel {
        right: 12px;
        left: 12px;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .message-bubble {
        font-size: 13px;
    }
}