/**
 * Forms Component - Sistema de formularios siguiendo BEM
 * Mantiene y extiende los estilos de formularios existentes
 */

.form {
  display: grid;
  gap: var(--space-lg);
}

.form--inline {
  display: flex;
  gap: var(--space-md);
  align-items: end;
  flex-wrap: wrap;
}

/* Campo de formulario */
.field {
  display: grid;
  gap: var(--space-xs);
}

.field--horizontal {
  grid-template-columns: 120px 1fr;
  gap: var(--space-md);
  align-items: center;
}

.field__label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--white);
}

.field__label--required::after {
  content: " *";
  color: #dc2626;
}

.field__help {
  font-size: var(--font-size-xs);
  color: var(--muted);
  margin-top: var(--space-xs);
}

.field__error {
  font-size: var(--font-size-xs);
  color: #dc2626;
  margin-top: var(--space-xs);
}

/* Inputs */
.input {
  background: #0f0f0f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: var(--font-size-base);
  font-family: inherit;
  transition: all 0.2s ease;
  width: 100%;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  outline: 2px solid var(--ckm-green);
  border-color: transparent;
  background: #1a1a1a;
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #0a0a0a;
}

.input--error {
  border-color: #dc2626;
}

.input--error:focus {
  outline-color: #dc2626;
}

.input--success {
  border-color: var(--ckm-green);
}

.input--sm {
  padding: 8px 10px;
  font-size: var(--font-size-sm);
}

.input--lg {
  padding: 16px;
  font-size: var(--font-size-lg);
}

/* Textarea */
.textarea {
  resize: vertical;
  min-height: 80px;
}

.textarea--fixed {
  resize: none;
}

/* Select */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23c9c9c9' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

.select:focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2300c853' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Checkbox y Radio */
.checkbox,
.radio {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.checkbox__input,
.radio__input {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox__input {
  border-radius: 4px;
}

.radio__input {
  border-radius: 50%;
}

.checkbox__input:checked,
.radio__input:checked {
  background: var(--ckm-green);
  border-color: var(--ckm-green);
}

.checkbox__input:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #00240f;
  font-size: 12px;
  font-weight: bold;
}

.radio__input:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #00240f;
  border-radius: 50%;
}

.checkbox__input:focus,
.radio__input:focus {
  outline: 2px solid var(--ckm-green);
  outline-offset: 2px;
}

/* Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.switch__input {
  appearance: none;
  width: 48px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.switch__input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--white);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.switch__input:checked {
  background: var(--ckm-green);
}

.switch__input:checked::after {
  transform: translateX(24px);
  background: #00240f;
}

.switch__input:focus {
  outline: 2px solid var(--ckm-green);
  outline-offset: 2px;
}

/* Input group */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input {
  border-radius: 0;
  border-right: none;
}

.input-group .input:first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.input-group .input:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.input-group__addon {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--ckm-gray);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: none;
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.input-group__addon:first-child {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: none;
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.input-group__addon:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

/* Consent checkbox (del formulario existente) */
.consent {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.consent input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Grid de formulario */
.grid-2 {
  display: grid;
  gap: var(--space-md);
}

@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  
  .field--horizontal {
    grid-template-columns: 140px 1fr;
  }
}

/* Estados de validación */
.field--loading .input {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3e%3ccircle cx='12' cy='12' r='10' stroke='%23c9c9c9' stroke-width='2'/%3e%3cpath fill='%23c9c9c9' d='M4 12a8 8 0 0 1 8-8V2.5a1.5 1.5 0 0 0-3 0V4a6 6 0 1 0 6 6h1.5a1.5 1.5 0 0 0 0-3H12a8 8 0 0 1 8 8z'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
  animation: input-spin 1s linear infinite;
}

@keyframes input-spin {
  to {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' transform='rotate(360deg)'%3e%3ccircle cx='12' cy='12' r='10' stroke='%23c9c9c9' stroke-width='2'/%3e%3cpath fill='%23c9c9c9' d='M4 12a8 8 0 0 1 8-8V2.5a1.5 1.5 0 0 0-3 0V4a6 6 0 1 0 6 6h1.5a1.5 1.5 0 0 0 0-3H12a8 8 0 0 1 8 8z'/%3e%3c/svg%3e");
  }
}

/* Estilos específicos para el login */
.login-container {
  background: var(--ckm-black);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  margin: 4rem auto;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  color: var(--white);
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.login-header p {
  color: var(--muted);
  margin: 0.5rem 0 0 0;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--white);
  font-size: 0.9rem;
}
