/**
 * PraisonAI Chat Widget Styles
 * Scoped under .ai-chat-wrapper — only affects AI pages, no site-wide impact
 */

/* ================================
   Wrapper (scoped) — wide centred
   ================================ */
.ai-chat-wrapper {
    font-family: 'Inter', 'Noto Sans Tamil', system-ui, -apple-system, sans-serif;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px 40px;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

/*
 * Override Twenty Seventeen two-column layout on AI pages.
 * The plugin removes 'page-two-column' from body and adds
 * 'praison-ai-page' — these rules are a CSS safety net.
 */
.praison-ai-page #primary .entry-header,
.praison-ai-page #primary .entry-content {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Hide sidebar on AI pages */
.praison-ai-page .widget-area {
    display: none;
}

/* ================================
   Hero Section
   ================================ */
.ai-chat-wrapper .ai-hero {
    text-align: center;
    padding: 40px 0 28px;
    position: relative;
}

.ai-chat-wrapper .ai-hero-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 180px;
    background: radial-gradient(ellipse, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.ai-chat-wrapper .ai-hero-bible .ai-hero-glow {
    background: radial-gradient(ellipse, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
}

.ai-chat-wrapper .ai-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 8px;
    position: relative;
    z-index: 1;
}

.ai-chat-wrapper .ai-hero-bible .ai-title {
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.ai-chat-wrapper .ai-subtitle {
    color: #6b7280;
    font-size: 14px;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

/* ================================
   Chat Container — full width
   ================================ */
.ai-chat-wrapper .ai-chat-container {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fafbfc;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ================================
   Messages — taller area
   ================================ */
.ai-chat-wrapper .ai-messages {
    padding: 24px;
    min-height: 60vh;
    max-height: 75vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.ai-chat-wrapper .ai-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: praison-fade-in 0.3s ease;
}

@keyframes praison-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.ai-chat-wrapper .ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.ai-chat-wrapper .ai-message-user .ai-avatar {
    background: #ede9fe;
    border-color: #c4b5fd;
}

/* ================================
   Bubble — wider for content
   ================================ */
.ai-chat-wrapper .ai-bubble {
    max-width: 90%;
    padding: 14px 20px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    line-height: 1.7;
    font-size: 15px;
    color: #1f2937;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-chat-wrapper .ai-message-user .ai-bubble {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

/* ================================
   Markdown Elements in Bubble
   ================================ */
.ai-chat-wrapper .ai-bubble p {
    margin: 0 0 8px;
}

.ai-chat-wrapper .ai-bubble p:last-child {
    margin: 0;
}

.ai-chat-wrapper .ai-bubble strong {
    font-weight: 600;
    color: #111827;
}

.ai-chat-wrapper .ai-bubble em {
    font-style: italic;
    color: #374151;
}

.ai-chat-wrapper .ai-bubble h1,
.ai-chat-wrapper .ai-bubble h2,
.ai-chat-wrapper .ai-bubble h3,
.ai-chat-wrapper .ai-bubble h4 {
    margin: 16px 0 8px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.ai-chat-wrapper .ai-bubble h1:first-child,
.ai-chat-wrapper .ai-bubble h2:first-child,
.ai-chat-wrapper .ai-bubble h3:first-child,
.ai-chat-wrapper .ai-bubble h4:first-child {
    margin-top: 0;
}

.ai-chat-wrapper .ai-bubble h1 {
    font-size: 20px;
}

.ai-chat-wrapper .ai-bubble h2 {
    font-size: 18px;
}

.ai-chat-wrapper .ai-bubble h3 {
    font-size: 16px;
    color: #4338ca;
}

.ai-chat-wrapper .ai-bubble h4 {
    font-size: 15px;
}

.ai-chat-wrapper .ai-bubble a {
    color: #6366f1;
    text-decoration: none;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    transition: border-color 0.2s;
}

.ai-chat-wrapper .ai-bubble a:hover {
    border-color: #6366f1;
}

.ai-chat-wrapper .ai-message-user .ai-bubble a {
    color: #e0e7ff;
    border-bottom-color: rgba(224, 231, 255, 0.4);
}

.ai-chat-wrapper .ai-bubble ol,
.ai-chat-wrapper .ai-bubble ul {
    padding-left: 22px;
    margin: 8px 0;
}

.ai-chat-wrapper .ai-bubble li {
    margin-bottom: 4px;
    line-height: 1.6;
}

.ai-chat-wrapper .ai-bubble blockquote {
    border-left: 3px solid #7c3aed;
    margin: 8px 0;
    padding: 8px 16px;
    background: #f5f3ff;
    border-radius: 0 8px 8px 0;
    color: #4c1d95;
    font-style: italic;
}

.ai-chat-wrapper .ai-bubble code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    color: #e11d48;
}

.ai-chat-wrapper .ai-bubble br {
    display: block;
    content: '';
    margin-top: 6px;
}

/* ================================
   Suggestions
   ================================ */
.ai-chat-wrapper .ai-suggestions {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chat-wrapper .ai-suggestions li {
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-chat-wrapper .ai-suggestions li:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #5b21b6;
    transform: translateY(-1px);
}

/* ================================
   Typing Indicator
   ================================ */
.ai-chat-wrapper .ai-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-chat-wrapper .ai-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: praison-bounce 1.4s ease-in-out infinite;
}

.ai-chat-wrapper .ai-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-wrapper .ai-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes praison-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ================================
   Input Form
   ================================ */
.ai-chat-wrapper .ai-input-form {
    padding: 14px 20px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.ai-chat-wrapper .ai-input-wrapper {
    display: flex;
    gap: 8px;
    border: 2px solid #d1d5db;
    border-radius: 12px;
    padding: 3px 3px 3px 16px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-wrapper .ai-input-wrapper:focus-within {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.ai-chat-wrapper #aiInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #1f2937;
    font-size: 15px;
    font-family: inherit;
    padding: 10px 0;
}

.ai-chat-wrapper #aiInput::placeholder {
    color: #9ca3af;
}

.ai-chat-wrapper #aiSend {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.ai-chat-wrapper #aiSend:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.ai-chat-wrapper #aiSend:active {
    transform: scale(0.95);
}

.ai-chat-wrapper #aiSend:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-wrapper .ai-disclaimer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin: 8px 0 0;
}

/* ================================
   Responsive
   ================================ */
@media (max-width: 640px) {
    .ai-chat-wrapper {
        padding: 0 0 24px;
    }

    .ai-chat-wrapper .ai-hero {
        padding: 24px 0 16px;
    }

    .ai-chat-wrapper .ai-title {
        font-size: 22px;
    }

    .ai-chat-wrapper .ai-subtitle {
        font-size: 13px;
    }

    .ai-chat-wrapper .ai-bubble {
        max-width: 95%;
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-chat-wrapper .ai-avatar {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .ai-chat-wrapper .ai-suggestions li {
        font-size: 12px;
        padding: 5px 10px;
    }

    .ai-chat-wrapper .ai-messages {
        min-height: 50vh;
        max-height: 65vh;
        padding: 14px;
    }
}

/* ================================
   Scrollbar
   ================================ */
.ai-chat-wrapper .ai-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-wrapper .ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-wrapper .ai-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}