/*
 * TROFENO Form System — v2.0
 * Sistema de formulários unificado: home + dashboard
 * Grid 8px · Altura mínima 44px · WCAG AA
 */

/* ══ FIELD WRAPPER ══ */
.tf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-2);
}
.tf-field:last-of-type { margin-bottom: 0; }

/* ══ LABEL ══ */
.tf-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-text-primary);
  letter-spacing: .01em;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
}
.tf-label-hint {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--c-text-tertiary);
}
.tf-req { color: var(--c-danger); margin-left: 2px; }

/* ══ INPUT BASE ══ */
.tf-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--sp-2);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow   var(--dur-fast) var(--ease),
    background   var(--dur-fast) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.tf-input::placeholder {
  color: var(--c-text-tertiary);
  font-weight: 400;
}

/* States */
.tf-input:hover:not(:disabled) {
  border-color: var(--c-border-strong);
}
.tf-input:focus:not(:disabled) {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
  background: var(--c-surface);
  outline: none;
}
.tf-input:disabled {
  background: var(--c-surface-sunken);
  color: var(--c-text-tertiary);
  cursor: not-allowed;
  border-color: var(--c-border);
}
.tf-input.is-error {
  border-color: var(--c-danger);
  background: #fff;
}
.tf-input.is-error:focus {
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
.tf-input.is-valid {
  border-color: var(--c-success);
}

/* ══ PASSWORD WRAPPER ══ */
.tf-input-pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.tf-input-pw-wrap .tf-input {
  padding-right: 44px;
}
.tf-pw-toggle {
  position: absolute;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-tertiary);
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  transition: color var(--dur-fast) var(--ease);
}
.tf-pw-toggle:hover { color: var(--c-text-primary); }

/* ══ TEXTAREA ══ */
.tf-textarea {
  min-height: 88px;
  padding: var(--sp-1) var(--sp-2);
  resize: vertical;
  line-height: 1.5;
}

/* ══ SELECT ══ */
.tf-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%23737373'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* ══ CHECKBOX & RADIO ══ */
.tf-check-group {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  cursor: pointer;
  user-select: none;
}
.tf-check-group input[type="checkbox"],
.tf-check-group input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--c-brand);
  cursor: pointer;
  flex-shrink: 0;
}
.tf-check-group span {
  font-size: var(--text-base);
  color: var(--c-text-secondary);
}

/* ══ FIELD MESSAGE (validation) ══ */
.tf-field-msg {
  font-size: var(--text-xs);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 16px;
}
.tf-field-msg--error   { color: var(--c-danger); }
.tf-field-msg--success { color: var(--c-success); }
.tf-field-msg--hint    { color: var(--c-text-tertiary); }

/* ══ FORM GRID ══ */
.tf-form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
@media (max-width: 480px) { .tf-form-grid-2 { grid-template-columns: 1fr; } }

/* ══ FORM ALERT BANNER ══ */
.tf-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: 10px var(--sp-2);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: var(--sp-2);
  border: 1px solid transparent;
}
.tf-alert--error   { background: var(--c-danger-surface);  color: #991b1b; border-color: #fecaca; }
.tf-alert--success { background: var(--c-success-surface); color: #14532d; border-color: #bbf7d0; }
.tf-alert--warning { background: var(--c-warning-surface); color: #78350f; border-color: #fde68a; }

/* ══ SUBMIT / CTA BUTTON ══ */
.tf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 44px;
  padding: 0 var(--sp-3);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background     var(--dur-fast) var(--ease),
    border-color   var(--dur-fast) var(--ease),
    color          var(--dur-fast) var(--ease),
    box-shadow     var(--dur-fast) var(--ease),
    transform      var(--dur-fast) var(--ease),
    opacity        var(--dur-fast) var(--ease);
  position: relative;
  overflow: hidden;
}
.tf-btn:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}
.tf-btn:disabled { opacity: .38; cursor: not-allowed; transform: none !important; }

/* Variants */
.tf-btn-primary {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}
.tf-btn-primary:hover:not(:disabled) {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
}
.tf-btn-primary:active:not(:disabled) { transform: scale(.985); }

.tf-btn-secondary {
  background: var(--c-surface);
  color: var(--c-text-primary);
  border-color: var(--c-border);
}
.tf-btn-secondary:hover:not(:disabled) {
  background: var(--c-surface-sunken);
  border-color: var(--c-border-strong);
}

.tf-btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
  border-color: transparent;
}
.tf-btn-ghost:hover:not(:disabled) {
  background: var(--c-surface-sunken);
  color: var(--c-text-primary);
}

.tf-btn-danger {
  background: var(--c-danger-surface);
  color: var(--c-danger);
  border-color: transparent;
}
.tf-btn-danger:hover:not(:disabled) { background: #fee2e2; }

.tf-btn-wa {
  background: var(--c-wa);
  color: #fff;
  border-color: var(--c-wa);
}
.tf-btn-wa:hover:not(:disabled) {
  background: var(--c-wa-hover);
  border-color: var(--c-wa-hover);
}

/* Sizes */
.tf-btn-sm  { min-height: 32px; padding: 0 var(--sp-2); font-size: var(--text-sm); }
.tf-btn-lg  { min-height: 52px; padding: 0 var(--sp-4); font-size: var(--text-md); }
.tf-btn-full { width: 100%; }

/* Loading spinner inside button */
.tf-btn-spinner {
  display: none;
  align-items: center;
  gap: 6px;
}
.tf-btn-spinner svg { animation: tf-spin 1s linear infinite; }
@keyframes tf-spin { to { transform: rotate(360deg); } }
