/**
 * Expresso Cadastro - Forms Unified CSS
 * 
 * ARQUIVO CONSOLIDADO - Todos os estilos de formulário em um só lugar
 * 
 * Consolida os seguintes arquivos:
 * - form-cadastro-desktop-responsivo.css (Base principal)
 * - form-cadastro-consolidated.css (Versão consolidada)
 * - form-compact-inputs.css (Inputs compactos)
 * - form-ultra-compact.css (Compactação extrema)
 * 
 * @package Expresso_Cadastro
 * @since 2.2.0
 */

/* ===== DESIGN TOKENS PARA FORMULÁRIOS ===== */

:root {
  /* Form Colors */
  --ec-form-bg: #f8fafc;
  --ec-form-primary: #f08000;
  --ec-form-primary-hover: #e67300;
  --ec-form-success: #10b981;
  --ec-form-error: #ef4444;
  --ec-form-warning: #f59e0b;
  
  /* Form Text Colors */
  --ec-form-text: #334155;
  --ec-form-text-light: #64748b;
  --ec-form-text-muted: #94a3b8;
  
  /* Form Borders */
  --ec-form-border: #d1d5db;
  --ec-form-border-focus: #f08000;
  --ec-form-border-error: #ef4444;
  
  /* Form Spacing */
  --ec-form-space-xs: 4px;
  --ec-form-space-sm: 8px;
  --ec-form-space-md: 16px;
  --ec-form-space-lg: 24px;
  --ec-form-space-xl: 32px;
  
  /* Form Components */
  --ec-form-input-height: 38px;
  --ec-form-input-height-compact: 34px;
  --ec-form-input-height-ultra: 30px;
  --ec-form-border-radius: 6px;
  
  /* Form Typography */
  --ec-form-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --ec-form-font-size: 14px;
  --ec-form-font-size-sm: 12px;
  --ec-form-line-height: 1.5;
}

/* ===== RESET E BASE - SCOPED TO PLUGIN ONLY ===== */

.ec-cadastro-form-container *,
.ec-portal-page *,
.ec-status-page *,
.ec-form-container *,
.ec-modal-container *,
[class*="ec-"] * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body.ec-cadastro-page,
.ec-modern-form-container {
  background: var(--ec-form-bg);
  font-family: var(--ec-form-font-family);
  line-height: var(--ec-form-line-height);
  color: var(--ec-form-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1;
}

/* ===== CONTAINER PRINCIPAL ===== */

.ec-modern-form-container {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 16px;
  position: relative;
  background: white;
  border-radius: var(--ec-form-border-radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* ===== HEADER DO FORMULÁRIO ===== */

.ec-form-header {
  background: linear-gradient(135deg, var(--ec-form-primary) 0%, var(--ec-form-primary-hover) 100%);
  padding: var(--ec-form-space-xl);
  text-align: center;
  color: white;
  position: relative;
}

.ec-form-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="0.5" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  pointer-events: none;
}

.ec-form-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: var(--ec-form-space-sm);
  position: relative;
  z-index: 1;
}

.ec-form-subtitle {
  font-size: var(--ec-form-font-size);
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

/* ===== BODY DO FORMULÁRIO ===== */

.ec-form-body {
  padding: var(--ec-form-space-xl);
}

/* ===== GRUPOS DE CAMPOS ===== */

.ec-form-group,
.ec-form-field,
.form-group,
.field-group {
  margin-bottom: var(--ec-form-space-md);
  position: relative;
}

.ec-form-group:last-child,
.ec-form-field:last-child {
  margin-bottom: 0;
}

/* ===== LABELS ===== */

.ec-form-label,
label {
  display: block;
  font-weight: 600;
  color: var(--ec-form-text);
  margin-bottom: var(--ec-form-space-sm);
  font-size: var(--ec-form-font-size);
  line-height: 1.4;
}

.ec-form-label.required::after,
label.required::after {
  content: " *";
  color: var(--ec-form-error);
  font-weight: 700;
}

/* ===== INPUTS BASE ===== */

.ec-form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
textarea,
select {
  width: 100%;
  height: var(--ec-form-input-height);
  padding: var(--ec-form-space-sm) 12px;
  font-size: var(--ec-form-font-size);
  font-family: var(--ec-form-font-family);
  line-height: 1.4;
  color: var(--ec-form-text);
  background: white;
  border: 1px solid var(--ec-form-border);
  border-radius: var(--ec-form-border-radius);
  transition: all 0.2s ease;
  outline: none;
}

textarea.ec-form-control,
textarea {
  height: auto;
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

/* ===== ESTADOS DOS INPUTS ===== */

.ec-form-control:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--ec-form-border-focus);
  box-shadow: 0 0 0 3px rgba(240, 128, 0, 0.1);
  background: #fffbf7;
}

.ec-form-control:hover:not(:focus):not(.error),
input:hover:not(:focus):not(.error),
textarea:hover:not(:focus):not(.error),
select:hover:not(:focus):not(.error) {
  border-color: #9ca3af;
}

.ec-form-control.error,
input.error,
textarea.error,
select.error {
  border-color: var(--ec-form-border-error);
  background: #fef2f2;
}

.ec-form-control:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  background: #f9fafb;
  color: var(--ec-form-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* ===== PLACEHOLDERS ===== */

.ec-form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--ec-form-text-muted);
  opacity: 1;
}

/* ===== HELP TEXT E DICAS ===== */

.ec-field-help,
.ec-field-tip,
.field-help,
.help-text,
.form-help {
  font-size: var(--ec-form-font-size-sm);
  color: var(--ec-form-text-light);
  margin-top: var(--ec-form-space-xs);
  line-height: 1.4;
  display: block;
}

.ec-field-error,
.error-message {
  font-size: var(--ec-form-font-size-sm);
  color: var(--ec-form-error);
  margin-top: var(--ec-form-space-xs);
  display: flex;
  align-items: center;
  gap: var(--ec-form-space-xs);
}

.ec-field-error::before {
  content: "⚠";
  font-size: 12px;
}

/* ===== BOTÕES ===== */

.ec-btn,
.btn,
button[type="submit"],
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ec-form-space-sm);
  padding: 12px var(--ec-form-space-lg);
  font-size: var(--ec-form-font-size);
  font-weight: 600;
  font-family: var(--ec-form-font-family);
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--ec-form-border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  outline: none;
  position: relative;
  overflow: hidden;
}

.ec-btn-primary,
.btn-primary,
button[type="submit"],
input[type="submit"] {
  background: linear-gradient(135deg, var(--ec-form-primary) 0%, var(--ec-form-primary-hover) 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(240, 128, 0, 0.2);
}

.ec-btn-primary:hover,
.btn-primary:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(240, 128, 0, 0.3);
}

.ec-btn-primary:active,
.btn-primary:active,
button[type="submit"]:active,
input[type="submit"]:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(240, 128, 0, 0.2);
}

.ec-btn-secondary,
.btn-secondary {
  background: white;
  color: var(--ec-form-text);
  border: 1px solid var(--ec-form-border);
}

.ec-btn-secondary:hover,
.btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* Fix para botão cancelar edição - evitar cor roxa */
.ec-btn-secondary {
  background: #ffffff !important;
  color: #374151 !important;
  border: 1px solid #d1d5db !important;
}

.ec-btn-secondary:hover {
  background: #f9fafb !important;
  color: #374151 !important;
  border-color: #9ca3af !important;
}

/* ===== PROGRESS INDICATOR ===== */

.ec-form-progress {
  display: flex;
  align-items: center;
  gap: var(--ec-form-space-sm);
  margin-bottom: var(--ec-form-space-xl);
  padding: 0 var(--ec-form-space-md);
}

.ec-progress-step {
  flex: 1;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.ec-progress-step.active {
  background: linear-gradient(90deg, var(--ec-form-primary) 0%, var(--ec-form-primary-hover) 100%);
}

.ec-progress-step.completed {
  background: var(--ec-form-success);
}

/* ===== SEÇÕES COLAPSÁVEIS ===== */

.ec-form-section {
  border: 1px solid #e5e7eb;
  border-radius: var(--ec-form-border-radius);
  margin-bottom: var(--ec-form-space-md);
  overflow: hidden;
}

.ec-section-header {
  background: #f9fafb;
  padding: var(--ec-form-space-md) var(--ec-form-space-lg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s ease;
}

.ec-section-header:hover {
  background: #f3f4f6;
}

.ec-section-header.active {
  background: #fef3e2;
  border-bottom-color: var(--ec-form-primary);
}

.ec-section-title {
  font-weight: 600;
  color: var(--ec-form-text);
  margin: 0;
  font-size: var(--ec-form-font-size);
}

.ec-section-toggle {
  background: none;
  border: none;
  color: var(--ec-form-text-light);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.3s ease, color 0.2s ease;
  padding: var(--ec-form-space-xs);
  border-radius: 4px;
}

.ec-section-toggle:hover {
  color: var(--ec-form-primary);
  background: rgba(240, 128, 0, 0.1);
}

.ec-section-header.active .ec-section-toggle {
  transform: rotate(180deg);
  color: var(--ec-form-primary);
}

.ec-section-content {
  padding: var(--ec-form-space-lg);
  display: none;
  animation: slideDown 0.3s ease;
}

.ec-section-content.active {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== UPLOAD DE DOCUMENTOS ===== */

.ec-document-field,
.ec-file-input-wrapper,
.ec-documents-container,
.document-upload,
.file-upload {
  margin-bottom: var(--ec-form-space-sm);
  position: relative;
}

.ec-file-input-wrapper {
  border: 2px dashed var(--ec-form-border);
  border-radius: var(--ec-form-border-radius);
  padding: var(--ec-form-space-lg);
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  background: #fafbfc;
}

.ec-file-input-wrapper:hover {
  border-color: var(--ec-form-primary);
  background: #fef7f0;
}

.ec-file-input-wrapper.dragover {
  border-color: var(--ec-form-primary);
  background: #fef7f0;
  transform: scale(1.02);
}

.ec-file-input {
  display: none;
}

.ec-file-label {
  display: block;
  font-weight: 600;
  color: var(--ec-form-text);
  margin-bottom: var(--ec-form-space-xs);
}

.ec-file-help {
  font-size: var(--ec-form-font-size-sm);
  color: var(--ec-form-text-light);
}

.ec-file-preview {
  margin-top: var(--ec-form-space-md);
  padding: var(--ec-form-space-md);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--ec-form-border-radius);
}

.ec-file-name {
  font-weight: 600;
  color: var(--ec-form-success);
  margin-bottom: var(--ec-form-space-xs);
}

.ec-file-size {
  font-size: var(--ec-form-font-size-sm);
  color: var(--ec-form-text-light);
}

/* ===== GRID RESPONSIVO ===== */

.ec-form-grid {
  display: grid;
  gap: var(--ec-form-space-md);
  margin-bottom: var(--ec-form-space-md);
}

.ec-form-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.ec-form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.ec-form-grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ===== VARIANTES COMPACTAS ===== */

/* Inputs compactos - aplicar quando necessário */
.ec-form-compact .ec-form-control,
.ec-form-compact input,
.ec-form-compact textarea,
.ec-form-compact select {
  height: var(--ec-form-input-height-compact);
  padding: 6px 10px;
  font-size: 13px;
}

.ec-form-compact .ec-form-group,
.ec-form-compact .ec-form-field {
  margin-bottom: 12px;
}

.ec-form-compact .ec-field-help,
.ec-form-compact .ec-field-tip {
  font-size: 11px;
  margin-top: 4px;
}

/* Ultra compacto - máxima compactação */
.ec-form-ultra-compact .ec-form-control,
.ec-form-ultra-compact input,
.ec-form-ultra-compact textarea,
.ec-form-ultra-compact select {
  height: var(--ec-form-input-height-ultra);
  padding: 4px 8px;
  font-size: 12px;
}

.ec-form-ultra-compact .ec-form-group,
.ec-form-ultra-compact .ec-form-field,
.ec-form-ultra-compact .ec-document-field,
.ec-form-ultra-compact .ec-file-input-wrapper,
.ec-form-ultra-compact .ec-documents-container {
  margin-bottom: 2px !important;
  margin-top: 0px !important;
  padding-bottom: 0px !important;
  padding-top: 2px !important;
}

.ec-form-ultra-compact .ec-field-help,
.ec-form-ultra-compact .ec-field-tip,
.ec-form-ultra-compact .help-text {
  font-size: 10px !important;
  line-height: 1.2 !important;
  margin-top: 1px !important;
  margin-bottom: 1px !important;
}

/* ===== SEÇÃO DE CONFIRMAÇÕES FINAIS ===== */

#confirmations-section {
  margin-top: var(--ec-form-space-xl);
  padding: var(--ec-form-space-lg);
  border: 1px solid var(--ec-form-border-light);
  border-radius: var(--ec-form-radius-lg);
  background: var(--ec-form-bg-light);
}

.ec-confirmations-container {
  margin-top: var(--ec-form-space-md);
}

.ec-confirmations-container .ec-form-group {
  margin-bottom: var(--ec-form-space-md);
  padding: var(--ec-form-space-sm);
  background: white;
  border-radius: var(--ec-form-radius-md);
  border: 1px solid var(--ec-form-border-light);
  transition: var(--ec-form-transition);
}

.ec-confirmations-container .ec-form-group:hover {
  border-color: var(--ec-form-border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Melhorar layout dos checkboxes */
.ec-checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: var(--ec-form-space-sm);
}

/* Sobrescrever sistema custom do frontend.css para confirmações */
.ec-confirmations-container .ec-checkbox-label {
  display: flex !important;
  align-items: flex-start !important;
  gap: 12px !important;
  padding: var(--ec-form-space-sm) !important;
  min-height: auto !important;
  font-size: var(--ec-form-text-sm) !important;
  line-height: 1.5 !important;
}

.ec-confirmations-container .ec-checkbox-label input[type="checkbox"] {
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
  margin-top: 2px !important;
  cursor: pointer !important;
  accent-color: var(--ec-form-primary-color) !important;
}

.ec-checkbox-wrapper .ec-checkbox-label {
  flex: 1;
  margin: 0;
  color: var(--ec-form-text-color);
  cursor: pointer;
}

/* Links em checkboxes */
.ec-checkbox-label .ec-modal-link {
  color: var(--ec-form-primary-color);
  text-decoration: underline;
  font-weight: 600;
  transition: var(--ec-form-transition);
}

.ec-checkbox-label .ec-modal-link:hover {
  color: var(--ec-form-primary-hover);
  text-decoration: none;
}

/* Asterisco obrigatório */
.ec-checkbox-label span[style*="color: #ef4444"] {
  color: var(--ec-form-error-color) !important;
  font-weight: bold;
}

/* Campo de autorização de contato - layout especial */
.ec-form-group:has(.ec-field-description) {
  background: #f8fafc;
  border-left: 4px solid var(--ec-form-info-color);
}

.ec-field-description {
  margin-top: var(--ec-form-space-sm);
  padding: var(--ec-form-space-sm);
  background: rgba(59, 130, 246, 0.05);
  border-radius: var(--ec-form-radius-sm);
  border: 1px solid rgba(59, 130, 246, 0.1);
}

.ec-description-icon {
  font-size: 16px;
  margin-right: 8px;
  color: var(--ec-form-info-color);
}

.ec-description-text {
  font-size: var(--ec-form-text-xs);
  line-height: 1.4;
  color: var(--ec-form-text-muted);
}

/* Responsividade para confirmações */
@media (max-width: 768px) {
  #confirmations-section {
    padding: var(--ec-form-space-md);
    margin-top: var(--ec-form-space-lg);
  }
  
  .ec-confirmations-container .ec-form-group {
    padding: var(--ec-form-space-xs);
  }
  
  .ec-checkbox-wrapper {
    gap: 10px;
    padding: var(--ec-form-space-xs);
  }
  
  .ec-checkbox-label {
    font-size: var(--ec-form-text-xs);
  }
  
  .ec-description-text {
    font-size: 11px;
  }
}

.ec-form-ultra-compact .ec-form-label,
.ec-form-ultra-compact label {
  margin-bottom: 2px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
}

/* ===== RESPONSIVIDADE ===== */

/* Tablet */
@media (max-width: 1024px) {
  .ec-modern-form-container {
    margin: 16px auto;
    padding: 0 12px;
  }
  
  .ec-form-header,
  .ec-form-body {
    padding: var(--ec-form-space-lg);
  }
  
  .ec-form-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .ec-modern-form-container {
    margin: 8px auto;
    padding: 0 8px;
    border-radius: 0;
  }
  
  .ec-form-header {
    padding: var(--ec-form-space-lg) var(--ec-form-space-md);
  }
  
  .ec-form-title {
    font-size: 24px;
  }
  
  .ec-form-body {
    padding: var(--ec-form-space-md);
  }
  
  .ec-form-grid-2,
  .ec-form-grid-3 {
    grid-template-columns: 1fr;
  }
  
  .ec-form-progress {
    padding: 0;
  }
  
  .ec-section-header {
    padding: var(--ec-form-space-md);
  }
  
  .ec-section-content {
    padding: var(--ec-form-space-md);
  }
  
  .ec-file-input-wrapper {
    padding: var(--ec-form-space-md);
  }
}

/* Mobile pequeno */
@media (max-width: 480px) {
  .ec-form-header,
  .ec-form-body {
    padding: var(--ec-form-space-md) var(--ec-form-space-sm);
  }
  
  .ec-form-title {
    font-size: 20px;
  }
  
  .ec-btn,
  .btn {
    width: 100%;
    margin-bottom: var(--ec-form-space-sm);
  }
  
  .ec-form-grid {
    gap: var(--ec-form-space-sm);
  }
}

/* ===== HIGH CONTRAST MODE ===== */

@media (prefers-contrast: high) {
  .ec-form-control,
  input,
  textarea,
  select {
    border: 2px solid currentColor;
  }
  
  .ec-form-control:focus,
  input:focus,
  textarea:focus,
  select:focus {
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }
}

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  .ec-cadastro-form-container *,
  .ec-portal-page *,
  .ec-status-page *,
  .ec-form-container *,
  .ec-modal-container *,
  [class*="ec-"] *,
  .ec-cadastro-form-container *::before,
  .ec-portal-page *::before,
  .ec-status-page *::before,
  .ec-form-container *::before,
  .ec-modal-container *::before,
  [class*="ec-"] *::before,
  .ec-cadastro-form-container *::after,
  .ec-portal-page *::after,
  .ec-status-page *::after,
  .ec-form-container *::after,
  .ec-modal-container *::after,
  [class*="ec-"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .ec-section-toggle {
    transition: none;
  }
  
  .ec-section-content {
    animation: none;
  }
}

/* ===== PRINT STYLES ===== */

@media print {
  .ec-modern-form-container {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .ec-form-header {
    background: none !important;
    color: black !important;
  }
  
  .ec-btn,
  .btn {
    display: none;
  }
  
  .ec-section-content {
    display: block !important;
  }
  
  .ec-section-toggle {
    display: none;
  }
}