/* ============================================================
   O PATUDO — Estilos partilhados (dono + equipa)
   Paleta calma e profissional. Mobile-first, responsivo.
   A cor da marca do estabelecimento entra via --marca (JS).
   ============================================================ */

:root {
    --marca: #2f5d50;          /* cor do estabelecimento (white-label) */
    --marca-escura: #234a40;
    --marca-clara: #e7efe9;

    --creme: #f6f3ec;
    --creme-2: #efe9dd;
    --carvao: #283330;
    --texto: #2c3633;
    --texto-suave: #6b7770;
    --linha: #e2ddd0;
    --branco: #ffffff;

    --quente: #c98a4b;         /* tom quente de acento */
    --verde-ok: #4f8a5b;
    --vermelho: #c0573f;
    --amarelo: #d8a93a;
    --azul: #4a7ba6;

    --raio: 14px;
    --raio-s: 10px;
    --sombra: 0 1px 3px rgba(40,51,48,.08), 0 6px 18px rgba(40,51,48,.06);
    --sombra-forte: 0 10px 30px rgba(40,51,48,.14);
    --fonte: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--fonte);
    background: var(--creme);
    color: var(--texto);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--marca); }

/* ---------- Utilitarios ---------- */
.escondido { display: none !important; }
.centro { text-align: center; }
.flex { display: flex; }
.entre { justify-content: space-between; }
.alinha { align-items: center; }
.gap { gap: 12px; }
.gap-s { gap: 8px; }
.crescer { flex: 1; }
.suave { color: var(--texto-suave); }
.peq { font-size: .82rem; }
.negrito { font-weight: 700; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* ---------- App shell ---------- */
.app {
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.topo {
    position: sticky; top: 0; z-index: 30;
    background: var(--branco);
    border-bottom: 1px solid var(--linha);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
}
.topo .logo {
    width: 36px; height: 36px; border-radius: 9px;
    background: var(--marca); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; overflow: hidden; flex-shrink: 0;
}
.topo .logo img { width: 100%; height: 100%; object-fit: cover; }
.topo h1 { font-size: 1.05rem; font-weight: 700; }
.topo .sub { font-size: .75rem; color: var(--texto-suave); }
.topo .acoes { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.conteudo { flex: 1; padding: 16px; padding-bottom: 90px; }

/* ---------- Navegacao inferior (mobile) ---------- */
.nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--branco);
    border-top: 1px solid var(--linha);
    display: flex; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    max-width: 1100px; margin: 0 auto;
}
.nav button {
    flex: 1; background: none; border: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--texto-suave); font-size: .68rem; padding: 6px 2px;
    border-radius: 10px;
}
.nav button.ativo { color: var(--marca); }
.nav button svg { width: 24px; height: 24px; }
.nav .badge {
    position: absolute; transform: translate(12px,-6px);
    background: var(--vermelho); color: #fff; font-size: .6rem;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* ---------- Cartoes ---------- */
.cartao {
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    padding: 16px;
    margin-bottom: 14px;
}
.cartao.fino { padding: 12px 14px; }
.seccao-titulo {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--texto-suave); font-weight: 700; margin: 18px 2px 10px;
}

/* ---------- Botoes ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--marca); color: #fff; border: 0;
    padding: 12px 18px; border-radius: var(--raio-s);
    font-weight: 600; font-size: .95rem; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn.bloco { width: 100%; }
.btn.fantasma { background: var(--marca-clara); color: var(--marca-escura); }
.btn.contorno { background: transparent; color: var(--marca); border: 1.5px solid var(--linha); }
.btn.perigo { background: var(--vermelho); }
.btn.peq { padding: 8px 12px; font-size: .85rem; }
.btn.grande { padding: 16px 22px; font-size: 1.05rem; }
.btn svg { width: 20px; height: 20px; }
.btn-icone {
    background: var(--creme-2); border: 0; color: var(--texto);
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.btn-icone svg { width: 20px; height: 20px; }

/* ---------- Etiquetas / chips ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--creme-2); color: var(--texto);
    padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.chip.ok { background: #e3f1e6; color: #2c6b3c; }
.chip.aviso { background: #fbeede; color: #9a6320; }
.chip.perigo { background: #f7e2dc; color: #9c3a26; }
.chip svg { width: 14px; height: 14px; }

.alerta {
    border-left: 4px solid var(--quente);
    background: #fbf2e6; color: #7a5421;
    padding: 10px 14px; border-radius: 8px; font-size: .88rem; margin-bottom: 12px;
}
.alerta.medico { border-color: var(--vermelho); background: #f9e9e4; color: #8a3322; }

/* ---------- Linha do tempo ---------- */
.timeline { position: relative; padding-left: 6px; }
.tl-item { display: flex; gap: 12px; padding: 4px 0; }
.tl-marca { display: flex; flex-direction: column; align-items: center; }
.tl-icone {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--marca-clara); color: var(--marca-escura);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tl-icone svg { width: 20px; height: 20px; }
.tl-linha { width: 2px; flex: 1; background: var(--linha); margin: 4px 0; }
.tl-corpo { padding-bottom: 16px; flex: 1; }
.tl-corpo .hora { font-size: .72rem; color: var(--texto-suave); font-weight: 600; }
.tl-corpo .tit { font-weight: 600; }
.tl-corpo .det { font-size: .9rem; color: var(--texto-suave); }
.tl-corpo .autor { font-size: .72rem; color: var(--texto-suave); margin-top: 2px; }

/* tipos de registo - cores do icone */
.t-refeicao { background:#fbeede; color:#9a6320; }
.t-passeio  { background:#e3f1e6; color:#2c6b3c; }
.t-atividade{ background:#e3eef7; color:#2e5d80; }
.t-agua     { background:#e0f0f3; color:#1f6b76; }
.t-higiene  { background:#eee7f4; color:#6a4a86; }
.t-medicacao{ background:#f7e2dc; color:#9c3a26; }
.t-humor    { background:#fbf3da; color:#8a6b1f; }
.t-nota     { background:#eceae4; color:#5a5a52; }

/* ---------- Resumo do dia (cartoes pequenos) ---------- */
.resumo { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.resumo .cel {
    background: var(--branco); border: 1px solid var(--linha); border-radius: 12px;
    padding: 12px 8px; text-align: center;
}
.resumo .cel svg { width: 22px; height: 22px; color: var(--marca); margin: 0 auto 4px; }
.resumo .cel .n { font-weight: 800; font-size: 1.1rem; }
.resumo .cel .l { font-size: .68rem; color: var(--texto-suave); }

/* ---------- Galeria ---------- */
.galeria { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.galeria img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* ---------- Ficha animal ---------- */
.ficha-topo { display: flex; gap: 16px; align-items: center; }
.ficha-foto { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid var(--branco); box-shadow: var(--sombra); }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--creme-2); flex-shrink: 0; }
.avatar.peq { width: 38px; height: 38px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 8px 0 16px; }
.bolha { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: .92rem; }
.bolha .h { font-size: .65rem; opacity: .7; margin-top: 3px; text-align: right; }
.bolha.deles { background: var(--branco); border: 1px solid var(--linha); align-self: flex-start; border-bottom-left-radius: 4px; }
.bolha.minha { background: var(--marca); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.barra-msg {
    position: fixed; bottom: 64px; left: 0; right: 0; max-width: 1100px; margin: 0 auto;
    background: var(--branco); border-top: 1px solid var(--linha);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px;
}
.barra-msg input { flex: 1; border: 1px solid var(--linha); border-radius: 999px; padding: 10px 16px; font-size: .95rem; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: .82rem; font-weight: 600; color: var(--texto-suave); margin-bottom: 5px; }
.campo input, .campo select, .campo textarea {
    width: 100%; border: 1px solid var(--linha); border-radius: var(--raio-s);
    padding: 11px 13px; font-size: .95rem; font-family: inherit; background: var(--branco); color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--marca-clara); border-color: var(--marca); }
.campo textarea { min-height: 80px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: linear-gradient(160deg, var(--marca-clara), var(--creme)); }
.login-cartao { background: var(--branco); border-radius: 20px; box-shadow: var(--sombra-forte); padding: 32px 26px; width: 100%; max-width: 380px; }
.login-cartao .marca-logo { width: 60px; height: 60px; border-radius: 16px; background: var(--marca); color: #fff;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-cartao .marca-logo svg { width: 32px; height: 32px; }
.login-cartao h2 { text-align: center; margin-bottom: 4px; }
.login-cartao p.sub { text-align: center; color: var(--texto-suave); margin-bottom: 22px; font-size: .9rem; }

/* ---------- Botoes grandes do registo rapido (equipa) ---------- */
.botoes-rapidos { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.botao-rapido {
    background: var(--branco); border: 2px solid var(--linha); border-radius: 14px;
    padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
    font-weight: 600; color: var(--texto); transition: .12s; min-height: 92px; justify-content: center;
}
.botao-rapido svg { width: 30px; height: 30px; color: var(--marca); }
.botao-rapido:active { transform: scale(.97); }
.botao-rapido.sel { border-color: var(--marca); background: var(--marca-clara); box-shadow: var(--sombra); }

/* seletor de animais (lote) */
.animais-grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 10px; }
.animal-card {
    background: var(--branco); border: 2px solid var(--linha); border-radius: 14px; padding: 10px;
    text-align: center; transition: .12s; position: relative;
}
.animal-card img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; margin: 0 auto 6px; }
.animal-card .n { font-weight: 600; font-size: .85rem; }
.animal-card.sel { border-color: var(--marca); background: var(--marca-clara); }
.animal-card .check {
    position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
    background: var(--marca); color: #fff; display: none; align-items: center; justify-content: center;
}
.animal-card .check svg { width: 14px; height: 14px; }
.animal-card.sel .check { display: flex; }

/* respostas rapidas */
.respostas { display: flex; flex-wrap: wrap; gap: 8px; }
.resposta {
    background: var(--branco); border: 2px solid var(--linha); border-radius: 999px;
    padding: 10px 16px; font-weight: 600; font-size: .92rem; color: var(--texto);
}
.resposta.sel { border-color: var(--marca); background: var(--marca-clara); color: var(--marca-escura); }

/* painel do dia */
.painel-animal { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--linha);
    border-radius: 12px; margin-bottom: 8px; background: var(--branco); }
.estado-pontos { display: flex; gap: 6px; margin-left: auto; }
.ponto { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--creme-2); color: var(--texto-suave); }
.ponto svg { width: 16px; height: 16px; }
.ponto.feito { background: #e3f1e6; color: var(--verde-ok); }
.ponto.alerta { background: #f7e2dc; color: var(--vermelho); }

/* tabela faturacao */
.tabela { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabela th, .tabela td { text-align: left; padding: 10px; border-bottom: 1px solid var(--linha); }
.tabela th { font-size: .72rem; text-transform: uppercase; color: var(--texto-suave); letter-spacing: .05em; }
.tabela td.num, .tabela th.num { text-align: right; }
.kpi { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
.kpi .cel { background: var(--branco); border: 1px solid var(--linha); border-radius: 14px; padding: 16px; text-align: center; }
.kpi .cel .v { font-size: 1.6rem; font-weight: 800; color: var(--marca); }
.kpi .cel .l { font-size: .75rem; color: var(--texto-suave); }

/* modal */
.modal-fundo { position: fixed; inset: 0; background: rgba(20,28,25,.5); z-index: 60; display: flex;
    align-items: flex-end; justify-content: center; padding: 0; }
.modal {
    background: var(--branco); border-radius: 20px 20px 0 0; width: 100%; max-width: 560px;
    max-height: 92vh; overflow-y: auto; padding: 20px; animation: subir .2s ease;
}
@keyframes subir { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { margin-bottom: 14px; }
.modal-foto { width: 100%; border-radius: 12px; }

/* estado vazio */
.vazio { text-align: center; padding: 40px 20px; color: var(--texto-suave); }
.vazio svg { width: 56px; height: 56px; opacity: .4; margin: 0 auto 12px; }

/* toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 90;
    background: var(--carvao); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: .9rem;
    box-shadow: var(--sombra-forte); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.ver { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.erro { background: var(--vermelho); }

/* spinner */
.spinner { width: 28px; height: 28px; border: 3px solid var(--marca-clara); border-top-color: var(--marca);
    border-radius: 50%; animation: rodar .7s linear infinite; margin: 30px auto; }
@keyframes rodar { to { transform: rotate(360deg); } }

/* ============================================================
   DESKTOP / TABLET
   ============================================================ */
@media (min-width: 860px) {
    .app { flex-direction: row; max-width: 1200px; }
    .nav {
        position: sticky; top: 0; left: 0; bottom: auto; height: 100vh; width: 230px;
        flex-direction: column; justify-content: flex-start; gap: 4px;
        border-top: 0; border-right: 1px solid var(--linha); padding: 20px 12px; margin: 0;
    }
    .nav .marca-lateral { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
    .nav .marca-lateral .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--marca);
        color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; overflow: hidden; }
    .nav .marca-lateral .logo img { width:100%; height:100%; object-fit:cover; }
    .nav button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
        width: 100%; padding: 12px 14px; font-size: .92rem; border-radius: 10px; }
    .nav button.ativo { background: var(--marca-clara); }
    .nav button svg { width: 22px; height: 22px; }
    .nav .badge { position: static; transform: none; margin-left: auto; }
    .corpo-principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }
    .conteudo { padding: 24px 28px; padding-bottom: 24px; max-width: 820px; margin: 0 auto; width: 100%; }
    .barra-msg { position: sticky; bottom: 0; left: auto; right: auto; max-width: 820px; margin: 0 auto; }
    .modal-fundo { align-items: center; padding: 24px; }
    .modal { border-radius: 20px; }
    .resumo { grid-template-columns: repeat(4,1fr); }
    .galeria { grid-template-columns: repeat(4,1fr); }
    .botoes-rapidos { grid-template-columns: repeat(4,1fr); }
    .toast { bottom: 24px; }
}
@media (max-width: 859px) {
    .nav .marca-lateral { display: none; }
    .desktop-so { display: none; }
}
@media (min-width: 860px) {
    .topo { display: none; } /* no desktop a marca esta na barra lateral */
    .mobile-so { display: none; }
}
