/* =============================================
   AI Chat Widget Styles
   Extracted from article.php inline <style>
   ============================================= */

/* --- Base widget --- */
.article-ai-chat {
    margin-top: 32px;
    margin-bottom: 32px;
    border: 1px solid rgba(227, 195, 122, 0.35);
    border-radius: 18px;
    background: linear-gradient(160deg, #fffef9 0%, #fff8e8 100%);
    box-shadow: 0 8px 32px rgba(46, 35, 7, 0.07), 0 1px 3px rgba(46, 35, 7, 0.04);
    overflow: hidden;
    position: relative;
}

/* --- Sidebar variant — compact for right sidebar --- */
.article-ai-chat--sidebar {
    margin: 0;
    border-radius: 14px;
    font-size: 13px;
}
.article-ai-chat--sidebar .article-ai-chat__log {
    max-height: 320px;
}
.article-ai-chat--sidebar .article-ai-chat__title {
    font-size: 15px;
}
.article-ai-chat--sidebar .article-ai-chat__subtitle {
    font-size: 11.5px;
}
.article-ai-chat--sidebar .ai-chat-msg {
    font-size: 13px;
    padding: 8px 12px;
}
.article-ai-chat--sidebar .article-ai-chat__input {
    font-size: 13px;
    min-height: 38px;
}
.article-ai-chat--sidebar .article-ai-chat__call-btn span {
    display: none;
}
.article-ai-chat--sidebar .article-ai-chat__call-btn {
    padding: 7px 10px;
}
.article-ai-chat--sidebar .ai-chat-phone-prompt {
    max-width: 100%;
}
.article-ai-chat--sidebar .ai-chat-phone-prompt__row {
    flex-direction: column;
}
.article-ai-chat--sidebar .ai-chat-phone-prompt__send {
    width: 100%;
    text-align: center;
}

/* --- Fullscreen overlay — appended to body --- */
.ai-chat-fullscreen-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    background: rgba(20, 15, 5, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: aiChatFadeIn 0.25s ease;
}

@keyframes aiChatFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-chat-fullscreen-overlay .ai-chat-fullscreen-box {
    width: 100%;
    max-width: 720px;
    height: 85vh;
    max-height: 700px;
    background: linear-gradient(160deg, #fffef9 0%, #fff8e8 100%);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(20, 15, 5, 0.25), 0 0 0 1px rgba(227, 195, 122, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiChatSlideUp 0.3s ease;
}

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

.ai-chat-fullscreen-overlay .ai-chat-fullscreen-box .ai-chat-fs-log {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fffdf9;
}

.ai-chat-fullscreen-overlay .ai-chat-fs-form {
    padding: 14px 16px;
    border-top: 1px solid rgba(227, 195, 122, 0.3);
    background: #fffdf8;
}

/* --- Header --- */
.article-ai-chat__head {
    padding: 14px 18px 12px;
    border-bottom: 1px solid rgba(227, 195, 122, 0.25);
    background: linear-gradient(90deg, rgba(227, 195, 122, 0.15), rgba(227, 195, 122, 0.05));
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.article-ai-chat__head-text {
    flex: 1;
    min-width: 0;
}

.article-ai-chat__head-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.article-ai-chat__head-btn {
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(47, 36, 20, 0.12);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a7450;
    transition: all 0.2s ease;
}

.article-ai-chat__head-btn:hover {
    background: rgba(227, 195, 122, 0.25);
    color: #2f2414;
    border-color: rgba(207, 167, 76, 0.4);
}

.article-ai-chat__head-btn svg {
    width: 17px;
    height: 17px;
}

/* --- Call button --- */
.article-ai-chat__call-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #2f7d32 0%, #388e3c 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.article-ai-chat__call-btn:hover {
    background: linear-gradient(135deg, #256d28 0%, #2e7d32 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(47, 125, 50, 0.25);
}

.article-ai-chat__call-btn svg {
    width: 15px;
    height: 15px;
}

/* --- Title / Subtitle --- */
.article-ai-chat__title {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #2f2414;
    line-height: 1.3;
}

.article-ai-chat__subtitle {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: #8a7450;
    line-height: 1.35;
}

/* --- Chat log --- */
.article-ai-chat__log {
    max-height: 380px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fffdf9;
}

.article-ai-chat__log::-webkit-scrollbar { width: 5px; }
.article-ai-chat__log::-webkit-scrollbar-track { background: transparent; }
.article-ai-chat__log::-webkit-scrollbar-thumb { background: rgba(207,167,76,0.3); border-radius: 10px; }

/* --- Messages --- */
.ai-chat-msg {
    max-width: 88%;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid transparent;
}

.ai-chat-msg--assistant {
    align-self: flex-start;
    background: #f6eed8;
    border-color: rgba(227, 195, 122, 0.35);
    color: #2e2418;
    border-bottom-left-radius: 4px;
}

.ai-chat-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #3a2e1a 0%, #2f2414 100%);
    border-color: transparent;
    color: #f8f2e5;
    border-bottom-right-radius: 4px;
}

/* --- Typing indicator --- */
.ai-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: #f6eed8;
    border: 1px solid rgba(227, 195, 122, 0.35);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.ai-chat-typing__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b8a06a;
    animation: aiChatTyping 1.4s infinite ease-in-out;
}

.ai-chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

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

/* --- Meta (sources, suggestions) --- */
.ai-chat-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(47, 36, 20, 0.15);
    font-size: 13px;
}

.ai-chat-meta-title {
    margin: 0 0 5px;
    font-weight: 600;
    color: #5a4a2e;
}

.ai-chat-meta ul {
    margin: 0;
    padding-left: 18px;
}

.ai-chat-meta li {
    margin-bottom: 4px;
}

.ai-chat-meta a {
    color: #8b6914;
    text-decoration: underline;
    text-decoration-color: rgba(139,105,20,0.3);
}

.ai-chat-meta a:hover {
    color: #2f2414;
}

/* --- Phone prompt (lead form) --- */
.ai-chat-phone-prompt {
    align-self: flex-start;
    background: linear-gradient(135deg, #f6eed8 0%, #f0e6c4 100%);
    border: 1px solid rgba(227, 195, 122, 0.4);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 14px;
    font-size: 14px;
    max-width: 88%;
}

.ai-chat-phone-prompt p {
    margin: 0 0 10px;
    color: #2e2418;
    line-height: 1.45;
}

.ai-chat-phone-prompt__row {
    display: flex;
    gap: 8px;
}

.ai-chat-phone-prompt__input {
    flex: 1;
    border: 1px solid rgba(47, 36, 20, 0.2);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: #2e2418;
    background: #fff;
    transition: border-color 0.2s;
}

.ai-chat-phone-prompt__input:focus {
    outline: none;
    border-color: #cfa74c;
    box-shadow: 0 0 0 3px rgba(207,167,76,0.15);
}

.ai-chat-phone-prompt__send {
    background: linear-gradient(135deg, #2f7d32 0%, #388e3c 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.ai-chat-phone-prompt__send:hover {
    background: linear-gradient(135deg, #256d28 0%, #2e7d32 100%);
    box-shadow: 0 2px 8px rgba(47,125,50,0.2);
}

/* --- Input form --- */
.article-ai-chat__form {
    padding: 12px 14px;
    border-top: 1px solid rgba(227, 195, 122, 0.25);
    background: #fffdf8;
}

.article-ai-chat__input-wrap {
    position: relative;
    display: flex;
    align-items: flex-end;
    border: 1.5px solid rgba(47, 36, 20, 0.15);
    border-radius: 14px;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.article-ai-chat__input-wrap:focus-within {
    border-color: #cfa74c;
    box-shadow: 0 0 0 3px rgba(207, 167, 76, 0.15);
}

.article-ai-chat__input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border: none;
    background: transparent;
    padding: 11px 50px 11px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #2e2418;
    line-height: 1.45;
    outline: none;
}

.article-ai-chat__send {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #3a2e1a 0%, #2f2414 100%);
    color: #f8f2e5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.article-ai-chat__send:hover {
    opacity: 0.88;
    transform: scale(1.06);
    box-shadow: 0 2px 8px rgba(47,36,20,0.2);
}

.article-ai-chat__send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.article-ai-chat__send svg {
    width: 17px;
    height: 17px;
}

/* --- Status bar --- */
.article-ai-chat__status {
    min-height: 0;
    font-size: 13px;
    color: #8a7450;
    padding: 0 14px 10px;
}

.article-ai-chat__status:empty {
    display: none;
}

.article-ai-chat__status.error {
    color: #b23a2f;
}

.article-ai-chat__status.success {
    color: #2f7d32;
}

/* --- Mobile responsive --- */
@media (max-width: 768px) {
    .article-ai-chat__log {
        max-height: 300px;
    }
    .article-ai-chat__call-btn span {
        display: none;
    }
    .article-ai-chat__call-btn {
        padding: 7px 10px;
    }
    .ai-chat-fullscreen-overlay {
        padding: 0;
    }
    .ai-chat-fullscreen-overlay .ai-chat-fullscreen-box {
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .ai-chat-fullscreen-overlay .ai-chat-fs-log {
        padding: 12px;
    }
    .ai-chat-fullscreen-overlay .ai-chat-fs-form {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}
