/* ================================================================
   Objais Partners — Portal & Admin shared CSS
   Extends /css/style.css tokens
   ================================================================ */

:root {
  --sidebar-w: 220px;
  --color-success: #16a34a;
  --color-danger:  #dc2626;
  --color-warning: #d97706;
  --color-info:    #2563eb;
}

/* ── App shell ──────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-text);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar__logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-white);
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  text-decoration: none;
  display: block;
}

/* A marca da barra lateral deixou de ser texto: o logotipo branco e o mesmo
   ficheiro que assina o rodape publico, e a barra e navy. Largura fixa em vez
   de 100%: a barra tem 220px e o logotipo e 2:1, esticar ate a borda dava-lhe
   110px de altura. `width`/`height` no markup dao a proporcao antes de a
   imagem chegar, por isso a navegacao por baixo nao salta. */
.sidebar__logo img { display: block; width: 132px; height: auto; }

.sidebar__nav { flex: 1; padding: 1rem 0; }

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar__nav a:hover,
.sidebar__nav a.active {
  background: rgba(255,255,255,0.08);
  color: var(--color-white);
  border-left-color: var(--color-violet);
}

.sidebar__footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar__user {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 0.75rem;
}

.sidebar__user strong { color: var(--color-white); display: block; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.5rem; }

/* ── Cards / Stats ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card__label {
  font-size: 0.78rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.stat-card__sub {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.3rem;
}

/* ── Table ──────────────────────────────────────────────────── */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card__header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card__header h2 { font-size: 1rem; margin: 0; }

.card__body { padding: 1.25rem; }

.table-wrap { overflow-x: auto; }

/* A coluna das acções é sempre a última, e nas tabelas largas do admin cai fora
   do ecrã: medido a 23 Set 2026 num browser real, a de leads pedia 1070px num
   contentor de 450px e os botões caíam em x=1246px, com nada no ecrã a dizer que
   havia scroll lateral. O Christophe teve de baixar a resolução do monitor para
   chegar a "Editar", e a 24 Set deu por falta do botão de excluir corretor em
   /admin/brokers.html pela mesma razão: existia, estava fora de vista.
   Fixar a coluna mantém os botões alcançáveis em qualquer largura. A classe é
   explícita de propósito: `td:last-child` também apanharia o `colspan` da linha
   "sem resultados" e fixaria uma célula vazia. */
.table-wrap th.col-actions,
.table-wrap td.col-actions {
  position: sticky;
  right: 0;
  background: var(--color-surface, #fff);
  box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

/* Fixar a coluna resolveu o alcance, nao a largura: tres botoes lado a lado
   (Aceitar, Recusar, Apagar) pedem ~330px e a coluna fixa tapa a vizinha, que
   em /admin/applications.html e a mensagem do candidato. Empilhados, a coluna
   pede a largura de um botao so. `display: block` em vez de flex na propria
   celula: a celula continua a ser table-cell, e mudar-lhe o display partia o
   alinhamento da linha e o sticky. */
.table-wrap td.col-actions {
  white-space: normal;
}

.table-wrap td.col-actions .btn {
  display: block;
  width: 100%;
  text-align: center;
}

.table-wrap td.col-actions .btn + .btn {
  margin-top: 0.35rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  border-bottom: 2px solid var(--color-border);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-surface); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2em 0.55em;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--color-surface);
  color: var(--color-text);
}

.badge--open     { background: #dcfce7; color: #15803d; }
.badge--closed   { background: #fee2e2; color: #b91c1c; }
.badge--inactive { background: #f1f5f9; color: #64748b; }
.badge--pending  { background: #fef9c3; color: #854d0e; }
.badge--completed{ background: #dcfce7; color: #15803d; }
.badge--high     { background: #fee2e2; color: #b91c1c; }
.badge--medium   { background: #fef9c3; color: #854d0e; }
.badge--low      { background: #dcfce7; color: #15803d; }

.badge--tier     { background: var(--color-surface); color: var(--color-text); }
.badge--silver   { background: #e2e8f0; color: #475569; }
.badge--gold     { background: #fef3c7; color: #92400e; }
.badge--platinum { background: #E3F7F6; color: #14606A; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary   { background: var(--color-violet); color: #fff; }
.btn--danger    { background: var(--color-danger); color: #fff; }
.btn--warning   { background: var(--color-warning); color: #fff; }
.btn--success   { background: var(--color-success); color: #fff; }
.btn--ghost     { background: transparent; color: var(--color-violet); border: 1.5px solid var(--color-violet); }
.btn--sm        { padding: 0.3rem 0.65rem; font-size: 0.78rem; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--color-text);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--color-white);
  color: var(--color-text);
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-violet);
}

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 2rem;
}

.login-card {
  position: relative;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-card__logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.login-card__logo span { color: var(--color-violet); }
.login-card__sub { color: var(--color-muted); font-size: 0.88rem; margin-bottom: 1.75rem; }

/* ── Countdown ───────────────────────────────────────────────── */
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.25em 0.6em;
  border-radius: 99px;
  background: #fef9c3;
  color: #854d0e;
}

.countdown--urgent { background: #fee2e2; color: #b91c1c; }
.countdown--done   { background: #dcfce7; color: #15803d; }

/* ── Lead card ───────────────────────────────────────────────── */
.lead-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.lead-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.lead-card:hover { box-shadow: var(--shadow-card); }

.lead-card__img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.lead-card__body { padding: 1rem; }
.lead-card__title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.4rem; }
.lead-card__meta { font-size: 0.8rem; color: var(--color-muted); display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.lead-card__price { font-weight: 800; color: var(--color-violet); font-size: 1.05rem; margin-top: 0.5rem; }

/* ── Progress bar ────────────────────────────────────────────── */
.progress-wrap { margin: 0.5rem 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--color-muted); margin-bottom: 0.25rem; }
.progress-bar { height: 6px; border-radius: 99px; background: var(--color-border); overflow: hidden; }
.progress-bar__fill { height: 100%; background: var(--color-violet); border-radius: 99px; transition: width 0.5s; }

/* ── Alert banner ────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}
.alert--danger  { background: #fee2e2; border-color: var(--color-danger); color: #991b1b; }
.alert--warning { background: #fef9c3; border-color: var(--color-warning); color: #854d0e; }
.alert--success { background: #dcfce7; border-color: var(--color-success); color: #14532d; }
.alert--info    { background: #dbeafe; border-color: var(--color-info); color: #1e3a8a; }

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 340px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  background: var(--color-text);
  color: var(--color-white);
}
#toast.toast--success { background: var(--color-success); }
#toast.toast--danger  { background: var(--color-danger); }
#toast.toast--warning { background: var(--color-warning); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(50,35,111,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 48px rgba(50,35,111,0.18);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }

/* ── Filters bar ─────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.filters select, .filters input {
  padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--color-white);
  color: var(--color-text);
}

/* ── Tier progress ───────────────────────────────────────────── */
.tier-card {
  background: linear-gradient(135deg, var(--color-text) 0%, #14606A 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.tier-card__name { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.tier-card__sub { opacity: 0.75; font-size: 0.88rem; margin-bottom: 1rem; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
}
.empty__icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty__text { font-size: 0.95rem; }

/* ── Mobile header ─────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  background: var(--color-text);
  color: var(--color-white);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.mobile-header__brand {
  font-weight: 800;
  font-size: 1rem;
  color: var(--color-white);
  text-decoration: none;
}

.mobile-header__brand { display: flex; align-items: center; }
/* A barra do telemovel tem 54px de altura. A 30px a palavra "Partners" ficava
   com 7px de caixa e deixava de se ler; 36px enche a barra sem a tocar. */
.mobile-header__brand img { display: block; height: 36px; width: auto; }

.hamburger {
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

.sidebar-overlay.open { display: block; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    top: 0 !important;
    /* A barra comeca em `top: 0` para o fundo cobrir o ecra todo, mas o
       cabecalho do telemovel esta por cima dela (z-index 300 contra 200): sem
       este recuo a marca da barra nasce por baixo do cabecalho e os dois
       logotipos sobrepoem-se. */
    padding-top: calc(54px + 1rem);
  }
  .sidebar.open { transform: translateX(0); }
  /* O cabecalho ja assina com o mesmo logotipo e fica por cima da barra: com os
     dois visiveis a marca aparecia duas vezes, empilhada, a 30px de distancia.
     O link para o dashboard nao se perde, e o primeiro item do menu. */
  .sidebar__logo { display: none; }
  .main-content {
    margin-left: 0;
    max-width: 100vw;
    padding: 1rem;
    padding-top: 70px;
  }
}

/* ── Selector de idioma na barra lateral ────────────────────── */
/* A barra lateral é escura, por isso o selector do site público (pensado para
   fundo claro) não serve aqui tal como está. */
.sidebar__lang { margin-bottom: 0.75rem; }

.sidebar__lang label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 0.3rem;
}

.sidebar__lang select {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  padding: 0.35rem 1.75rem 0.35rem 0.55rem;
  color: var(--color-white);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23ffffff' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
}

.sidebar__lang select option { color: #111; }

/* Ecrã de entrada: o selector fica no canto do cartão, não há barra lateral.
   O `absolute` abaixo precisa que o cartão estabeleça o bloco contentor, que
   é o que a regra `.login-card` faz: sem isso a âncora é o viewport e o
   selector aterra no canto da janela, a 790 px do cartão em desktop e 162 px
   acima dele no telemóvel, órfão sobre o fundo. */
.login-lang {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

/* Ao contrário do selector da barra lateral, de onde estas cores foram
   copiadas, este é desenhado sobre fundo claro: herdar aquelas escrevia
   #f0eeff sobre #F4F6FA, 1,06:1, e o corretor deixava de ver o único
   controlo que muda a língua do portal. */
.login-lang select {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.25rem 1.6rem 0.25rem 0.5rem;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%230A2140' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.login-lang select option { color: #111; }

/* As condicoes gerais existiam e nao tinham link nenhum no portal: a unica
   forma de la chegar era escrever o URL. Um contrato que ninguem consegue
   abrir e um contrato que ninguem leu. */
.sidebar__terms {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.72rem;
  text-align: center;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
}

.sidebar__terms:hover { color: rgba(255,255,255,0.75); text-decoration: underline; }

/* Caixa de aceitação das condições gerais no modal de compra (cláusula 13). */
.modal-accept {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  line-height: 1.4;
  cursor: pointer;
}
.modal-accept input[type="checkbox"] {
  margin-top: .2rem;
  flex-shrink: 0;
}
.modal-accept a { text-decoration: underline; }

/* Per-field refusal, printed under the input the server named. Muted red
   rather than the page-level danger banner: the banner says the save failed,
   this says which field to go and fix. */
.field-error {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--color-danger, #c0392b);
}
.field-error:empty { display: none; }
