/* =============================================================
   Brotas Beauty - componentes reutilizaveis:
   botoes, formularios, cartoes, tabelas, modais, avisos e etiquetas.
   ============================================================= */

/* ---------------------------------------------------------------
   Botoes
   --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-outline {
  background: #fff;
  border-color: #cfc8c3;
  color: var(--ink);
}
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); color: var(--ink); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }

.btn-sm {
  min-height: 34px;
  padding: 5px 11px;
  font-size: .82rem;
}

.btn-icon {
  min-height: var(--touch);
  width: var(--touch);
  padding: 0;
  font-size: 1.1rem;
}

.btn-block { width: 100%; }

/* Botao "+" de cadastro rapido ao lado dos campos (item 6) */
.btn-add {
  flex-shrink: 0;
  width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  background: var(--brand-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--brand);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.btn-add:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------------------------------------------------------
   Formularios
   --------------------------------------------------------------- */
.field {
  display: block;
  margin-bottom: 14px;
}

.field > .label,
label > .label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: .8rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid #cfc8c3;
  border-radius: 3px;
  color: var(--ink);
  font: inherit;
  font-size: .78rem;
  transition: border-color .15s, box-shadow .15s;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(193, 77, 134, .13);
  outline: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f5f2f7;
  color: var(--ink-faint);
}

/* Campo somente leitura que mostra um valor calculado */
input[readonly] {
  background: var(--brand-soft);
  font-weight: 600;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.field-row > .field { flex: 1; margin-bottom: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 14px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: var(--touch);
  cursor: pointer;
  font-size: .9rem;
}

.checkbox input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

fieldset {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);

  /* O navegador dá ao fieldset um min-width igual ao conteúdo, e ele
     se recusa a encolher: uma tabela larga dentro dele vaza para fora
     do modal em vez de rolar. Estas duas linhas resolvem. */
  min-width: 0;
  max-width: 100%;
}

legend {
  padding: 0 6px;
  color: var(--ink-soft);
  font-size: .8rem;
  font-weight: 600;
}

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  background: var(--danger-bg);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  color: #8f2033;
  font-size: .86rem;
}

.form-card {
  max-width: 960px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(60, 52, 48, .08);
}

.list-panel {
  max-width: none;
  padding: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------------
   Cartoes e paineis
   --------------------------------------------------------------- */
.card {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(60, 52, 48, .08);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

/* Cartoes de indicador do painel (item 28) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat b {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.15;
}

.stat small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: .76rem;
}

.dashboard-grid,
.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.reports-wide {
  grid-column: 1 / -1;
  max-width: none;
}

.mini-row {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 3px;
}

.mini-row b {
  font-size: .86rem;
}

.mini-row span,
.mini-row small {
  color: var(--ink-soft);
  font-size: .78rem;
}

@media (max-width: 900px) {
  .dashboard-grid,
  .reports-grid {
    grid-template-columns: 1fr;
  }
}

.stat .stat-label {
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.stat .stat-value {
  margin-top: 4px;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

/* ---------------------------------------------------------------
   Tabelas
   --------------------------------------------------------------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;   /* tabela larga rola sozinha, a pagina nao */
  max-width: 100%;
  min-width: 0;
}

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

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: var(--brand-soft);
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky;
  top: 0;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--brand-soft); }

.empty-row {
  padding: 34px 16px;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------------------------------------------------------------
   Barra de busca e filtros das listas
   --------------------------------------------------------------- */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  margin-bottom: 0;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.list-toolbar .search-input {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

.select-inline {
  width: auto;
  min-width: 150px;
}

.list-count { white-space: nowrap; }

/* Linha de cadastro inativo fica esmaecida, mas continua legivel. */
.row-inactive td { opacity: .55; }

.row-actions {
  width: 1%;
}

.row-actions .btn {
  min-height: 28px;
  padding: 4px 8px;
  font-size: .74rem;
}

.row-actions .btn + .btn { margin-left: 4px; }

.data-table th,
.data-table td {
  padding: 9px 12px;
}

.data-table th {
  background: #f7f5f2;
  border-bottom-color: #cfc8c3;
}

.data-table tbody tr:nth-child(even) {
  background: #fbfaf8;
}

.data-table tbody tr:hover {
  background: #fff2ea;
}

@media (max-width: 720px) {
  .list-toolbar .search-input { max-width: none; }
  .list-toolbar .select-inline { flex: 1; }
}

/* ---------------------------------------------------------------
   Etiquetas de status (item 4 e 24)
   --------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-neutral { background: #eeeaf1; color: #5c5464; }
.badge-info    { background: var(--info-bg);   color: var(--info); }
.badge-ok      { background: var(--ok-bg);     color: var(--ok); }
.badge-warn    { background: var(--warn-bg);   color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }

/* ---------------------------------------------------------------
   Etiquetas selecionaveis (areas de atuacao, permissoes)
   --------------------------------------------------------------- */
.chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.chip:hover { border-color: var(--brand); }

.chip input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

/* Marcado fica preenchido, para dar para ver de longe o que está ligado. */
.chip:has(input:checked) {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

.chip:has(input:disabled) { cursor: not-allowed; }

.perm-group { margin-bottom: 14px; }

.perm-group-title {
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Bolinha da cor do profissional na agenda */
.color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
}

/* ---------------------------------------------------------------
   Grade de jornada e lista de servicos dentro do formulario

   Tabelas dentro de um modal nao repetem sombra e borda: elas ja
   estao dentro de um fieldset, e a moldura dupla polui a leitura.
   --------------------------------------------------------------- */
.modal .table-wrap {
  box-shadow: none;
  background: transparent;
}

.modal .table-wrap th {
  background: transparent;
  border-bottom: 2px solid var(--line);
}

.schedule-table th,
.schedule-table td {
  padding: 4px 8px;
  white-space: nowrap;
}

.schedule-table input[type="time"] {
  min-height: 36px;
  width: 100px;
  padding: 4px 6px;
}

.schedule-table .checkbox {
  min-height: 36px;
  font-weight: 600;
}

/* Dia sem atendimento: campos desligados e linha esmaecida, para
   dar para ver de relance quais dias a profissional trabalha. */
.schedule-table .sc-off td:not(:first-child) { opacity: .35; }
.schedule-table .sc-off .checkbox { font-weight: 400; color: var(--ink-soft); }

/* Dia marcado ganha um leve destaque de fundo. */
.schedule-table tr:not(.sc-off):hover { background: transparent; }
.schedule-table tr:not(.sc-off) { background: var(--brand-soft); }

.services-box table td { padding: 6px 8px; }

.services-box input[type="number"] {
  min-height: 36px;
  width: 92px;
  padding: 4px 6px;
}

.services-box .muted { font-size: .74rem; }

/* Nome do serviço não quebra em duas linhas à toa. */
.services-box td:nth-child(2) { min-width: 190px; }

/* ---------------------------------------------------------------
   Modais e painel lateral (itens 5 e 6)
   --------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(43, 36, 48, .45);

  /* Quem rola é o .modal-body, por dentro. O modal em si nunca rola:
     assim o cabeçalho e os botões ficam sempre visíveis. */
  overflow: hidden;
}

.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);

  /* Item de grid também cresce para caber o conteúdo por padrão.
     Sem isto, uma tabela larga estica o modal para fora da tela em
     vez de rolar por dentro. */
  min-width: 0;
}

.modal-box.wide { max-width: 860px; }

/* O <form> fica ENTRE a caixa e o miolo. Sem repassar o flex para ele,
   a cadeia se rompe: o "flex: 1" do .modal-body nao encontra altura
   definida, a rolagem interna nao liga e o formulario vaza para fora
   da caixa branca. */
.modal-box > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* Modal empilhado: o cadastro rapido abre por cima do agendamento
   sem fechar o formulario que ja estava preenchido (item 6). */
.modal.stacked { z-index: 110; background: rgba(43, 36, 48, .3); }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-head h3 { margin-right: auto; }

.modal-close {
  width: 34px;
  height: 34px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--brand-soft); color: var(--ink); }

.modal-body {
  padding: 18px;
  overflow: auto;
  flex: 1;

  /* Sem estes dois zeros o item flex se recusa a ficar menor que o
     conteúdo, o "overflow: auto" acima nunca entra em ação e o miolo
     do formulário vaza para fora da caixa branca do modal. */
  min-height: 0;
  min-width: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--brand-soft);
  border-radius: 0 0 var(--radius) var(--radius);
  flex-shrink: 0;
}

@media (max-width: 720px) {
  /* No celular o modal ocupa a tela toda: mais espaco para os dedos. */
  .modal {
    padding: 0;
    place-items: stretch;
  }

  /* Altura fixa na tela (e nao "minima"): a caixa fica presa ao
     tamanho do aparelho e quem rola e o miolo. */
  .modal-box,
  .modal-box.wide {
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }
}

/* ---------------------------------------------------------------
   Aviso flutuante (toast)
   --------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: .9rem;
  animation: toast-in .2s ease;
}

.toast.ok     { background: var(--ok); }
.toast.error  { background: var(--danger); }
.toast.warn   { background: var(--warn); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------------------------------------------------------
   Carregando
   --------------------------------------------------------------- */
.loading {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 48px;
  color: var(--ink-soft);
  opacity: 0;
  animation: loading-reveal .16s ease .55s forwards;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading-reveal { to { opacity: 1; } }

/* ---------------------------------------------------------------
   Listas compactas usadas em fluxos operacionais
   --------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.view-head.compact {
  margin-bottom: 12px;
}

.view-head.compact h3 {
  margin: 0;
}

.stack-list {
  display: grid;
  gap: 12px;
}

.list-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px;
  background: #fff;
}

.list-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.list-card p {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
  color: var(--ink-soft);
  font-size: .9rem;
}

.status-note,
.alert-box {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--brand-soft);
}

.alert-box {
  margin-top: 12px;
}

.alert-box p {
  margin: 6px 0 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 160px) auto;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.input.compact {
  min-height: 40px;
  width: auto;
}

.closing-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.closing-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.closing-item:hover,
.closing-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.closing-item span {
  color: var(--ink-soft);
  font-size: .84rem;
}

.closing-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}

.closing-totals b {
  padding: 10px;
  background: var(--brand-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}

.closing-payment {
  display: grid;
  grid-template-columns: 160px 140px minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.closing-form {
  grid-template-columns: minmax(200px, 1fr) 120px 120px auto;
}

.commission-actions {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.table-wrap.compact table {
  font-size: .86rem;
}

@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .meta-grid,
  .inline-form,
  .closing-layout,
  .closing-totals,
  .closing-payment,
  .commission-actions {
    grid-template-columns: 1fr;
  }
}
