/* ===================================
   FORM ENHANCEMENTS - Stili
=================================== */

/* Field validation states */
.field-error {
  border-color: #f44336 !important;
  background: rgba(244, 67, 54, 0.05);
}

.field-success {
  border-color: #4caf50 !important;
}

/* Field feedback messages */
.field-feedback {
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field-feedback-error {
  color: #f44336;
}

.field-feedback-success {
  color: #4caf50;
}

/* Character count */
.character-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: right;
}

/* Form loading state */
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Required field indicator */
label.required::after {
  content: ' *';
  color: #f44336;
}

/* Form section divider */
.form-section {
  margin: 24px 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Help text */
.help-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

/* Input groups */
.input-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-group input {
  flex: 1;
}

.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-actions);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
}

.input-group-addon.prefix {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.input-group input.with-prefix {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group-addon.suffix {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: none;
}

.input-group input.with-suffix {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Checkbox e Radio personalizzati */
.custom-checkbox,
.custom-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
}

.custom-checkbox input[type="checkbox"],
.custom-radio input[type="radio"] {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--azul);
}

.custom-checkbox label,
.custom-radio label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
}

/* Switch toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background: var(--azul);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(24px);
}

.switch input:focus + .switch-slider {
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

/* File upload custom */
.file-upload-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.file-upload-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--azul);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.file-upload-button:hover {
  background: var(--blue-hover);
}

.file-upload-wrapper input[type="file"] {
  position: absolute;
  left: -9999px;
}

.file-upload-name {
  display: inline-block;
  margin-left: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Date picker enhancements */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: var(--date-picker-filter, none);
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Form grid migliorato */
.form-grid-2cols {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-grid-3cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-grid-full {
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  .form-grid-2cols,
  .form-grid-3cols {
    grid-template-columns: 1fr;
  }
}

/* Inline form */
.form-inline {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.form-inline .form-field {
  flex: 1;
  min-width: 200px;
}

.form-inline .form-field label {
  display: block;
  margin-bottom: 4px;
}

.form-inline button {
  flex-shrink: 0;
}

/* Form steps (wizard) */
.form-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 32px;
  position: relative;
}

.form-steps::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.form-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  flex: 1;
}

.form-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.form-step.active .form-step-circle {
  background: var(--azul);
  border-color: var(--azul);
  color: white;
}

.form-step.completed .form-step-circle {
  background: #4caf50;
  border-color: #4caf50;
  color: white;
}

.form-step-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.form-step.active .form-step-label {
  color: var(--text-primary);
  font-weight: 600;
}

/* Floating labels */
.floating-label {
  position: relative;
  margin-top: 16px;
}

.floating-label input,
.floating-label textarea {
  width: 100%;
  padding: 12px 12px 8px;
}

.floating-label label {
  position: absolute;
  left: 12px;
  top: 12px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  pointer-events: none;
  font-weight: normal;
}

.floating-label input:focus + label,
.floating-label input:not(:placeholder-shown) + label,
.floating-label textarea:focus + label,
.floating-label textarea:not(:placeholder-shown) + label {
  top: 4px;
  font-size: 11px;
  color: var(--azul);
}

.floating-label input::placeholder,
.floating-label textarea::placeholder {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.floating-label input:focus::placeholder,
.floating-label textarea:focus::placeholder {
  opacity: 0.5;
}
