/* ============================================================
   Inox Design — Chat Interno
   Paleta: Vermelho #cc0000 · Carvão #1e1e1e · Branco #fff
   As variáveis de branding são injetadas pelo header.php via :root{}
   ============================================================ */

/* ── Variáveis base (sobrescritas pelo header.php com valores do .env) ── */
:root {
    --sidebar-width: 260px;
    --brand-primary: #cc0000;
    --brand-on-primary: #ffffff;
    --brand-sidebar: #1e1e1e;
    --brand-sidebar-hover: #2a2a2a;
    --brand-sidebar-active: #cc0000;
    --bg-user-msg: #cc0000;
    --text-user-msg: #ffffff;
    --bg-asst-msg: #f4f4f4;
    --text-asst-msg: #2d2d2d;
    --border-radius-btn: 26px;
    --font-base: 'Open Sans', sans-serif;
}

/* ── Tipografia ─────────────────────────── */
html,
body {
    height: 100%;
    margin: 0;
    font-family: var(--font-base);
    font-size: 15px;
    color: #2d2d2d;
    background: #fff;
}

/* ── Layout geral ───────────────────────── */
.app-layout {
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════ */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--brand-sidebar);
    border-right: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-header {
    min-height: 60px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Logo na sidebar */
.sidebar-logo {
    max-height: 34px;
    max-width: 150px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Botão nova conversa (ícone) */
#btn-new-chat {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, .35);
    background: transparent;
    color: rgba(255, 255, 255, .8);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s, color .15s;
}

#btn-new-chat:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* Lista de threads */
#thread-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

#thread-list::-webkit-scrollbar {
    width: 4px;
}

#thread-list::-webkit-scrollbar-track {
    background: transparent;
}

#thread-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 4px;
}

/* Seção de label "Conversas" */
.sidebar-section-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
    padding: 8px 6px 4px;
}

.thread-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: rgba(255, 255, 255, .75);
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
    min-height: 38px;
    font-size: .855rem;
}

.thread-link:hover {
    background: var(--brand-sidebar-hover);
    color: #fff;
}

.thread-link.active {
    background: var(--brand-primary);
    color: #fff;
}

.thread-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity .15s;
}

.thread-link:hover .thread-actions {
    opacity: 1;
}

.btn-edit-thread,
.btn-delete-thread {
    color: rgba(255, 255, 255, .45) !important;
    padding: 0 !important;
    line-height: 1;
    font-size: .8rem;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    transition: color .15s;
}

.btn-edit-thread:hover,
.btn-delete-thread:hover {
    color: #fff !important;
}

/* Rodapé da sidebar */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 12px 14px;
}

.sidebar-credits {
    margin-top: 10px;
    font-size: 1rem;
    color: rgba(255, 255, 255, .2);
    text-align: center;
    letter-spacing: .03em;
}

.sidebar-credits a {
    color: rgba(255, 255, 255, .35);
    text-decoration: none;
    transition: color .15s;
}

.sidebar-credits a:hover {
    color: rgba(255, 255, 255, .7);
}

.sidebar-user-name {
    font-size: .8rem;
    color: rgba(255, 255, 255, .45);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .btn {
    font-size: .8rem;
    border-radius: var(--border-radius-btn);
    padding: 5px 14px;
    font-weight: 600;
    letter-spacing: .02em;
}

.btn-sidebar-admin {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, .25);
    color: rgba(255, 255, 255, .7);
    width: 100%;
    margin-bottom: 6px;
    transition: border-color .15s, color .15s;
}

.btn-sidebar-admin:hover {
    border-color: rgba(255, 255, 255, .6);
    color: #fff;
}

.btn-sidebar-logout {
    background: transparent;
    border: 1.5px solid rgba(204, 0, 0, .55);
    color: rgba(255, 100, 100, .85);
    width: 100%;
    transition: background .15s, color .15s;
}

.btn-sidebar-logout:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* ════════════════════════════════════════
   CHAT MAIN
   ════════════════════════════════════════ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}

/* Cabeçalho da conversa */
.chat-header {
    min-height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
}

.chat-header .chat-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .85rem;
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: .95rem;
    color: #1e1e1e;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Área de mensagens ───────────────────── */
.messages-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px 20px 12px;
}

.messages-area::-webkit-scrollbar {
    width: 5px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.message-row {
    display: flex;
}

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

.assistant-message {
    justify-content: flex-start;
}

.message-bubble {
    max-width: min(72%, 680px);
    padding: 11px 16px;
    border-radius: 18px;
    font-size: .9rem;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}

/* Balão do usuário */
.user-message .message-bubble {
    background: var(--bg-user-msg);
    color: var(--text-user-msg);
    border-bottom-right-radius: 5px;
}

/* Balão do assistente */
.assistant-message .message-bubble {
    background: var(--bg-asst-msg);
    color: var(--text-asst-msg);
    border-bottom-left-radius: 5px;
    border: 1px solid #ebebeb;
}

/* Cabeçalho do balão do assistente (avatar) */
.assistant-message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.assistant-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.message-time {
    font-size: .68rem;
    opacity: .55;
    margin-top: 5px;
    text-align: right;
}

.assistant-message .message-time {
    text-align: left;
}

/* Conteúdo do assistente */
.message-content {
    white-space: pre-wrap;
}

/* ── Indicador de digitação ──────────────── */
.typing-dots {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 4px 2px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: blink 1.3s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: .2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: .15;
        transform: scale(.85);
    }

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

/* ════════════════════════════════════════
   ÁREA DE INPUT
   ════════════════════════════════════════ */
#chat-input-area {
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 14px 20px;
}

#chat-form {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #f6f6f6;
    border: 1.5px solid #e0e0e0;
    border-radius: 14px;
    padding: 10px 10px 8px 16px;
    transition: border-color .2s;
}

#chat-form:focus-within {
    border-color: var(--brand-primary);
    background: #fff;
}

/* Seletor de agente */
.agent-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.agent-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1.5px solid #ddd;
    background: transparent;
    font-family: var(--font-base);
    font-size: .75rem;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.agent-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.agent-btn.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.agent-selector.locked .agent-btn {
    cursor: default;
    pointer-events: none;
    opacity: .6;
}

.agent-selector.locked .agent-btn.active {
    opacity: 1;
}

/* Linha input + botão */
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-textarea {
    flex: 1;
    resize: none;
    max-height: 180px;
    overflow-y: auto;
    border: none;
    background: transparent;
    font-family: var(--font-base);
    font-size: .9rem;
    line-height: 1.5;
    padding: 4px 0;
    color: #2d2d2d;
    outline: none;
    box-shadow: none !important;
}

.chat-textarea::placeholder {
    color: #aaa;
}

/* Botão enviar — círculo vermelho */
#btn-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    background: var(--brand-primary);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background .15s, transform .1s;
    line-height: 1;
}

#btn-send:hover {
    background: #aa0000;
    transform: scale(1.06);
}

#btn-send:active {
    transform: scale(.95);
}

#btn-send:disabled {
    background: #ccc;
    transform: none;
    cursor: not-allowed;
}

.chat-disclaimer {
    font-size: .7rem;
    color: #bbb;
    text-align: center;
    margin-top: 8px;
    margin-bottom: 0;
}

/* ════════════════════════════════════════
   WELCOME SCREEN
   ════════════════════════════════════════ */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #888;
}

.welcome-logo {
    max-height: 56px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 20px;
    opacity: .75;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--brand-primary);
    margin: 0 auto 20px;
}

.welcome-screen h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e1e1e;
    margin-bottom: 8px;
}

.welcome-screen p {
    font-size: .9rem;
    max-width: 380px;
    margin: 0 auto 24px;
}

/* Botão primário estilo Inox Design: outlined pill */
.btn-inox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    border-radius: var(--border-radius-btn);
    border: 2px solid var(--brand-primary);
    background: transparent;
    color: var(--brand-primary);
    font-family: var(--font-base);
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .18s, color .18s;
    text-decoration: none;
}

.btn-inox:hover {
    background: var(--brand-primary);
    color: #fff;
}

.btn-inox-filled {
    background: var(--brand-primary);
    color: #fff;
}

.btn-inox-filled:hover {
    background: #aa0000;
    border-color: #aa0000;
    color: #fff;
}

/* ════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════ */
.login-page-body {
    background: var(--brand-sidebar);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    border: none;
    overflow: hidden;
}

.login-card-header {
    background: var(--brand-primary);
    padding: 28px 32px 24px;
    text-align: center;
}

.login-logo {
    max-height: 52px;
    max-width: 200px;
    object-fit: contain;
}

.login-logo-text {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.login-card-body {
    padding: 28px 32px 32px;
    background: #fff;
}

.login-subtitle {
    font-size: .8rem;
    color: #888;
    text-align: center;
    margin-bottom: 24px;
    letter-spacing: .02em;
    text-transform: uppercase;
    font-weight: 600;
}

.login-card .form-control {
    border-radius: 8px;
    border: 1.5px solid #ddd;
    font-size: .9rem;
    padding: 10px 14px;
    transition: border-color .2s;
}

.login-card .form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, .12);
}

.login-card .form-label {
    font-weight: 600;
    font-size: .85rem;
    color: #444;
    margin-bottom: 5px;
}

.btn-login {
    width: 100%;
    padding: 11px;
    border-radius: var(--border-radius-btn);
    background: var(--brand-primary);
    border: none;
    color: #fff;
    font-family: var(--font-base);
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .04em;
    cursor: pointer;
    transition: background .18s, transform .1s;
}

.btn-login:hover {
    background: #aa0000;
}

.btn-login:active {
    transform: scale(.98);
}

/* ════════════════════════════════════════
   ADMIN PAGES
   ════════════════════════════════════════ */
.admin-topbar {
    background: var(--brand-sidebar);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-topbar .brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
}

.admin-topbar .topbar-logo {
    max-height: 28px;
    object-fit: contain;
}

.admin-topbar .topbar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Botão admin inline style Inox */
.btn-admin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: var(--border-radius-btn);
    border: 1.5px solid currentColor;
    background: transparent;
    font-family: var(--font-base);
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-decoration: none;
}

.btn-admin-red {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-admin-red:hover {
    background: var(--brand-primary);
    color: #fff;
}

.btn-admin-dark {
    color: #555;
    border-color: #bbb;
}

.btn-admin-dark:hover {
    background: #555;
    color: #fff;
    border-color: #555;
}

.btn-admin-ghost {
    color: rgba(255, 255, 255, .75);
    border-color: rgba(255, 255, 255, .3);
}

.btn-admin-ghost:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-color: rgba(255, 255, 255, .6);
}

.admin-content {
    padding: 28px 24px;
}

.admin-page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e1e1e;
    margin-bottom: 4px;
}

.admin-page-subtitle {
    font-size: .8rem;
    color: #888;
    margin-bottom: 20px;
}

/* Tabelas admin */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.admin-table th {
    background: #f7f7f7;
    color: #555;
    font-weight: 700;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 11px 14px;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

.admin-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    color: #2d2d2d;
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #fafafa;
}

/* Badges */
.badge-perfil-admin {
    background: var(--brand-primary);
    color: #fff;
}

.badge-perfil-colab {
    background: #6c757d;
    color: #fff;
}

.badge-ativo {
    background: #198754;
    color: #fff;
}

.badge-inativo {
    background: #dee2e6;
    color: #555;
}

.badge-inox {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
}

/* Log content */
.log-content {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    color: #555;
}

/* Badge papel */
.badge-user {
    background: #e8f0fe;
    color: #1a56c4;
}

.badge-assistant {
    background: #e8f8ef;
    color: #176d3a;
}

/* Card genérico admin */
.admin-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
}

/* Formulário admin */
.admin-form-label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    color: #444;
    margin-bottom: 5px;
}

.admin-form-control {
    display: block;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1.5px solid #ddd;
    font-size: .9rem;
    padding: 9px 14px;
    width: 100%;
    font-family: var(--font-base);
    transition: border-color .2s;
    color: #2d2d2d;
}

.admin-form-control:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(204, 0, 0, .1);
}

/* ════════════════════════════════════════
   CUSTOM MODAL
   ════════════════════════════════════════ */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.custom-modal-overlay.d-none {
    display: none !important;
}

.custom-modal {
    background: #fff;
    width: 90%;
    max-width: 420px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }

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

.custom-modal-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e1e1e;
    border-bottom: 1px solid #eee;
}

.custom-modal-body {
    padding: 20px;
}

.custom-modal-footer {
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fafafa;
    border-top: 1px solid #eee;
}

/* ════════════════════════════════════════
   RESPONSIVO
   ════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 230px;
    }

    .message-bubble {
        max-width: 88%;
    }

    .admin-content {
        padding: 16px;
    }
}

@media (max-width: 576px) {
    :root {
        --sidebar-width: 200px;
    }

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

    .messages-area {
        padding: 16px 12px 8px;
    }

    .login-card-body {
        padding: 20px;
    }
}