/* ARQUIVO: IA/css/chat.css */

:root {
    --ess-bg-0: #f5f7f2;
    --ess-bg-1: #eef4e8;
    --ess-surface: #fbfdf9;
    --ess-surface-strong: #ffffff;
    --ess-border: #d9e3d2;
    --ess-text: #1f2a1f;
    --ess-muted: #607063;
    --ess-brand-1: #4c8c42;
    --ess-brand-2: #6bb15d;
    --ess-brand-3: #2f5f3a;
    --ess-shadow: 0 14px 40px rgba(24, 40, 21, 0.12);
}

/* Layout Full Height (Ocupa tela toda) */
.content-area.chat-layout {
    height: 100vh;
    padding: 22px !important;
    display: flex;
    justify-content: center;
    background:
        radial-gradient(1200px 540px at 12% -5%, #dceccc 0%, transparent 55%),
        radial-gradient(800px 360px at 92% 108%, #d7ebcf 0%, transparent 58%),
        linear-gradient(180deg, var(--ess-bg-0) 0%, var(--ess-bg-1) 100%);
    overflow: hidden; 
}

.chat-container {
    width: 100%;
    max-width: 1020px;
    height: 100%;
    background: color-mix(in srgb, var(--ess-surface) 90%, white 10%);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ess-border);
    border-radius: 20px;
    box-shadow: var(--ess-shadow);
    overflow: hidden;
    position: relative;
}

/* Header */
.chat-header {
    min-height: 88px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--ess-border);
    display: flex; justify-content: space-between; align-items: center;
    background: color-mix(in srgb, white 75%, #f2f7ec 25%);
    flex-shrink: 0;
    position: relative;
    isolation: isolate;
}

.header-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, rgba(76, 140, 66, 0.12), transparent 45%, rgba(107, 177, 93, 0.1));
    pointer-events: none;
    z-index: -1;
}

.ai-profile { display: flex; align-items: center; gap: 15px; }
.ai-avatar-wrapper {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 28% 24%, #82ce72 0%, var(--ess-brand-2) 40%, var(--ess-brand-1) 100%);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 8px 18px rgba(63, 115, 56, 0.28);
}

.ai-info h2 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.22rem;
    line-height: 1.2;
    color: #1a2619;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.status-indicator {
    font-size: 0.82rem;
    color: var(--ess-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.ai-subtitle {
    display: block;
    font-size: 0.78rem;
    color: #70816f;
    margin-top: 4px;
    font-weight: 600;
}

.dot.online {
    width: 8px;
    height: 8px;
    background: #58d447;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(88, 212, 71, 0.2);
}

.icon-btn-ghost {
    background: rgba(76, 140, 66, 0.08);
    border: 1px solid rgba(76, 140, 66, 0.18);
    color: #4a5b4d;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.2s ease;
    display: flex; align-items: center; justify-content: center;
}

.icon-btn-ghost:hover {
    background: rgba(76, 140, 66, 0.14);
    color: #2d4734;
    transform: translateY(-1px);
}

/* Área de Mensagens */
.chat-messages-area {
    flex: 1;
    padding: 22px 24px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 15px;
    background-color: #f7faf4;
    background-image:
        radial-gradient(rgba(74, 112, 64, 0.1) 1px, transparent 1px),
        radial-gradient(rgba(74, 112, 64, 0.08) 1px, transparent 1px);
    background-position: 0 0, 10px 10px;
    background-size: 22px 22px;
}

.message {
    display: flex; flex-direction: column;
    max-width: min(86%, 680px);
    animation: slideIn 0.28s ease;
}

.message-content {
    padding: 12px 15px;
    border-radius: 16px;
    font-size: 0.96rem;
    line-height: 1.58;
    position: relative; word-wrap: break-word;
    box-shadow: 0 8px 18px rgba(34, 52, 34, 0.08);
}

/* Balão do Usuário (Verde) */
.user-message { align-self: flex-end; align-items: flex-end; }
.user-message .message-content {
    background: linear-gradient(145deg, var(--ess-brand-2), var(--ess-brand-1));
    color: #ffffff;
    border-bottom-right-radius: 6px;
    border: 1px solid rgba(43, 91, 49, 0.28);
}

/* Balão da IA (Branco) */
.ai-message { align-self: flex-start; align-items: flex-start; }
.ai-message .message-content {
    background: linear-gradient(180deg, #ffffff 0%, #f9fcf6 100%);
    color: var(--ess-text);
    border-bottom-left-radius: 6px;
    border: 1px solid #d8e2d1;
}

.ai-message strong { color: #3d7a3a; font-weight: 800; }

.chat-heading {
    margin: 4px 0 7px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    color: #2d4f2f;
}

.chat-divider {
    border: none;
    border-top: 1px dashed #c5d6bf;
    margin: 8px 0;
}

.chat-code {
    background: #edf5e8;
    color: #24462a;
    border: 1px solid #d2e2cb;
    border-radius: 6px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.86rem;
}

.message-content li {
    margin-left: 16px;
    padding-left: 2px;
}

.message-time {
    font-size: 0.72rem;
    color: #7d8d80;
    margin-top: 5px;
    padding: 0 4px;
    font-weight: 600;
}

/* Input */
.chat-input-area {
    padding: 14px 20px 16px;
    background: linear-gradient(180deg, #fdfefb 0%, #f7fbf3 100%);
    border-top: 1px solid var(--ess-border);
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.quick-prompt-btn {
    border: 1px solid #cfdeca;
    background: #f4faef;
    color: #416443;
    border-radius: 999px;
    font-size: 0.77rem;
    font-weight: 700;
    padding: 7px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-prompt-btn:hover {
    transform: translateY(-1px);
    border-color: #9fc492;
    background: #ebf6e4;
    color: #2f5a34;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    background: #f1f7ec;
    padding: 8px 8px 8px 16px;
    border-radius: 18px;
    align-items: flex-end;
    border: 1px solid #d2e1cd;
    transition: 0.2s ease;
}

.input-wrapper:focus-within {
    background: #ffffff;
    border-color: #78ac6b;
    box-shadow: 0 0 0 4px rgba(108, 177, 93, 0.16);
}

#user-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: 'Lato', sans-serif;
    font-size: 0.98rem;
    color: #253725;
    max-height: 120px;
    padding: 9px 0;
}

#user-input::placeholder {
    color: #859487;
}

.btn-send-ai {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(43, 91, 49, 0.35);
    background: linear-gradient(145deg, #6ab75e, #4c8d42);
    color: white;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    transition: 0.2s ease;
    box-shadow: 0 10px 16px rgba(56, 104, 53, 0.28);
}

.btn-send-ai:disabled {
    background: #e8efe4;
    color: #a8b4a4;
    border-color: #d2ddd0;
    box-shadow: none;
    cursor: default;
}

.btn-send-ai:not(:disabled):hover {
    transform: translateY(-1px) scale(1.03);
    background: linear-gradient(145deg, #5da752, #3d7636);
}

.disclaimer-text {
    text-align: center;
    font-size: 0.74rem;
    color: #91a08f;
    margin-top: 9px;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .content-area.chat-layout {
        padding: 0 !important;
    }

    .chat-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
}

@media (max-width: 700px) {
    .chat-header {
        padding: 10px 14px;
    }

    .ai-subtitle {
        display: none;
    }

    .chat-messages-area {
        padding: 14px 12px;
        gap: 12px;
    }

    .message {
        max-width: 92%;
    }

    .chat-input-area {
        padding: 12px 10px 14px;
    }

    .quick-prompts {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .quick-prompt-btn {
        white-space: nowrap;
    }
}

/* Sidebar search aligned with other sections */
.sidebar-search,
.mobile-menu-search {
    padding: 10px 15px;
    position: relative;
}

.sidebar-search i,
.mobile-menu-search i {
    position: absolute;
    top: 50%;
    left: 28px;
    transform: translateY(-50%);
    color: #aaa;
}

.sidebar-search input,
.mobile-menu-search input {
    width: 100%;
    padding: 8px 8px 8px 35px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background-color: #f0f2f5;
    font-family: 'Lato', sans-serif;
}

.mobile-menu-search input {
    background-color: #fff;
}

/* Animação de Loading (Três pontos) */
.typing { display: flex; gap: 5px; padding: 15px !important; }
.dot-anim {
    width: 6px; height: 6px; background: #b0b3b8; border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot-anim:nth-child(1) { animation-delay: -0.32s; }
.dot-anim:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =======================================================
 * OFF-CANVAS SEARCH DRAWER (PORTAL PATTERN) - GLOBAL
 * ======================================================= */
.insta-search-drawer {
    position: fixed; top: 0; left: 0; width: 100%; max-width: 350px; height: 100vh;
    background-color: #ffffff; box-shadow: 4px 0 15px rgba(0,0,0,0.1); z-index: 10000; 
    transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex; flex-direction: column;
}
.insta-search-drawer.active { transform: translateX(0); }
.insta-drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 15px 15px; }
.insta-drawer-header h2 { font-size: 1.2rem; font-weight: 800; color: #1a1a1a; margin: 0; }
.insta-close-btn { background: none; border: none; font-size: 1.2rem; color: #65676b; cursor: pointer; transition: color 0.2s ease; }
.insta-close-btn:hover { color: #e74c3c; }

/* Input Trapping Box */
.insta-drawer-search-container { padding: 0 15px 15px; border-bottom: 1px solid #eaeaea; }
.insta-input-wrapper { position: relative; width: 100%; }
.insta-input-wrapper i { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: #8e8e8e; font-size: 0.9rem; pointer-events: none; }
.insta-drawer-input { width: 100%; padding: 10px 10px 10px 35px; background-color: #efefef; border: none; border-radius: 8px; font-size: 0.95rem; color: #1a1a1a; outline: none; transition: background-color 0.2s; }
.insta-drawer-input:focus { background-color: #e4e4e4; }

/* UX: Sidebar trigger read-only feel */
.sidebar-search input, .mobile-menu-search input { cursor: pointer; }

/* Content Rendering */
.insta-results-area { padding: 15px; overflow-y: auto; flex: 1; }
.insta-user-item { display: flex; align-items: center; padding: 10px; text-decoration: none; color: inherit; border-radius: 8px; transition: background-color 0.2s ease; cursor: pointer; }
.insta-user-item:hover { background-color: #f0f2f5; }
.insta-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; margin-right: 12px; border: 1px solid #eaeaea; }
.insta-user-info { display: flex; flex-direction: column; overflow: hidden; }
.insta-username { font-weight: 700; font-size: 0.95rem; color: #1a1a1a; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.insta-name { font-size: 0.85rem; color: #65676b; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* States */
.insta-state-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 10px; color: #65676b; }
.insta-state-title { font-weight: 700; color: #1a1a1a; margin-bottom: 5px; }
.insta-state-desc { font-size: 0.9rem; }
.insta-loader-container { display: flex; justify-content: center; padding: 30px 0; }
.insta-spinner { width: 30px; height: 30px; border: 3px solid #f3f3f3; border-top: 3px solid #53954a; border-radius: 50%; animation: insta-spin 1s linear infinite; }
@keyframes insta-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }