/* =========================
   AI CHAT — tema verde floresta (Zanaga Tecnologia)
========================= */

.session-title-input {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    outline: none;
}

    .session-title-input:focus {
        border-bottom: 1px solid #81c784;
    }

/* =========================
   LAYOUT BASE
========================= */

.layout {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* =========================
   SIDEBAR CHAT (ESTILIZADA)
========================= */

.sidebar-chat {
    margin-top: 5%;
    width: 260px;
    background: linear-gradient(180deg, #0a1a10, #06120b);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e3a26;
    height: 80%;
    box-shadow: 4px 0 24px rgba(12, 61, 28, 0.35);
}

/* HEADER */

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #1e3a26;
}

/* BOTÃO NOVA CONVERSA */

.new-chat {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #2e9e41, #2e7d32);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.35);
}

    .new-chat:hover {
        transform: translateY(-1px);
        background: linear-gradient(90deg, #4caf50, #2e9e41);
        box-shadow: 0 4px 14px rgba(76, 175, 80, 0.45);
    }

/* LISTA */

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ITEM */

.session-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    color: #cde8cf;
    transition: all 0.2s ease;
}

    /* hover */

    .session-item:hover {
        background: rgba(76, 175, 80, 0.10);
        border-color: rgba(76, 175, 80, 0.22);
    }

    /* ativo */

    .session-item.active {
        background: linear-gradient(90deg, #2e9e41, #2e7d32);
        color: white;
        box-shadow: 0 2px 10px rgba(46, 125, 50, 0.35);
    }

.session-content {
    flex: 1;
    min-width: 0;
}

/* título */

.session-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* botões da sidebar (excluir / renomear) */

.delete-session-btn,
.rename-session-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9fbca3;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 3px 5px;
    opacity: 0;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

    .delete-session-btn:hover {
        background: rgba(229, 57, 53, 0.18);
        color: #ef9a9a;
    }

    .rename-session-btn:hover {
        background: rgba(76, 175, 80, 0.18);
        color: #a5d6a7;
    }

    .session-item:hover .delete-session-btn,
    .session-item:hover .rename-session-btn,
    .session-item.active .rename-session-btn {
        opacity: 1;
    }

/* overlay mobile */

/* overlay: só existe no mobile (drawer); no desktop não bloqueia nada */
.sidebar-overlay {
    display: none;
}

/* scrollbar bonita */

.sessions-list::-webkit-scrollbar {
    width: 6px;
}

.sessions-list::-webkit-scrollbar-thumb {
    background: #24422f;
    border-radius: 4px;
}

/* =========================
   RESPONSIVO
========================= */

@media (max-width: 900px) {

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(4, 14, 8, 0.55);
        z-index: 15;
    }

    .sidebar-chat {
        position: absolute;
        z-index: 20;
        left: 0;
        top: 0;
        height: 100vh;
        width: 240px;
        padding: 20px 10px;
        box-shadow: 6px 0 24px rgba(6, 18, 11, 0.6);
        height: 90%;
    }
}

/* =========================
   WRAPPER (ESSENCIAL)
========================= */

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 🔥 alinha com sidebar */
}

/* =========================
   CHAT CONTAINER
========================= */

.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    height: calc(100vh - 140px);
    margin: 20px 0;
    border: 1px solid #1e3a26;
    border-radius: 16px;
    background: linear-gradient(180deg, #0e1a12, #0c160e);
    overflow: hidden;
    margin-left: 5%;
    box-shadow: 0 10px 40px rgba(12, 61, 28, 0.35);
}

/* =========================
   HEADER
========================= */

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid #1e3a26;
    background: rgba(76, 175, 80, 0.06);
}

    .chat-header h2 {
        margin: 0;
        color: #a5d6a7;
        font-size: 1.1rem;
        letter-spacing: 0.02em;
    }

    .chat-header h2::before {
        content: "";
        display: inline-block;
        width: 9px;
        height: 9px;
        margin-right: 9px;
        border-radius: 50%;
        background: #4caf50;
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.9);
    }

.menu-btn {
    background: linear-gradient(135deg, #2e9e41, #2e7d32);
    border: none;
    color: white;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .menu-btn:hover {
        background: linear-gradient(135deg, #4caf50, #2e9e41);
        transform: translateY(-1px);
    }

/* =========================
   SELETOR DE MODELOS (OllamaLive)
========================= */

.ollama-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    padding: 8px 0;
}

.ollama-selector {
    width: 100%;
    max-width: 720px;
    margin: 12px auto 0;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(76, 175, 80, 0.06);
    border: 1px solid #1e3a26;
    border-radius: 14px;
}

.ollama-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ollama-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.ollama-label {
    flex: 0 0 auto;
    min-width: 170px;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: right;
}

/* seta customizada em data-uri: o style.css global remove o appearance
   nativo (appearance: unset !important), então desenhamos a seta nós mesmos */
.ollama-select {
    appearance: none !important;
    -moz-appearance: none !important;
    -webkit-appearance: none !important;
    width: 100%;
    padding: 0.5rem 2.2rem 0.5rem 0.85rem;
    font-size: 0.9rem;
    color: #e8f5e9;
    background-color: #16241b;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234caf50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1px solid #24422f;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    text-overflow: ellipsis;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .ollama-select:hover {
        border-color: #2e7d32;
    }

    .ollama-select:focus {
        border-color: #4caf50;
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.22);
    }

    /* popup nativo do combo: força modo escuro para o texto
       do browser não ficar escuro/ilegível */
    .ollama-select {
        color-scheme: dark;
    }

    .ollama-select option,
    .ollama-select optgroup {
        background: #101d15;
        color: #ffffff;
    }

    .ollama-select option:checked,
    .ollama-select option:hover {
        background: #2e7d32;
        color: #ffffff;
    }

.ollama-alert {
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
}

    .ollama-alert-success {
        background: rgba(76, 175, 80, 0.10);
        border: 1px solid rgba(76, 175, 80, 0.30);
        color: #cde8cf;
    }

    .ollama-alert-warning {
        background: rgba(255, 193, 7, 0.10);
        border: 1px solid rgba(255, 193, 7, 0.30);
        color: #ffe08a;
    }

    .ollama-alert-danger {
        background: rgba(229, 57, 53, 0.10);
        border: 1px solid rgba(229, 57, 53, 0.30);
        color: #ef9a9a;
        margin: 12px 16px 0;
    }

/* =========================
   MESSAGES
========================= */

.messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    list-style: none;
    width: 100%;
}

/* USER */

.user-message {
    display: flex;
    justify-content: flex-end;
}

    .user-message .message {
        background: linear-gradient(135deg, #2e9e41, #2e7d32);
        color: white;
        padding: 10px 14px;
        border-radius: 14px 14px 4px 14px;
        box-shadow: 0 2px 10px rgba(46, 125, 50, 0.35);
        max-width: 70%;
        word-break: break-word;
    }

/* BOT */

.bot-message {
    display: flex;
    justify-content: flex-start;
}

    .bot-message .message {
        background: #16241b;
        color: #dcead9;
        padding: 10px 14px;
        border-radius: 14px 14px 14px 4px;
        border: 1px solid #223c2b;
        max-width: 95%;
        width: fit-content;
    }

/* =========================
   CODE (USER)
========================= */

.user-code {
    background: transparent;
    color: inherit;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
    tab-size: 4;
    margin: 0;
}

/* =========================
   INPUT
========================= */

.chat-container footer {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #1e3a26;
    background: rgba(76, 175, 80, 0.04);
}

.chat-container textarea {
    flex: 1;
    min-height: 80px;
    max-height: 200px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #24422f;
    outline: none;
    background: #16241b;
    color: #e8f5e9;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
    tab-size: 4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .chat-container textarea:focus {
        border-color: #4caf50;
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.22);
    }

.chat-container button {
    padding: 0 22px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #2e9e41, #2e7d32);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.30);
}

    .chat-container button:hover {
        background: linear-gradient(135deg, #4caf50, #2e9e41);
        transform: translateY(-1px);
    }

/* =========================
   ACTIONS
========================= */

.actions-bar {
    width: 190%;
    max-width: 1200px;
    display: flex;
    gap: 10px;
    height: 50px;
    margin-bottom: 10px;
    margin-left: 5%;
}

.actions-bar button.btn-primary {
    background: linear-gradient(135deg, #2e9e41, #2e7d32);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.55rem 1.1rem;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.30);
}

.actions-bar button.btn-primary:hover {
    background: linear-gradient(135deg, #4caf50, #2e9e41);
    transform: translateY(-1px);
}

/* =========================
   LOADING / THINKING
========================= */

.loading {
    text-align: center;
    opacity: 0.7;
}

.dots::after {
    content: "…";
    display: inline-block;
    width: 1.4em;
    text-align: left;
    animation: zanaga-blink 1.2s infinite;
}

@keyframes zanaga-blink {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
    100% { content: ""; }
}

.thinking {
    color: #81c784;
    font-style: italic;
}

/* =========================
   RESPONSIVO
========================= */

@media (max-width: 900px) {

    .chat-container {
        height: calc(100vh - 100px);
    }

    .user-message .message,
    .bot-message .message {
        max-width: 90%;
    }
}

@media (max-width: 600px) {

    .chat-container footer {
        flex-direction: column;
        margin-left: 0px;
    }

    .chat-container button {
        width: 100%;
    }
}