* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, system-ui, sans-serif; background: #faf7fb; color: #2a1f2d; }

.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 320px; }
.login-card h1 { margin: 0 0 4px; color: #a3406a; }
.login-card .subtitle { margin: 0 0 20px; color: #888; }
.login-card label { display: block; margin-top: 12px; font-size: 13px; color: #555; }
.login-card input { width: 100%; padding: 8px 10px; margin-top: 4px; border: 1px solid #ddd; border-radius: 6px; }
.login-card button { margin-top: 20px; width: 100%; padding: 10px; background: #a3406a; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.login-card .hint { font-size: 12px; color: #999; margin-top: 16px; }
.login-card .hint a { color: #a3406a; }
.hint-inline { font-size: 11px; color: #999; margin: 2px 0 0; }
.hint-inline.terms { margin-top: 14px; }
.oauth-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: #bbb; font-size: 12px; }
.oauth-sep::before, .oauth-sep::after { content: ""; flex: 1; height: 1px; background: #eee; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; background: #fff; color: #3c4043; text-decoration: none; font-size: 14px; font-weight: 500; }
.google-btn:hover { background: #f7f7f7; }
.google-mark { flex: none; }
.alert-error { background: #fdecea; color: #c0392b; padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }

.chat-page { display: flex; height: 100vh; }
.companion-list { width: 240px; background: #fff; border-right: 1px solid #eee; padding: 16px; display: flex; flex-direction: column; }
.sidebar-logo { display: block; margin-bottom: 14px; }
.sidebar-logo img { display: block; height: 32px; width: auto; }
.companion-list h2 { font-size: 15px; color: #a3406a; margin: 0 0 10px; }
.companion-list ul { list-style: none; padding: 0; margin: 0; flex: 1; }
.companion-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.companion-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.companion-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; background: #f0e6ec; }
.companion-avatar.vazio { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff; }

.avatar-box { display: flex; gap: 14px; align-items: flex-start; margin-top: 6px; }
.avatar-preview { width: 110px; height: 110px; border-radius: 10px; object-fit: cover; flex: none; background: #faf7fb; border: 1px solid #f0e6ec; }
.avatar-preview.vazio { display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 600; color: #fff; }
.avatar-acoes { flex: 1; min-width: 0; }
.avatar-btn { padding: 8px 16px; border: 1px solid #e3cdd8; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; font-size: 13px; }
.avatar-btn:hover:not(:disabled) { background: #f5eaf0; }
.avatar-btn:disabled { color: #bbb; border-color: #eee; cursor: default; }
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.chat-avatar.vazio { display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; color: #fff; }
.companion-item:hover { background: #f5eaf0; }
.companion-item.active { background: #a3406a; color: #fff; }
.credit-box { border: 1px solid #f0e6ec; background: #fdfafc; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.credit-box.baixo { border-color: #f0c9a8; background: #fff8f0; }
.credit-label { font-size: 11px; color: #999; display: block; }
.credit-value { font-size: 20px; font-weight: 600; color: #a3406a; }
.credit-warn { font-size: 11px; color: #b6702a; margin: 6px 0 0; line-height: 1.35; }
.new-companion-link { display: block; text-align: center; padding: 8px; margin: 8px 0; border: 1px dashed #a3406a; border-radius: 6px; color: #a3406a; text-decoration: none; font-size: 13px; }
.new-companion-link:hover { background: #f5eaf0; }
.logout-btn { margin-top: auto; padding: 8px; border: 1px solid #ddd; background: #fff; border-radius: 6px; cursor: pointer; }
.empty { font-size: 13px; color: #999; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-empty { margin: auto; color: #999; }
.chat-thread { display: flex; flex-direction: column; height: 100%; padding: 16px; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 60%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; white-space: pre-wrap; }
.bubble-user { align-self: flex-end; background: #a3406a; color: #fff; }
.bubble-companion { align-self: flex-start; background: #fff; border: 1px solid #eee; }
.bubble-system { align-self: center; background: #fdecea; color: #c0392b; font-size: 12px; }
.char-count { font-size: 11px; color: #999; margin: 4px 0 0; text-align: right; }
.char-count.char-count-full { color: #c0392b; font-weight: 600; }

.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #f0e6ec; }
.chat-header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn { padding: 5px 12px; font-size: 12px; border: 1px solid #e3cdd8; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.header-btn:hover { background: #f5eaf0; }

/* Fotos ao LADO da conversa — coluna própria, não sobreposição. */
.photo-panel { position: relative; width: 300px; flex: none; background: #fff; border-left: 1px solid #eee; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.photo-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #a3406a; font-weight: 600; }
.photo-close { border: none; background: none; font-size: 20px; line-height: 1; color: #999; cursor: pointer; padding: 0 4px; }
.photo-frame { flex: 1; min-height: 220px; display: flex; align-items: center; justify-content: center; background: #faf7fb; border: 1px solid #f0e6ec; border-radius: 10px; overflow: hidden; }
.photo-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.photo-empty { font-size: 12px; color: #999; text-align: center; margin: 0; padding: 0 12px; }
.photo-name { font-size: 11px; color: #999; text-align: center; margin: 0; min-height: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-status { font-size: 12px; color: #888; min-height: 18px; text-align: center; }
.photo-auth-btn { padding: 6px 14px; font-size: 12px; border: 1px solid #e3cdd8; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; }
.photo-controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.photo-nav { width: 30px; height: 28px; border: 1px solid #eee; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
.photo-nav:hover { background: #f5eaf0; }
.photo-counter { font-size: 11px; color: #999; min-width: 46px; text-align: center; }
.photo-remove { padding: 5px 10px; font-size: 11px; border: 1px solid #eee; background: #fff; color: #999; border-radius: 6px; cursor: pointer; }
.photo-remove:hover { background: #fdecea; color: #c0392b; border-color: #f5c6c0; }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 190px; overflow-y: auto; align-content: start; }
/* Quadrado pelo padding, não por aspect-ratio: com a imagem em height:100%
   dentro de um pai sem altura definida, a célula colapsava e as fotos
   ficavam encavaladas. O padding reserva a altura antes de a imagem
   carregar, e a imagem é posicionada por cima. */
.photo-thumb { position: relative; height: 0; padding-bottom: 100%; border-radius: 5px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: #faf7fb; box-sizing: border-box; }
.photo-thumb.ativa { border-color: #a3406a; }
.photo-thumb img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb-del { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; padding: 0; border: none; border-radius: 3px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 16px; cursor: pointer; display: none; }
.photo-thumb:hover .photo-thumb-del { display: block; }
.photo-thumb-del:hover { background: #c0392b; }
.photo-staging { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; overflow: hidden; }
.staging-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding: 4px 0; }
.staging-grid .photo-thumb { border-width: 3px; }
.photo-thumb.marcada { border-color: #a3406a; }
.photo-thumb.marcada::after { content: "✓"; position: absolute; bottom: 2px; right: 3px; color: #fff; font-size: 12px; text-shadow: 0 0 3px rgba(0,0,0,.9); }
.photo-thumb.desmarcada img { opacity: .35; }
.photo-pick { padding: 8px; font-size: 12px; border: 1px dashed #d9a8c0; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; }
.photo-pick:hover { background: #f5eaf0; }
.chat-header h3 { margin: 0; }

.edit-companion-btn { padding: 5px 12px; font-size: 12px; border: 1px solid #e3cdd8; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.edit-companion-btn:hover { background: #f5eaf0; }

/* Editor ocupa toda a área do chat, no lugar das mensagens. */
.companion-editor { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; overflow-y: auto; }
.editor-head { display: flex; align-items: center; justify-content: space-between; }
.editor-head h3 { margin: 0; color: #a3406a; }
.editor-close { border: none; background: none; font-size: 22px; line-height: 1; color: #999; cursor: pointer; padding: 0 4px; }
.companion-editor label { display: block; margin-top: 14px; font-size: 13px; color: #555; }
.editor-input { width: 100%; max-width: 420px; padding: 8px 10px; margin-top: 4px; border: 1px solid #ddd; border-radius: 6px; font: inherit; box-sizing: border-box; }
.editor-section { font-size: 14px; color: #a3406a; margin: 22px 0 4px; border-top: 1px solid #f0e6ec; padding-top: 16px; }
.editor-error { margin-top: 12px; padding: 8px 10px; background: #fdecea; color: #c0392b; font-size: 12px; border-radius: 6px; }
.editor-actions { display: flex; gap: 10px; margin-top: 22px; }
.editor-save { padding: 9px 22px; background: #a3406a; color: #fff; border: none; border-radius: 8px; cursor: pointer; }
.editor-save:disabled { background: #d5b8c5; cursor: default; }
.editor-cancel { padding: 9px 18px; background: #fff; color: #666; border: 1px solid #ddd; border-radius: 8px; cursor: pointer; }

/* Lista de tópicos — compartilhada pela criação e pela edição. */
.traits-editor { margin-top: 6px; }
.trait-row { display: flex; gap: 6px; margin-bottom: 6px; }
.trait-input { flex: 1; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font: inherit; font-size: 13px; }
.trait-remove { width: 32px; border: 1px solid #eee; background: #fff; color: #999; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
.trait-remove:hover { background: #fdecea; color: #c0392b; border-color: #f5c6c0; }
.traits-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.trait-add { padding: 6px 12px; font-size: 12px; border: 1px dashed #d9a8c0; background: #fff; color: #a3406a; border-radius: 6px; cursor: pointer; }
.trait-add:hover:not(:disabled) { background: #f5eaf0; }
.trait-add:disabled { color: #bbb; border-color: #eee; cursor: default; }
.traits-counter { font-size: 11px; color: #999; }
.trait-row-error .trait-input { border-color: #e0a5a0; background: #fdf5f4; }

.typing-indicator { font-size: 12px; color: #999; padding: 4px 0; }
.send-form { display: flex; gap: 8px; margin-top: 12px; }
.send-form input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 8px; }
.send-form button { padding: 10px 20px; background: #a3406a; color: #fff; border: none; border-radius: 8px; cursor: pointer; }

.companion-form-page { display: flex; justify-content: center; padding: 32px 16px; }
.companion-form-card { background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 100%; max-width: 560px; }
.companion-form-card h1 { margin: 0 0 4px; color: #a3406a; }
.companion-form-card .subtitle { margin: 0 0 20px; color: #888; font-size: 13px; }
.companion-form-card h2 { font-size: 14px; color: #a3406a; margin: 24px 0 8px; border-top: 1px solid #f0e6ec; padding-top: 16px; }
.companion-form-card h2:first-of-type { border-top: none; padding-top: 0; }
/* Os campos são o MESMO mixin nas duas telas (_companionFields.pug), então
   o estilo também precisa ser o mesmo — antes só a criação tinha, e a
   edição herdava um visual solto. */
.companion-form-card label,
.companion-editor label { display: block; margin-top: 10px; font-size: 13px; color: #555; }
.companion-form-card h2,
.companion-editor h2 { font-size: 14px; color: #a3406a; margin: 24px 0 8px; border-top: 1px solid #f0e6ec; padding-top: 16px; }
.companion-form-card h2:first-of-type,
.companion-editor h2:first-of-type { border-top: none; padding-top: 0; }
.companion-form-card input[type="text"],
.companion-form-card input[type="number"],
.companion-form-card select,
.companion-form-card textarea,
.companion-editor input[type="text"],
.companion-editor input[type="number"],
.companion-editor select,
.companion-editor textarea { width: 100%; max-width: 460px; padding: 8px 10px; margin-top: 4px; border: 1px solid #ddd; border-radius: 6px; font-family: inherit; box-sizing: border-box; }
.companion-form-card input[type="range"],
.companion-editor input[type="range"] { width: calc(100% - 32px); max-width: 428px; vertical-align: middle; }
.companion-form-card output,
.companion-editor output { display: inline-block; width: 24px; text-align: right; font-size: 13px; color: #a3406a; }
.companion-editor .interests-grid { max-width: 640px; }
.interests-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; margin-top: 6px; }
.interest-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: normal; margin-top: 0; }
.interest-checkbox input { width: auto; }
.consent-checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; font-weight: normal; line-height: 1.4; }
.consent-checkbox input { width: auto; margin-top: 2px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 24px; }
.form-actions button[type="submit"] { flex: 1; padding: 12px; background: #a3406a; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 15px; }
.form-actions .btn-cancelar { padding: 12px 20px; border: 1px solid #ddd; border-radius: 6px; color: #666; text-decoration: none; font-size: 15px; background: #fff; }
.form-actions .btn-cancelar:hover { background: #f7f7f7; }


/* Diálogos (namorai-modal.js) — substituem alert/confirm/prompt nativos. */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(42, 31, 45, .45);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-caixa {
    background: #fff; border-radius: 12px; padding: 24px;
    width: 100%; max-width: 420px;
    box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.modal-titulo { margin: 0 0 8px; font-size: 17px; color: #a3406a; }
.modal-mensagem { margin: 0; font-size: 14px; line-height: 1.5; color: #4a3d44; }
.modal-campo {
    width: 100%; margin-top: 14px; padding: 9px 11px;
    border: 1px solid #ddd; border-radius: 6px; font: inherit; box-sizing: border-box;
}
.modal-acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-btn { padding: 9px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; border: 1px solid transparent; }
.modal-btn-principal { background: #a3406a; color: #fff; }
.modal-btn-principal:hover { background: #8d3159; }
.modal-btn-secundario { background: #fff; color: #666; border-color: #ddd; }
.modal-btn-secundario:hover { background: #f7f7f7; }


/* Modelos prontos na tela de criação. */
.templates { margin-bottom: 24px; }
.templates-titulo { font-size: 13px; color: #666; margin: 0 0 10px; }
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.template-card {
    display: flex; flex-direction: column; gap: 3px; text-align: left;
    padding: 10px 12px; border: 1px solid #eee; background: #fff;
    border-radius: 8px; cursor: pointer; font: inherit;
}
.template-card:hover { border-color: #d9a8c0; background: #fdfafc; }
.template-card.ativo { border-color: #a3406a; background: #f9eef3; }
.template-card strong { font-size: 13px; color: #a3406a; }
.template-card span { font-size: 11px; line-height: 1.35; color: #888; }

/* ---- Compra de créditos (/creditos) ---------------------------------- */
.creditos-card { max-width: 620px; }
.credit-line { margin: 0; font-size: 13px; color: #6b5560; }
.packs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.pack-card {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 16px 8px; border: 1px solid #f0e6ec; border-radius: 10px;
    background: #fff; cursor: pointer; font: inherit; color: inherit;
}
.pack-card:hover:not(:disabled) { border-color: #a3406a; background: #fdfafc; }
.pack-card:disabled { opacity: 0.5; cursor: default; }
.pack-card strong { font-size: 22px; color: #a3406a; line-height: 1; }
.pack-card span { font-size: 11px; color: #999; }
.pack-card em { font-style: normal; font-size: 14px; margin-top: 6px; }
.pack-card.carregando { border-color: #a3406a; }
.pix-valor { font-size: 14px; color: #6b5560; margin: 0 0 10px; }
.pix-qr { text-align: center; margin-bottom: 12px; }
.pix-qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.pix-status { font-size: 13px; color: #a3406a; margin: 10px 0 0; }
.pix-status.ok { color: #2e7d32; font-weight: 600; }
/* Os botões desta tela são type="button" (não submetem formulário), e a
   regra geral só pega button[type="submit"] — sem isto saem com o visual
   cru do navegador no meio de uma tela estilizada. */
.creditos-card .form-actions button[type="button"] {
    flex: 1; padding: 12px; background: #a3406a; color: #fff; border: none;
    border-radius: 6px; cursor: pointer; font-size: 15px;
}
/* Composer travado por falta de saldo: sem sinal visual, o botão parece
   clicável e a pessoa fica tentando enviar. */
.send-form input:disabled { background: #f4f0f2; color: #999; }
.send-form button:disabled { background: #d8c3ce; cursor: not-allowed; }
@media (max-width: 520px) { .packs-grid { grid-template-columns: 1fr; } }

/* Fim de saldo no chat: bloco do SISTEMA, não bolha da persona. Precisa
   ficar visualmente longe da conversa — quem cobra é a plataforma. */
.sem-credito {
    border: 1px solid #f0c9a8; background: #fff8f0; border-radius: 10px;
    padding: 14px 16px; margin: 14px auto; max-width: 460px; text-align: center;
}
.sem-credito p { margin: 0 0 10px; font-size: 13px; color: #6b5560; }
.sem-credito a {
    display: inline-block; background: #a3406a; color: #fff; text-decoration: none;
    padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.aviso-sistema {
    text-align: center; font-size: 12px; color: #999; margin: 10px auto;
    max-width: 460px;
}
.aviso-sistema a { color: #a3406a; }
.credit-add { display: inline-block; margin-top: 6px; font-size: 12px; color: #a3406a; text-decoration: none; font-weight: 600; }
.credit-add:hover { text-decoration: underline; }
