/* ==========================================================================
   Ynerluz · Portal de Agentes
   components.css — componentes reutilizáveis
   ========================================================================== */

/* Botões ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius);
  font-weight: 700;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn__icon { width: 24px; height: 24px; flex: none; }

/* Botão principal (login) */
.btn--primary {
  width: 100%;
  height: 57px;
  border-radius: 9px;
  background: var(--green-2);
  color: var(--grey-dark);
  font-size: 20px;
  font-weight: 500;
}
.btn--primary:hover { background: #3fdc3b; }
.btn--primary:active { background: #35c932; }
.btn--primary:disabled { opacity: .5; cursor: not-allowed; }

/* Botão de ação (Novo cliente / Novo contrato / ...) */
.btn--outline {
  height: 49px;
  padding: 9px 14px;
  border: .709px solid var(--green-1);
  background: rgba(198, 239, 210, 0.22);
  color: var(--green-1);
  font-size: 14px;
}
.btn--outline:hover { background: rgba(198, 239, 210, 0.55); }

/* Botão escuro (Filtrar) */
.btn--dark {
  height: 43px;
  padding: 0 20px;
  background: var(--grey-dark);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.14px;
  text-transform: capitalize;
}
.btn--dark:hover { background: #3d3b44; }

/* Badges de estado ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px 5px 12px;
  border-radius: 39px;
  font-size: 12px;
  font-weight: 600;
  line-height: normal;
  white-space: nowrap;
}
.badge--pendente  { background: var(--lima); color: var(--black); }
.badge--ativo     { background: rgba(79, 233, 75, 0.2); color: var(--green-1); }
.badge--cancelado { background: rgba(242, 76, 5, 0.2); color: var(--alerta); }

/* Contador (notificações) */
.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--green-2);
  color: var(--grey-dark);
  font-size: 15.29px;
  font-weight: 700;
  line-height: normal;
}

/* Ponto de cor */
.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
}
.dot--green  { background: var(--green-2); }
.dot--lima   { background: var(--lima); }
.dot--orange { background: var(--alerta); }
.dot--grey   { background: #d9d9d9; }

/* Cartões ---------------------------------------------------------------- */
.card {
  background: var(--white);
  border-radius: var(--radius-card);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--grey-dark);
}
.card__link {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-1);
}
.card__link:hover { text-decoration: underline; }

/* Campo de formulário com label flutuante (login / recuperar) ------------ */
.field {
  position: relative;
  height: 64px;
}
.field__input {
  position: absolute;
  left: 0;
  right: 0;
  top: 7px;
  width: 100%;
  height: 57px;
  padding: 0 23px;
  border: 1px solid var(--grey-forms);
  border-radius: var(--radius);
  background: transparent;
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  outline: 0;
  transition: border-color .15s ease;
}
.field__input:focus { border-color: var(--green-2); }
.field--password .field__input { padding-right: 60px; }
.field__label {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 20px;
  padding: 0 4px;
  background: var(--grey-dark);
  color: var(--grey-forms);
  font-size: 14px;
  font-weight: 500;
  line-height: 13px;
  letter-spacing: -.14px;
  text-transform: uppercase;
  white-space: nowrap;
}
.field__toggle {
  position: absolute;
  top: 20px;
  right: 23px;
  width: 24px;
  height: 24px;
  opacity: 1;
  transition: opacity .15s ease;
}
.field__toggle[aria-pressed="true"] { opacity: .45; }
.field.is-invalid .field__input { border-color: var(--alerta); }
.field.is-invalid .field__label { color: var(--alerta); }

/* Controlo de filtro (select / input) ------------------------------------ */
.control {
  position: relative;
  height: 43px;
}
.control__input {
  width: 100%;
  height: 100%;
  padding: 9px 38px 9px 14px;
  border: .709px solid rgba(155, 155, 155, 0.5);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--grey-dark);
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  outline: 0;
  transition: border-color .15s ease;
}
.control__input:focus { border-color: var(--green-1); }
.control__input::placeholder { color: var(--grey-dark); opacity: 1; }
.control__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.control__chevron {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 19px;
  height: 19px;
  transform: translateY(-50%) rotate(90deg);
  pointer-events: none;
}

/* Tabelas (grid) --------------------------------------------------------- */
.table { width: 100%; }
.table__head,
.table__row {
  display: grid;
  grid-template-columns: var(--cols);
  align-items: center;
}
.table__head {
  height: 46px;
  border-radius: var(--radius);
  background: var(--table-head-bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-forms);
}
.table__row { font-size: 14px; }
.table__head > span,
.table__row > span { min-width: 0; padding-right: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table__head > span:last-child,
.table__row > span:last-child { padding-right: 0; }
.cell--id    { font-weight: 700; color: var(--black); }
.cell--name  { font-weight: 500; color: var(--black); }
.cell--strong{ font-weight: 600; color: var(--black); }
.cell--muted { font-weight: 500; color: var(--grey-forms); }
.cell--dark  { font-weight: 600; color: var(--grey-dark); }
.cell--link  { font-weight: 700; color: var(--green-1); }
.cell--link:hover { text-decoration: underline; }
.table-empty {
  padding: 24px 14px;
  color: var(--grey-forms);
  font-weight: 500;
  text-align: center;
}

/* Paginação -------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.pagination__pages {
  display: flex;
  gap: 9.5px;
  padding: 9.5px;
}
.pagination__page {
  min-width: 28px;
  padding: 4.8px 9.5px;
  border-radius: 7px;
  background: var(--white);
  color: var(--grey-forms);
  font-size: 15.29px;
  line-height: normal;
  transition: background-color .15s ease, color .15s ease;
}
.pagination__page:hover { background: #e9f9e8; color: var(--grey-dark); }
.pagination__page.is-active {
  background: #b8f3b6;
  color: var(--grey-dark);
  font-weight: 700;
}
.pagination__ellipsis { padding: 4.8px 2px; color: var(--grey-forms); font-size: 15.29px; }
.pagination__next {
  width: 31px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pagination__next img { transform: rotate(-90deg); }
.pagination__next:disabled { opacity: .3; cursor: default; }

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--grey-dark);
  border-radius: 0 24px 24px 0;
  overflow: hidden;
  transition: width .25s ease;
}
.sidebar.is-search-open { width: var(--sidebar-w-open); }

.sidebar__leaf {
  position: absolute;
  left: -255px;
  bottom: -499px;
  width: 822px;
  height: 822px;
  max-width: none;
  opacity: .2;
  pointer-events: none;
}

.sidebar__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  height: 100%;
  padding: 56px 40px 38px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar__inner::-webkit-scrollbar { display: none; }
.sidebar__inner > * { flex-shrink: 0; }

.sidebar__brand {
  display: block;
  margin-left: 7px;
  width: max-content;
}
.sidebar__logo { width: 135px; height: 30px; }
.sidebar__tagline {
  display: block;
  margin: 8px 0 0 1px;
  font-size: 14px;
  font-weight: 300;
  color: var(--grey-forms);
}

.sidebar__search {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 250px;
  height: 52px;
  margin-top: 79px;
  padding: 0 19px;
  border: 1px solid rgba(155, 155, 155, 0.15);
  border-radius: var(--radius);
  color: var(--grey-light);
  font-size: 16px;
  font-weight: 700;
  transition: background-color .15s ease, border-color .15s ease;
}
.sidebar__search:hover { background: rgba(155, 155, 155, 0.1); }
.sidebar__search-icon--active { display: none; }
.is-search-open .sidebar__search {
  background: var(--green-1);
  border-color: var(--green-1);
  color: var(--white);
}
.is-search-open .sidebar__search-icon--idle { display: none; }
.is-search-open .sidebar__search-icon--active { display: block; }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 42px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 250px;
  padding: 15px 20px;
  border: 1px solid var(--menu-item-border);
  border-radius: var(--radius);
  background: var(--menu-item-bg);
  color: var(--grey-light);
  font-size: 16px;
  font-weight: 700;
  transition: background-color .15s ease, border-color .15s ease;
}
.nav-item:hover { background: rgba(155, 155, 155, 0.25); }
.nav-item.is-active {
  border-color: var(--green-2);
  color: var(--green-2);
}
.nav-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  flex: none;
}
.nav-item__label { white-space: nowrap; }
.nav-item__counter { margin-left: auto; }

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 250px;
  height: 55px;
  margin-top: auto;
  padding: 9px 6px 9px 9px;
  border-radius: var(--radius);
  background: rgba(155, 155, 155, 0.1);
  transition: background-color .15s ease;
}
.sidebar__user:hover { background: rgba(155, 155, 155, 0.18); }
.sidebar__nav + .sidebar__user { padding-top: 9px; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37.4px;
  height: 37.4px;
  flex: none;
  border-radius: 50%;
  background: var(--green-1);
}
.sidebar__user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sidebar__user-name {
  font-size: 14.39px;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-role {
  font-size: 10.07px;
  font-weight: 300;
  color: var(--grey-forms);
}
.sidebar__user-chevron { flex: none; }

/* Backdrop para fechar a pesquisa ao clicar fora */
.sidebar-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: none;
}
.sidebar-backdrop.is-visible { display: block; }

/* Painel de pesquisa (menu expandido) ------------------------------------ */
.search-panel {
  position: absolute;
  z-index: 2;
  top: 0;
  left: var(--sidebar-w);
  width: calc(var(--sidebar-w-open) - var(--sidebar-w));
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 57px 18px 20px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s ease .05s, visibility 0s linear .3s;
}
.is-search-open .search-panel {
  visibility: visible;
  opacity: 1;
  transition: opacity .2s ease .1s, visibility 0s;
}
.search-panel::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 46px;
  bottom: 39px;
  width: 1px;
  background: rgba(155, 155, 155, 0.35);
}
.search-panel__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 24px;
  height: 24px;
  opacity: .9;
}
.search-panel__close:hover { opacity: 1; }
.search-panel__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  font-size: 21.23px;
  font-weight: 700;
  color: var(--green-2);
}
.search-field {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 397px;
  max-width: 100%;
  height: 55px;
  margin-bottom: 35px;
  padding: 15px 19px 16px;
  border: 1px solid var(--grey-forms);
  border-radius: var(--radius);
  transition: border-color .15s ease;
}
.search-field:focus-within { border-color: var(--green-2); }
.search-field__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 16px;
  outline: 0;
}
.search-field__input::placeholder { color: #6b6a6a; opacity: 1; }
.search-field__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(155,155,155,.4) transparent;
}
.search-results__empty {
  padding: 10px 2px;
  color: var(--grey-forms);
  font-size: 15px;
}

.result-card {
  display: block;
  width: 398px;
  max-width: 100%;
  padding: 15px;
  border-radius: var(--radius);
  background: var(--search-card-bg);
  text-align: left;
  transition: background-color .15s ease;
}
.result-card:hover { background: #3a383f; }
.result-card__row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.result-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 9px;
  background: var(--green-2);
}
.result-card__title {
  width: 301px;
  max-width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: var(--grey-forms);
  word-break: break-word;
}
.result-card__meta {
  display: flex;
  align-items: flex-end;
  gap: 30px;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 300;
  color: var(--grey-forms);
}
.result-card__sep {
  width: 1px;
  height: 15px;
  background: var(--grey-forms);
}

/* Toast ------------------------------------------------------------------ */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 28px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--grey-dark);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Barra superior (só em ecrãs estreitos; ver pages.css) ------------------ */
.topbar {
  display: none;
  position: fixed;
  z-index: 45;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--grey-dark);
  border-radius: 0 0 16px 16px;
}
.topbar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: var(--radius);
  transition: background-color .15s ease;
}
.topbar__btn:hover { background: rgba(155, 155, 155, 0.15); }
.topbar__brand {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding-left: 2px;
}
.topbar__brand img { width: 101px; height: 22px; }
.menu-toggle__bar {
  position: relative;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--white);
}
.menu-toggle__bar::before,
.menu-toggle__bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--white);
}
.menu-toggle__bar::before { top: -6px; }
.menu-toggle__bar::after  { top: 6px; }
