/**
 * WP Total Tracker - Premium Form Styles
 * Implements Floating Labels (Material Design) e animações.
 */
.wptt-form {
  --wptt-primary: #0073aa;
  --wptt-text: #333333; /* Fallback, overridden by inline style */
  --wptt-btn-text: #ffffff;
  --wptt-label: #757575;
  --wptt-label-bg: transparent; /* Fundo das labels flutuantes */
  --wptt-border: #cccccc;
  --wptt-bg: #ffffff;
  --wptt-error: #d32f2f;
  --wptt-success: #2e7d32;
  --wptt-font-size: 16px;
  --wptt-font-weight: 400;
  --wptt-btn-font-size: 16px;
  --wptt-btn-font-weight: 600;
  --wptt-border-width: 1px;
  --wptt-border-radius: 4px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  max-width: 100%;
  margin: 20px 0;
  box-sizing: border-box;
}

/* Layout do Formulário (Grid) */
.wptt-form.wptt-layout-cols-2,
.wptt-form.wptt-layout-cols-3,
.wptt-form.wptt-layout-cols-4 {
  display: grid;
  gap: 0 20px;
}

.wptt-form.wptt-layout-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.wptt-form.wptt-layout-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.wptt-form.wptt-layout-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Posicionamento do Botão e Mensagens no Grid */
.wptt-form.wptt-btn-full button[type="submit"],
.wptt-form-message {
  grid-column: 1 / -1;
  width: 100% !important;
}

.wptt-form.wptt-btn-inline button[type="submit"] {
  align-self: end;
  margin-bottom: 24px;
  width: 100%;
}

@media (min-width: 600px) {
  .wptt-form.wptt-btn-inline button[type="submit"] {
    width: auto;
    min-width: 200px;
  }
}

.wptt-form *,
.wptt-form *::before,
.wptt-form *::after {
  box-sizing: inherit;
}

.wptt-form-group {
  position: relative;
  margin-bottom: 24px;
}

/* INPUTS & TEXTAREAS */
.wptt-form input[type="text"],
.wptt-form input[type="email"],
.wptt-form input[type="tel"],
.wptt-form input[type="url"],
.wptt-form input[type="number"],
.wptt-form textarea {
  width: 100%;
  padding: 12px 12px;
  font-size: var(--wptt-font-size);
  font-weight: var(--wptt-font-weight);
  color: var(--wptt-text) !important;
  background-color: transparent;
  border: var(--wptt-border-width) solid var(--wptt-border);
  border-radius: var(--wptt-border-radius);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.wptt-form textarea {
  min-height: 100px;
  resize: vertical;
}

/* Foco */
.wptt-form input:focus,
.wptt-form textarea:focus {
  border-color: var(--wptt-primary);
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

/* Erro */
.wptt-form input.has-error,
.wptt-form textarea.has-error {
  border-color: var(--wptt-error);
}

/* FLOATING LABEL LOGIC */
.wptt-form label {
  position: absolute;
  left: 10px;
  top: 13px;
  padding: 0 4px;
  color: var(--wptt-text) !important;
  font-size: var(--wptt-font-size);
  font-weight: var(--wptt-font-weight);
  background-color: transparent;
  pointer-events: none;
  transition: 0.2s ease all;
  z-index: 1;
}

/* Quando focado ou quando tem valor (detectado pelo placeholder-shown hack) */
.wptt-form input:focus ~ label,
.wptt-form input:not(:placeholder-shown) ~ label,
.wptt-form textarea:focus ~ label,
.wptt-form textarea:not(:placeholder-shown) ~ label {
  top: -9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--wptt-primary);
  background-color: var(--wptt-label-bg);
}

.wptt-form input:focus ~ label,
.wptt-form textarea:focus ~ label {
  color: var(--wptt-primary);
}

.wptt-form input.has-error ~ label {
  color: var(--wptt-error);
}

/* FILE INPUT (Não suporta floating label padrão, tratamento diferente) */
.wptt-form input[type="file"] {
  padding: 10px 0;
  border: none;
}
.wptt-form-group.file-group label {
  position: static;
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 600;
  color: var(--wptt-text);
  pointer-events: auto;
}

/* BUTTON */
.wptt-form button[type="submit"] {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 24px;
  background-color: var(--wptt-primary);
  color: var(--wptt-btn-text);
  font-size: var(--wptt-btn-font-size);
  font-weight: var(--wptt-btn-font-weight);
  border: none;
  border-radius: var(--wptt-border-radius);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  width: 100%;
}

.wptt-form button[type="submit"]:hover {
  background-color: #005177;
}

.wptt-form button[type="submit"]:active {
  transform: translateY(1px);
}

.wptt-form button[type="submit"]:disabled {
  background-color: #a0a0a0;
  cursor: not-allowed;
  opacity: 0.7;
}

/* MESSAGES */
.wptt-form-message {
  margin-top: 15px;
  padding: 12px;
  border-radius: 4px;
  font-size: 14px;
  display: none;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.wptt-form-message.success {
  background-color: #e8f5e9;
  color: var(--wptt-success);
  border: 1px solid #c8e6c9;
}

.wptt-form-message.error {
  background-color: #ffebee;
  color: var(--wptt-error);
  border: 1px solid #ffcdd2;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
  .wptt-form.wptt-layout-cols-2,
  .wptt-form.wptt-layout-cols-3,
  .wptt-form.wptt-layout-cols-4 {
    grid-template-columns: 1fr;
  }
}
