/* ══════════════════════════════════════════
   FORM LAYOUT
══════════════════════════════════════════ */
.form-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-col-2  { grid-column: span 2; }
.form-col-3  { grid-column: span 3; }

.form-section { margin-bottom: var(--sp-8); }
.form-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
}

/* ══════════════════════════════════════════
   FIELD
══════════════════════════════════════════ */
.form-field { display: flex; flex-direction: column; gap: var(--sp-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: var(--sp-2);
}
.form-label .required { color: var(--color-danger); font-size: var(--text-xs); }
.form-label svg { width: 12px; height: 12px; color: var(--text-muted); }

/* ══════════════════════════════════════════
   INPUTS
══════════════════════════════════════════ */
.form-input,
.form-textarea,
.form-select-native {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--t-fast), background var(--t-fast);
  appearance: none;
  outline: none;
}
.form-select-native,
select.form-input {
  background: var(--bg-dropdown);
}
.form-input::placeholder { color: var(--text-disabled); }

.form-input:hover,
.form-textarea:hover { border-color: var(--border-strong); }

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea {
  height: auto;
  min-height: 96px;
  padding: var(--sp-3);
  resize: vertical;
  line-height: 1.6;
}

/* Input with icon */
.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-left: 38px; }
.input-wrapper .input-icon {
  position: absolute; left: var(--sp-3); top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; display: flex;
}
.input-wrapper .input-icon svg { width: 14px; height: 14px; }
.input-wrapper .input-suffix {
  position: absolute; right: var(--sp-3); top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: var(--text-sm);
}

/* Search input */
.search-input-wrapper {
  position: relative;
  flex: 1; min-width: 180px; max-width: 380px;
}
.search-input {
  width: 100%; height: 38px;
  padding: 0 var(--sp-4) 0 40px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--t-fast);
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.search-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; display: flex;
}
.search-icon svg { width: 14px; height: 14px; }

.search-clear {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); border-radius: var(--r-sm); padding: 2px;
  display: none; transition: color var(--t-fast); cursor: pointer;
}
.search-clear:hover { color: var(--text-primary); }
.search-clear svg { width: 12px; height: 12px; }
.search-input:not(:placeholder-shown) ~ .search-clear { display: flex; }

/* ══════════════════════════════════════════
   CUSTOM SELECT
══════════════════════════════════════════ */
.custom-select { position: relative; display: inline-flex; z-index: 20; }

.custom-select-trigger {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-3);
  background: var(--bg-dropdown);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  min-width: 90px;
}
.custom-select-trigger svg { width: 13px; height: 13px; flex-shrink: 0; transition: transform var(--t-base); }
.custom-select-trigger .chevron { color: var(--text-muted); margin-left: auto; }
.custom-select-current,
.custom-select-trigger .label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.custom-select.is-open .custom-select-trigger {
  border-color: var(--accent); color: var(--text-primary);
}
.custom-select.is-open .chevron { transform: rotate(180deg); }

.custom-select.has-value .custom-select-trigger {
  border-color: var(--accent-border);
  color: var(--accent-hover);
  background: var(--bg-dropdown);
}

.custom-select-menu {
  position: absolute; top: calc(100% + 5px); left: 0;
  min-width: 100%; width: max-content; max-width: 250px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: 4px; z-index: 9999;
  opacity: 0; transform: translateY(-5px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  transform-origin: top left;
  max-height: 270px; overflow-y: auto;
}
.custom-select.is-open .custom-select-menu {
  opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
}

.custom-select-option {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm); color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.custom-select-option:hover,
.custom-select-option:focus { background: var(--bg-surface-2); color: var(--text-primary); outline: none; }
.custom-select-option.is-selected { background: var(--accent-dim); color: var(--accent-hover); }
.custom-select-option .check-icon { margin-left: auto; opacity: 0; }
.custom-select-option.is-selected .check-icon { opacity: 1; }
.custom-select-option svg { width: 13px; height: 13px; flex-shrink: 0; }

.geo-option-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  white-space: nowrap;
}

.geo-option-text {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

/* ══════════════════════════════════════════
   VALIDATION
══════════════════════════════════════════ */
.form-error {
  font-size: var(--text-xs); color: var(--color-danger);
  display: flex; align-items: center; gap: 4px;
}
.form-error svg { width: 11px; height: 11px; flex-shrink: 0; }

.form-input.is-invalid { border-color: var(--color-danger) !important; }
.form-input.is-valid   { border-color: var(--color-success) !important; }
.form-hint { font-size: var(--text-xs); color: var(--text-muted); }
.form-hint .secret-status-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 1.55rem;
  padding: 0 .6rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  margin-right: .5rem;
  margin-bottom: .35rem;
}
.form-hint .secret-status-badge.is-configured {
  background: rgba(16, 185, 129, .12);
  color: #7ef0b4;
  border: 1px solid rgba(16, 185, 129, .28);
}
.form-hint .secret-status-copy {
  display: inline;
}
.form-hint .secret-mask {
  display: inline-block;
  margin-left: .5rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: .08em;
}

/* ══════════════════════════════════════════
   TOGGLE / SWITCH
══════════════════════════════════════════ */
.toggle-wrapper {
  display: flex; align-items: center; gap: var(--sp-3);
  cursor: pointer; user-select: none;
}
.toggle { position: relative; width: 38px; height: 21px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  transition: background var(--t-base), border-color var(--t-base);
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-spring), background var(--t-base);
}
.toggle input:checked ~ .toggle-track { background: var(--accent-dim); border-color: var(--accent-border); }
.toggle input:checked ~ .toggle-thumb { transform: translateX(17px); background: var(--accent-hover); }
.toggle-label { font-size: var(--text-sm); color: var(--text-secondary); }

/* ══════════════════════════════════════════
   FILTERS BAR
══════════════════════════════════════════ */
.filters-bar {
  display: flex; align-items: center;
  gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-4);
}

.filters-section {
  display: flex; align-items: center;
  gap: var(--sp-2); flex-wrap: wrap; flex: 1;
}

.filters-actions {
  display: flex; align-items: center;
  gap: var(--sp-2); margin-left: auto; flex-shrink: 0;
}

.filter-divider {
  width: 1px; height: 22px;
  background: var(--border-subtle); flex-shrink: 0;
}

.settings-row-control .form-input,
.settings-row-control .form-select-native { width: 100%; }

.filter-mini-input {
  max-width: 140px; height: 36px; border-radius: var(--r-md);
}

.filter-inline-group {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: nowrap;
}

.filter-inline-group .filter-mini-input {
  width: 140px;
  max-width: 140px;
}

.email-filters-form {
  width: 100%;
}

.email-filter-slot {
  min-width: 148px;
}

.email-filter-slot .form-input {
  height: 36px;
}

.email-filter-slot .custom-select {
  display: flex;
  width: 100%;
}

.email-filter-slot .custom-select-trigger {
  width: 100%;
}

.email-filter-slot .custom-select-menu {
  width: 100%;
  max-width: 280px;
}


.form-field .custom-select { display: flex; width: 100%; }
.form-field .custom-select-trigger { width: 100%; height: 40px; }
.form-field .custom-select-menu { width: 100%; max-width: none; }
.form-field .custom-select-option.is-selected { background: var(--accent-dim); color: var(--text-primary); }

/* ── File picker ── */
.file-pick-wrapper {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.file-pick-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.file-pick-name {
  font-size: var(--text-sm);
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-pick-btn { cursor: pointer; flex-shrink: 0; }

.card-overflow-visible { overflow: visible !important; }
.is-hidden-native { display: none !important; }
.custom-select-form.is-open { z-index: 10000; }

/* ══════════════════════════════════════════
   ESTRELINHA TOGGLE
══════════════════════════════════════════ */
.estrelinha-toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }

.estrelinha-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  cursor: pointer;
  user-select: none;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.estrelinha-toggle-label:hover {
  border-color: var(--border-default);
  background: var(--bg-surface-2);
}

.estrelinha-toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: var(--bg-surface-3);
  border-radius: 999px;
  border: 1px solid var(--border-default);
  transition: background var(--t-base), border-color var(--t-base);
}

.estrelinha-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: transform var(--t-base), background var(--t-base), color var(--t-base);
}

.estrelinha-toggle-input:checked ~ .estrelinha-toggle-track {
  background: var(--color-amber, #f59e0b);
  border-color: var(--color-amber, #f59e0b);
}
.estrelinha-toggle-input:checked ~ .estrelinha-toggle-track .estrelinha-toggle-thumb {
  transform: translateX(20px);
  background: #fff;
  color: var(--color-amber, #f59e0b);
}

.estrelinha-toggle-input:checked ~ .estrelinha-toggle-text .estrelinha-toggle-title {
  color: var(--color-amber, #f59e0b);
}

.estrelinha-toggle-text { display: flex; flex-direction: column; gap: 2px; }
.estrelinha-toggle-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.estrelinha-toggle-sub   { font-size: var(--text-xs); color: var(--text-muted); }
