/*
 * sz-tokyo-contact-modal.css
 * Redesign do modal "Novo contato" — light mode (Figma #1652706300/04).
 * Aplicado apenas no tenant tokyo via nginx sub_filter.
 *
 * Estrutura runtime do modal:
 *   <dialog>                              <- teleported to body
 *     <form>                              <- Dialog.vue (bg-n-alpha-3 etc)
 *       [.sz-tcm-header]                  <- INJETADO via JS (titulo + X)
 *       <div class="sz-cdf-form">         <- ContactsForm.vue (já estilizado)
 *         [.sz-tcm-tags]                  <- INJETADO via JS (Etiquetas)
 *         <div class="sz-cdf-grid">       <- grid de inputs
 *         <div class="sz-cdf-social-card"><- escondido aqui
 *       <div class="flex ... justify-between"> <- footer (Cancelar / Criar)
 *
 * O selector raiz é `dialog form:has(.sz-cdf-form)` pra mirar APENAS o modal
 * de criar contato (form de edicao do contato e inline, fora de <dialog>).
 */

/* ===== Container do modal — bg branco solido, sem blur ===== */
dialog form:has(.sz-cdf-form) {
  padding: 0 !important;
  gap: 0 !important;
  background: #FFFFFF !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}

/* ===== Header injetado (titulo + X) ===== */
.sz-tcm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #E5E5E5;
}
.sz-tcm-title {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 20px;
  line-height: 28px;
  color: #000000;
}
.sz-tcm-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #525252;
  border-radius: 6px;
  padding: 0;
  transition: background 0.12s ease;
}
.sz-tcm-close:hover {
  background: #F5F5F5;
}
.sz-tcm-close:focus,
.sz-tcm-close:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.sz-tcm-close svg {
  width: 20px;
  height: 20px;
}

/* ===== Body — padding interno do form de campos ===== */
dialog form:has(.sz-cdf-form) > .sz-cdf-form {
  padding: 24px !important;
  gap: 20px !important;
}

/* ===== Etiquetas (area injetada antes do grid) ===== */
.sz-tcm-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sz-tcm-tags-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  color: #262626;
}
.sz-tcm-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  position: relative; /* offsetParent do dropdown absolute */
}
.sz-tcm-tag-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  background: #E9E9E9;
  border: 1px dashed #CFCFCF;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  color: #000000;
  cursor: pointer;
}
.sz-tcm-tag-add svg {
  width: 12px;
  height: 12px;
}
.sz-tcm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
}
.sz-tcm-tag-dot {
  width: 9px;
  height: 9px;
  border-radius: 8px;
}
.sz-tcm-tag-x {
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  opacity: 0.7;
}
.sz-tcm-tag-x:hover { opacity: 1; }

/* ===== Dropdown de selecao de etiquetas (rich: search + checkbox + pill) ===== */
.sz-tcm-dropdown {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  width: 260px;
  max-height: 380px;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Search header — wrapper externo (padding/borda) */
.sz-tcm-dd-search {
  padding: 6px;
  border-bottom: 1px solid #E5E5E5;
  flex-shrink: 0;
}
/* Search field — FLEX (icone + input lado a lado, sem position:absolute) */
.sz-tcm-dd-search-field {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  background: #F5F5F5;
  border: 1px solid #E5E5E5;
  border-radius: 6px;
  gap: 8px;
  box-sizing: border-box;
}
.sz-tcm-dd-search-field:focus-within {
  border-color: #388E3C;
}
.sz-tcm-dd-search-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9797A0;
  pointer-events: none;
}
.sz-tcm-dd-search-icon svg { width: 16px; height: 16px; }
.sz-tcm-dd-search-input {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  color: #000000;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  text-align: left;
  vertical-align: middle;
}
.sz-tcm-dd-search-input::placeholder { color: #9797A0; opacity: 1; }

/* Divisor entre Selecionadas e nao-selecionadas */
.sz-tcm-dd-divider {
  height: 1px;
  background: #E5E5E5;
  margin: 4px 0;
}

/* List */
.sz-tcm-dd-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px;
  min-height: 60px;
  max-height: 320px;
}
.sz-tcm-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 6px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  color: #000000;
}
.sz-tcm-dd-item:hover { background: #F5F5F5; }

/* Checkbox visual */
.sz-tcm-dd-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid #D1D5DB;
  border-radius: 4px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.sz-tcm-dd-check[data-checked="1"] {
  background: #388E3C;
  border-color: #388E3C;
  color: #FFFFFF;
}
.sz-tcm-dd-check svg { width: 10px; height: 10px; }

/* Pill colorida do item — ellipsis no texto pra nao quebrar layout */
.sz-tcm-dd-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  max-width: calc(100% - 22px);
  min-width: 0;
  overflow: hidden;
}
.sz-tcm-dd-pill > span:not(.sz-tcm-dd-pill-dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sz-tcm-dd-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sz-tcm-dd-empty {
  padding: 16px 12px;
  font-weight: 400;
  font-size: 13px;
  line-height: 20px;
  color: #9797A0;
  text-align: center;
}

/* Toast de sucesso — spec Figma (bg #262626, radius 8, title 16/D4D4D4,
 * body 12 verde #7CCF00, data #A1A1A1) — canto INFERIOR direito */
.sz-tcm-success-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100000;
  width: 458px;
  background: #262626;
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.1);
}
.sz-tcm-success-toast .sz-tcm-success-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sz-tcm-success-title {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  color: #D4D4D4;
}
.sz-tcm-success-close {
  background: transparent;
  border: 0;
  padding: 0;
  width: 24px;
  height: 24px;
  cursor: pointer;
  color: #D4D4D4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sz-tcm-success-close:hover { color: #FFFFFF; }
.sz-tcm-success-close svg { width: 24px; height: 24px; }
.sz-tcm-success-body {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  font-size: 12px;
  line-height: 20px;
  color: #7CCF00;
}
.sz-tcm-success-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #7CCF00;
  display: inline-flex;
}
.sz-tcm-success-check svg { width: 16px; height: 16px; }
.sz-tcm-success-date {
  font-weight: 400;
  font-size: 12px;
  line-height: 20px;
  color: #A1A1A1;
}

/* Toast — light mode */
body:not(.dark) .sz-tcm-success-toast,
.sz-tcm-success-toast {
  /* default DARK ja definido acima; light override abaixo */
}
body:not(.dark) .sz-tcm-success-toast {
  background: #FFFFFF;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.15);
}
body:not(.dark) .sz-tcm-success-title { color: #262626; }
body:not(.dark) .sz-tcm-success-body { color: #388E3C; }
body:not(.dark) .sz-tcm-success-check { color: #388E3C; }
body:not(.dark) .sz-tcm-success-date { color: #6B6B75; }
body:not(.dark) .sz-tcm-success-close { color: #6B6B75; }
body:not(.dark) .sz-tcm-success-close:hover { color: #262626; }

/* Mensagem de erro: telefone duplicado */
.sz-tcm-phone-error {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 12px;
  line-height: 20px;
  color: #FFA2A2;
}
.sz-tcm-phone-error.sz-tcm-active { display: inline-flex; }
.sz-tcm-phone-error-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background: #DC2626;
  color: #FFFFFF;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', system-ui, sans-serif;
}
.sz-tcm-phone-error-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.sz-tcm-phone-error-link:hover { color: #FF6B6B; }

/* Bandeira BR (substitui emoji que Chrome/Win nao renderiza) */
.sz-tcm-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 18px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.sz-tcm-flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Heading "Selecionadas" no topo da lista */
.sz-tcm-dd-heading {
  padding: 8px 8px 4px;
  font-family: inherit;
  font-weight: 500;
  font-size: 11px;
  line-height: 16px;
  color: #6B6B75;
  letter-spacing: 0.02em;
}

/* ===== Esconder campos que nao aparecem no spec ===== */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(2),  /* Sobrenome */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(5),  /* Cidade */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(6),  /* Pais */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(7),  /* Bio */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(8) { /* Empresa */
  display: none !important;
}

/* Esconder card colapsavel "Redes sociais" */
dialog form:has(.sz-cdf-form) .sz-cdf-social-card {
  display: none !important;
}

/* ===== Reordenar visiveis: Nome(1) | Telefone(4) / E-mail(3) full-width ===== */
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(1) {
  order: 1;
  grid-column: 1;
}
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(4) {
  order: 2;
  grid-column: 2;
}
dialog form:has(.sz-cdf-form) .sz-cdf-grid .sz-cdf-field:nth-child(3) {
  order: 3;
  grid-column: 1 / -1;
}

/* ===== Inputs — bump pra 48px (spec do print) ===== */
dialog form:has(.sz-cdf-form) .sz-cdf-grid input:not([type="checkbox"]):not([type="radio"]):not([type="search"]):not([type="tel"]) {
  height: 48px !important;
  padding: 12px 16px !important;
}

/* ===== Label: asterisco vermelho ANTES (ja era assim no .vue), font weight 500 ===== */
dialog form:has(.sz-cdf-form) .sz-cdf-label {
  font-weight: 500 !important;
}

/* ===== Footer — alinhamento direita + divisor superior ===== */
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between {
  padding: 16px 24px !important;
  border-top: 1px solid #E5E5E5 !important;
  justify-content: flex-end !important;
  gap: 12px !important;
}

/* ===== Botao Cancelar (variant=link no .vue) -> bordered branco ===== */
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"] {
  background: #FFFFFF !important;
  border: 1px solid #D1D5DB !important;
  border-radius: 8px !important;
  color: #000000 !important;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  line-height: 20px !important;
  height: auto !important;
  padding: 10px 20px !important;
  outline: none !important;
  text-decoration: none !important;
}
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"]:hover {
  background: #F5F5F5 !important;
  text-decoration: none !important;
}

/* ===== Botao Criar contato (color=blue no .vue) -> verde brand ===== */
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="submit"] {
  background: #388E3C !important;
  color: #000000 !important;
  border-radius: 8px !important;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  line-height: 20px !important;
  height: auto !important;
  padding: 10px 20px !important;
  outline: none !important;
}
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="submit"]:hover:not(:disabled) {
  background: #2E7D32 !important;
  filter: none !important;
}
dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="submit"]:disabled {
  opacity: 0.5 !important;
}

/* ===================================================================== */
/* ============================== DARK MODE ============================ */
/* ===================================================================== */
/* Chatwoot aplica .dark no body. Replico todas as cores fixas pra escuras. */

/* Container — bg + border solidos (spec Figma: bg #1D1E21, border 1px #303138) */
.dark dialog form:has(.sz-cdf-form),
body.dark dialog form:has(.sz-cdf-form) {
  background: #1D1E21 !important;
  border: 1px solid #303138 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

/* Header dark */
.dark .sz-tcm-header,
body.dark .sz-tcm-header {
  border-bottom-color: #2A2C30;
}
.dark .sz-tcm-title,
body.dark .sz-tcm-title {
  color: #FFFFFF;
}
.dark .sz-tcm-close,
body.dark .sz-tcm-close {
  color: #9797A0;
}
.dark .sz-tcm-close:hover,
body.dark .sz-tcm-close:hover {
  background: #2A2C30;
}

/* Etiquetas (label + botao add) dark */
.dark .sz-tcm-tags-label,
body.dark .sz-tcm-tags-label {
  color: #FFFFFF;
}
.dark .sz-tcm-tag-add,
body.dark .sz-tcm-tag-add {
  background: #3D3F43;
  border-color: #3D3F43;
  color: #FFFFFF;
}

/* Footer dark */
.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between,
body.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between {
  border-top-color: #2A2C30 !important;
}

/* Botao Cancelar dark — transparente + borda + texto branco */
.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"],
body.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"] {
  background: transparent !important;
  border-color: #3D3F43 !important;
  color: #FFFFFF !important;
}
.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"]:hover,
body.dark dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="reset"]:hover {
  background: #2A2C30 !important;
}

/* Botao Criar contato — texto BRANCO no light, PRETO no dark */
body:not(.dark) dialog form:has(.sz-cdf-form) > div.flex.items-center.justify-between button[type="submit"] {
  color: #FFFFFF !important;
}

/* Dropdown dark */
.dark .sz-tcm-dropdown,
body.dark .sz-tcm-dropdown {
  background: #1F1F23;
  border-color: #2A2C30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.dark .sz-tcm-dd-search,
body.dark .sz-tcm-dd-search {
  border-bottom-color: #2A2C30;
}
.dark .sz-tcm-dd-search-field,
body.dark .sz-tcm-dd-search-field {
  background: #2A2C30;
  border-color: #3D3F43;
}
.dark .sz-tcm-dd-search-input,
body.dark .sz-tcm-dd-search-input {
  color: #FFFFFF;
}
.dark .sz-tcm-dd-search-input::placeholder,
body.dark .sz-tcm-dd-search-input::placeholder {
  color: #9797A0;
}
.dark .sz-tcm-dd-item,
body.dark .sz-tcm-dd-item {
  color: #FFFFFF;
}
.dark .sz-tcm-dd-item:hover,
body.dark .sz-tcm-dd-item:hover {
  background: #2A2C30;
}
.dark .sz-tcm-dd-check,
body.dark .sz-tcm-dd-check {
  border-color: #3D3F43;
}
.dark .sz-tcm-dd-empty,
body.dark .sz-tcm-dd-empty {
  color: #9797A0;
}
.dark .sz-tcm-dd-heading,
body.dark .sz-tcm-dd-heading {
  color: #9797A0;
}
.dark .sz-tcm-dd-divider,
body.dark .sz-tcm-dd-divider {
  background: #2A2C30;
}

/* Garantir que labels Nome/Telefone/E-mail apareçam em branco no dark.
 * O .vue ja tem `.dark .sz-cdf-label { color:#FFFFFF }` mas o scoped-style
 * pode nao bater dentro do <dialog> teleportado. Forçamos aqui. */
.dark dialog form:has(.sz-cdf-form) .sz-cdf-label,
body.dark dialog form:has(.sz-cdf-form) .sz-cdf-label {
  color: #FFFFFF !important;
}

/* ===================================================================== */
/* DARK — campos SEM fill (Figma: fundo = modal #1D1E21, so bordas 1.5px #303138)
 * Sobrepoe o scoped do fork (ContactsForm.vue) que pinta o campo de cinza
 * #242528 em dark. Cobre os 3 visiveis: Nome/E-mail (input texto) + Telefone
 * (wrapper composto bandeira+tel). Altura 48px ja vem da regra acima. */
body.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid input:not([type="checkbox"]):not([type="radio"]):not([type="search"]):not([type="tel"]),
.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid input:not([type="checkbox"]):not([type="radio"]):not([type="search"]):not([type="tel"]),
body.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid textarea,
.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid textarea {
  background: #1D1E21 !important;
  border: 1.5px solid #303138 !important;
}
/* Telefone — wrapper composto (bandeira/chevron e input tel internos ja sao
 * transparentes, entao mostram este fundo) */
body.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid .relative.flex.items-center,
.dark dialog form:has(.sz-cdf-form) .sz-cdf-grid .relative.flex.items-center {
  background: #1D1E21 !important;
  border: 1.5px solid #303138 !important;
}
