:root {
    --tpo-borda: #e6e8eb;
}

body {
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------- chat */

.chat-card {
    overflow: hidden;
}

.chat-historico {
    height: min(62vh, 620px);
    overflow-y: auto;
    padding: 1.25rem 1rem;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    margin-bottom: 0.75rem;
}

.chat-msg--ia {
    justify-content: flex-start;
}

.chat-msg--user {
    justify-content: flex-end;
}

.chat-balao {
    max-width: 82%;
    padding: 0.65rem 0.9rem;
    border-radius: 1rem;
    line-height: 1.45;
    font-size: 0.95rem;
    word-break: break-word;
}

.chat-msg--ia .chat-balao {
    background: #f1f3f5;
    color: #212529;
    border-bottom-left-radius: 0.25rem;
}

.chat-msg--user .chat-balao {
    background: var(--bs-primary);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

/* indicador "digitando..." */
.chat-balao--digitando {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.85rem 0.9rem;
}

.chat-balao--digitando span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #adb5bd;
    animation: tpo-pulsa 1.2s infinite ease-in-out;
}

.chat-balao--digitando span:nth-child(2) { animation-delay: 0.15s; }
.chat-balao--digitando span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tpo-pulsa {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-historico { scroll-behavior: auto; }
    .chat-balao--digitando span { animation: none; opacity: 0.5; }
}

/* --------------------------------------------------------------- widgets */

.chat-widget:empty {
    display: none;
}

.chat-widget {
    margin: 0.25rem 0 0.75rem;
}

.widget-caixa {
    border: 1px solid var(--tpo-borda);
    border-radius: 1rem;
    padding: 1rem;
    background: #fff;
}

.widget-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

@media (max-width: 480px) {
    .widget-cards { grid-template-columns: 1fr; }
}

.widget-card {
    border: 1.5px solid var(--tpo-borda);
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.85rem 0.75rem;
    text-align: left;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.3;
    transition: border-color 0.12s ease, background 0.12s ease;
    cursor: pointer;
}

.widget-card:hover:not(:disabled) {
    border-color: var(--bs-primary);
    background: #f8f9ff;
}

.widget-card:disabled {
    opacity: 0.55;
    cursor: default;
}

.widget-card.is-selecionado {
    border-color: var(--bs-primary);
    background: #eef2ff;
}

.widget-card small {
    display: block;
    font-weight: 400;
    color: #6c757d;
    margin-top: 0.15rem;
}

/* ------------------------------------------------- 4.3 região (autocomplete) */

.widget-sugestoes {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--tpo-borda);
    border-radius: 0.6rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
    max-height: 240px;
    overflow-y: auto;
}

.widget-sugestao {
    display: block;
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.3;
}

button.widget-sugestao:hover {
    background: #f1f3f5;
}

.widget-mapa {
    height: 240px;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--tpo-borda);
    background: #f8f9fa;
}

.widget-lista-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--tpo-borda);
    border-radius: 0.6rem;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}

.widget-lista-item:last-child {
    margin-bottom: 0;
}

/* Leaflet dentro do balão do chat não pode passar por cima do resto */
.leaflet-container {
    z-index: 1;
}

/* --------------------------------------------------------- 4.4 logo (upload) */

.widget-solta {
    border: 2px dashed var(--tpo-borda);
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.widget-solta:hover,
.widget-solta.is-ativa {
    border-color: var(--bs-primary);
    background: #f8f9ff;
}

.widget-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.widget-preview img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    /* Xadrez discreto: logo com fundo transparente fica legível */
    background-image: linear-gradient(45deg, #f1f3f5 25%, transparent 25%, transparent 75%, #f1f3f5 75%),
                      linear-gradient(45deg, #f1f3f5 25%, transparent 25%, transparent 75%, #f1f3f5 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    border-radius: 0.5rem;
}

/* ------------------------------------------------------------ 4.5 estilo */

.widget-fotos {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 520px) {
    .widget-fotos { grid-template-columns: 1fr; }
}

.widget-foto {
    padding: 0;
    border: 2px solid var(--tpo-borda);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 4 / 5;
    cursor: pointer;
    transition: border-color 0.12s ease, transform 0.12s ease;
}

.widget-foto img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.widget-foto:hover:not(:disabled) {
    border-color: var(--bs-primary);
    transform: translateY(-2px);
}

.widget-foto.is-selecionado {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

.widget-foto.is-sem-imagem {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #adb5bd;
}

.widget-foto.is-sem-imagem img {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .widget-foto:hover:not(:disabled) { transform: none; }
}

/* --------------------------------------------- Etapa 5: calendário de campanhas */

.campanha-logo {
    max-height: 48px;
    max-width: 160px;
    object-fit: contain;
}

.campanhas-acordeao {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
}

.campanhas-acordeao .accordion-button {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #fff;
}

.campanhas-acordeao .accordion-button:not(.collapsed) {
    background: var(--bs-primary-bg-subtle, #cfe2ff);
    box-shadow: none;
}

/* O mês atual é o item que o cliente procura ao abrir a tela. */
.campanha-item--atual > .accordion-header .accordion-button::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--bs-primary);
}

.campanha-item--atual > .accordion-header .accordion-button {
    position: relative;
}

.campanha-mes {
    flex: none;
    width: 2.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6c757d;
}

.campanha-titulo {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.campanha-selos {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: none;
    margin-left: auto;
    padding-right: 0.5rem;
}

.campanha-nome {
    font-weight: 600;
    line-height: 1.3;
}

.campanha-oferta {
    font-size: 0.9rem;
    line-height: 1.35;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campanha-formato {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6c757d;
}

.campanha-status--vazio  { background: #e9ecef; color: #6c757d; }
.campanha-status--gerado { background: var(--bs-success-bg-subtle, #d1e7dd); color: #0f5132; }
.campanha-status--erro   { background: var(--bs-danger-bg-subtle, #f8d7da); color: #842029; }

/* No celular a oferta e os selos não cabem na mesma linha do título. */
@media (max-width: 575.98px) {
    .campanha-oferta { display: none; }
    .campanhas-acordeao .accordion-button { gap: 0.6rem; }
}

.campanha-gancho {
    font-size: 0.85rem;
    font-style: italic;
    color: #6c757d;
    line-height: 1.35;
}

/* ------------------------------------------------ Etapa 6: preview dos criativos */

.criativo-palco {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f3f5;
    border: 1px solid var(--tpo-borda);
    border-radius: 0.75rem;
    overflow: hidden;
}

/* Reserva a proporção real de cada formato: o card não pula quando a imagem chega. */
.criativo-palco--feed { aspect-ratio: 1 / 1; }
.criativo-palco--stories { aspect-ratio: 9 / 16; }

.criativo-palco img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ---------------------------------------------------------------- entrada */

.chat-entrada {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem;
    border-top: 1px solid var(--tpo-borda);
    background: #fff;
}

.chat-entrada .form-control {
    border-radius: 2rem;
    padding-inline: 1rem;
}

.chat-entrada .btn {
    border-radius: 2rem;
    padding-inline: 1.25rem;
}
