/* ═══════════════════════════════════════════════
   FORMila — Frontend CSS
   Variables inyectadas por Assets::css_vars()
   ═══════════════════════════════════════════════ */

/* ── Reset base formularios ───────────────────── */
.fm-wrap {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
  overflow: hidden;
  font-family: var(--fm-font-body, 'Open Sans', sans-serif);
}

/* ── Headers ──────────────────────────────────── */
.fm-header {
  padding: 32px 40px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.fm-header::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 280px; height: 280px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}
.fm-header h1 {
  font-family: var(--fm-font-titles, 'Poppins', sans-serif);
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  position: relative;
  z-index: 1;
}
.fm-header p {
  font-size: 14px;
  opacity: .85;
  margin: 0;
  position: relative;
  z-index: 1;
}
.fm-header-primary  { background: linear-gradient(135deg, var(--fm-primary, #1048cb), #1a5fdb); }
.fm-header-secondary{ background: linear-gradient(135deg, var(--fm-secondary, #10cbac), #0aaa8e); }
.fm-header-dark     { background: linear-gradient(135deg, var(--fm-tertiary, #07202c), #0d3040); }

/* ── Barra de usuario logueado ────────────────── */
.fm-user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  margin: 20px 36px 0;
}
.fm-user-info { display: flex; align-items: center; gap: 12px; }
.fm-user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fm-secondary,#10cbac), #0aaa8e);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.fm-user-name  { font-weight: 600; color: #065f46; font-size: 14px; }
.fm-user-sub   { font-size: 12px; color: #047857; display: flex; align-items: center; gap: 4px; }
.fm-user-sub::before { content: ''; width: 7px; height: 7px; background: #10b981; border-radius: 50%; }
.fm-btn-logout {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid #a7f3d0;
  border-radius: 20px;
  color: #047857;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s;
}
.fm-btn-logout:hover { background: #a7f3d0; }

/* ── Mensajes de error / info ────────────────── */
.fm-msg-error {
  margin: 20px 36px 0;
  padding: 14px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border: 1px solid #fca5a5;
  color: #991b1b;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.fm-login-msg {
  text-align: center;
  padding: 40px;
  font-family: var(--fm-font-body, 'Open Sans', sans-serif);
}
.fm-login-msg a { color: var(--fm-primary, #1048cb); font-weight: 600; }

/* ── Cuerpo del formulario ────────────────────── */
.fm-form-body { padding: 28px 36px 0; }

/* ── Secciones ────────────────────────────────── */
.fm-section { margin-bottom: 28px; }
/* La línea gris va al final del bloque head (título + subtítulo debajo del título, línea al final) */
.fm-section-head {
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}
.fm-section-title {
  font-family: var(--fm-font-titles, 'Poppins', sans-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--fm-tertiary, #07202c);
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;   /* la línea la pone el contenedor, no el h2 */
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Subtítulo: va entre el título y la línea gris */
.fm-section-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin: 6px 0 0;
  line-height: 1.5;
  padding: 0;
}
.fm-sec-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.fm-sec-icon.blue   { background: #dbeafe; }
.fm-sec-icon.green  { background: #d1fae5; }
.fm-sec-icon.purple { background: #ede9fe; }
.fm-sec-icon.orange { background: #ffedd5; }

/* ── Grid de campos ───────────────────────────── */
.fm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.fm-field-wrap { position: relative; }
.fm-field-wrap.full { grid-column: 1 / -1; }

/* ── Campos ──────────────────────────────────── */
.fm-field-wrap label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 7px;
}
.fm-req { color: #ef4444; margin-left: 2px; }
.fm-field-wrap input[type="text"],
.fm-field-wrap input[type="email"],
.fm-field-wrap input[type="tel"],
.fm-field-wrap input[type="number"],
.fm-field-wrap input[type="password"],
.fm-field-wrap input[type="date"],
.fm-field-wrap textarea,
.fm-field-wrap select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--fm-font-body, 'Open Sans', sans-serif);
  color: #1f2937;
  background: #f8fafc;
  transition: all .25s;
  outline: none;
  box-sizing: border-box;
}
.fm-field-wrap input:focus,
.fm-field-wrap textarea:focus,
.fm-field-wrap select:focus {
  border-color: var(--fm-primary, #1048cb);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(16,72,203,.08);
}
.fm-field-wrap input::placeholder,
.fm-field-wrap textarea::placeholder { color: #9ca3af; }
.fm-field-wrap textarea { resize: vertical; min-height: 100px; }
.fm-field-wrap input[readonly] {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}
.fm-field-wrap input[readonly]:focus {
  border-color: #e2e8f0;
  background: #f1f5f9;
  box-shadow: none;
}
.fm-field-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; font-style: italic; }
.fm-field-err-msg {
  display: none;
  font-size: 11px;
  color: #ef4444;
  margin-top: 4px;
  font-weight: 500;
}
.fm-field-wrap.has-error input,
.fm-field-wrap.has-error select,
.fm-field-wrap.has-error textarea {
  border-color: #ef4444;
  background: #fef2f2;
}
.fm-field-wrap.has-error .fm-field-err-msg { display: block; }

/* ── Radio groups ─────────────────────────────── */
.fm-radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.fm-radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all .2s;
  background: #f8fafc;
  position: relative;
}
.fm-radio-item:hover { border-color: var(--fm-secondary, #10cbac); }
.fm-radio-item input[type="radio"] { position: absolute; opacity: 0; }
.fm-radio-item:has(input:checked) {
  border-color: var(--fm-primary, #1048cb);
  background: #eff6ff;
}
.fm-radio-circle {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: #fff;
  transition: all .2s;
  flex-shrink: 0;
  position: relative;
}
.fm-radio-item input:checked + .fm-radio-circle {
  background: var(--fm-primary, #1048cb);
  border-color: var(--fm-primary, #1048cb);
}
.fm-radio-circle::after {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 50%; left: 50%;
  margin: -3.5px 0 0 -3.5px;
  opacity: 0;
  transition: opacity .2s;
}
.fm-radio-item input:checked + .fm-radio-circle::after { opacity: 1; }
.fm-radio-label { font-size: 14px; color: #374151; font-weight: 500; }

/* ── Upload areas ─────────────────────────────── */
.fm-upload {
  border: 2px dashed #d1d5db;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .3s;
  background: #f8fafc;
  position: relative;
  overflow: hidden;
}
.fm-upload:hover   { border-color: var(--fm-primary, #1048cb); background: #eff6ff; }
.fm-upload.dragover { border-color: var(--fm-primary, #1048cb); background: #dbeafe; transform: scale(1.01); }
.fm-upload input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.fm-upload-icon {
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.fm-upload-icon.blue   { background: linear-gradient(135deg,#dbeafe,#bfdbfe); color: #2563eb; }
.fm-upload-icon.green  { background: linear-gradient(135deg,#d1fae5,#a7f3d0); color: #059669; }
.fm-upload-icon.orange { background: linear-gradient(135deg,#ffedd5,#fed7aa); color: #ea580c; }
.fm-upload h4 { font-size: 14px; color: #374151; margin: 0 0 4px; font-weight: 600; }
.fm-upload p  { font-size: 12px; color: #9ca3af; margin: 0; }

/* ── Preview de archivo ──────────────────────── */
.fm-file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  margin-top: 12px;
  animation: fmSlide .3s ease;
}
@keyframes fmSlide { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.fm-prev-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; border: 2px solid #bbf7d0; }
.fm-prev-info { flex: 1; }
.fm-prev-name { font-size: 13px; font-weight: 600; color: #1f2937; }
.fm-prev-meta { font-size: 11px; color: #6b7280; margin-top: 2px; }
.fm-prev-rm {
  width: 30px; height: 30px;
  border-radius: 50%; border: none;
  background: #fee2e2; color: #ef4444;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.fm-prev-rm:hover { background: #ef4444; color: #fff; }

/* ── Galería grid ─────────────────────────────── */
.fm-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.fm-gal-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
}
.fm-gal-item img { width: 100%; height: 100%; object-fit: cover; }
.fm-gal-rm {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%; border: none;
  background: rgba(239,68,68,.9); color: #fff;
  cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.fm-gal-item:hover .fm-gal-rm { opacity: 1; }
.fm-gal-ord {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(0,0,0,.55);
  color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 5px;
}

/* ── Password strength ────────────────────────── */
.fm-strength { margin-top: 8px; }
.fm-strength-bar { height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.fm-strength-fill { height: 100%; border-radius: 3px; transition: all .3s; }
.fm-strength-text { font-size: 12px; font-weight: 600; color: #6b7280; }

/* ── Área de submit ───────────────────────────── */
.fm-submit-area { padding: 24px 36px 36px; }
.fm-submit-row  { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* ── Botones frontend ─────────────────────────── */
.fm-btn-submit {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 36px;
  background: linear-gradient(135deg, var(--fm-secondary,#10cbac), #0aaa8e);
  color: #fff; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700;
  font-family: var(--fm-font-titles,'Poppins',sans-serif);
  cursor: pointer; transition: all .3s;
  box-shadow: 0 4px 14px rgba(16,203,172,.3);
}
.fm-btn-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,203,172,.4); }
.fm-btn-submit.loading { pointer-events: none; opacity: .8; }
.fm-btn-cancel {
  padding: 14px 24px;
  background: transparent;
  color: #6b7280;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  font-size: 15px; font-weight: 600;
  font-family: var(--fm-font-body,'Open Sans',sans-serif);
  cursor: pointer; transition: all .2s;
}
.fm-btn-cancel:hover { border-color: #d1d5db; background: #f9fafb; }

/* ── Spinner ──────────────────────────────────── */
.fm-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fmSpin .8s linear infinite;
}
@keyframes fmSpin { to { transform: rotate(360deg); } }

/* ── Modal de procesando / éxito ──────────────── */
.fm-modal-overlay-front {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
}
.fm-modal-card {
  background: #fff;
  border-radius: 24px;
  padding: 44px 48px;
  text-align: center;
  max-width: 420px; width: 92%;
  box-shadow: 0 25px 60px rgba(0,0,0,.2);
  animation: fmModalFront .4s ease;
}
@keyframes fmModalFront {
  from { opacity:0; transform:scale(.85) translateY(20px); }
  to   { opacity:1; transform:scale(1)  translateY(0); }
}
.fm-modal-icon {
  width: 76px; height: 76px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.fm-modal-icon.loading { background: linear-gradient(135deg,#dbeafe,#bfdbfe); }
.fm-modal-icon.success { background: linear-gradient(135deg,#d1fae5,#a7f3d0); }
.fm-modal-card h3 {
  font-family: var(--fm-font-titles,'Poppins',sans-serif);
  font-size: 20px; color: var(--fm-tertiary,#07202c);
  margin: 0 0 10px; font-weight: 700;
}
.fm-modal-card p { color: #64748b; font-size: 14px; margin: 0 0 16px; line-height: 1.6; }
.fm-modal-countdown {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg,#eff6ff,#dbeafe);
  border-radius: 50px; border: 1px solid #bfdbfe;
  font-size: 13px; color: #3b82f6; font-weight: 600;
}
.fm-modal-countdown span { font-size: 20px; font-weight: 800; color: var(--fm-primary,#1048cb); }
.fm-spin-icon { animation: fmSpin 1.2s linear infinite; }

/* ── Imagen/galería actual (modo edición) ─────── */
.fm-current-img {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #0369a1;
}
.fm-current-img img {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #bae6fd;
  flex-shrink: 0;
}
.fm-current-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  margin-bottom: 10px;
}
.fm-current-gallery img {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #bae6fd;
}
.fm-current-gallery span {
  font-size: 12px;
  color: #0369a1;
  align-self: center;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 640px) {
  .fm-header { padding: 24px 20px; }
  .fm-header h1 { font-size: 20px; }
  .fm-form-body { padding: 20px 16px 0; }
  .fm-submit-area { padding: 20px 16px 24px; }
  .fm-user-bar { margin: 14px 14px 0; }
  .fm-grid { grid-template-columns: 1fr; }
  .fm-gallery-grid { grid-template-columns: repeat(3,1fr); }
  .fm-radio-group { flex-direction: column; }

  /* Botón Guardar: flotante fijo en el pie, 90% ancho */
  .fm-btn-submit {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    justify-content: center;
    padding: 17px 24px;
    font-size: 17px;
    border-radius: 16px;
    z-index: 999;
    box-shadow: 0 8px 32px rgba(16,203,172,.45);
  }
  /* Espacio extra al fondo para que el contenido no quede tapado por el botón flotante */
  .fm-submit-area {
    padding-bottom: 90px;
  }
}

/* ── Botón de edición desde listing ──────────────── */
.fm-btn-edit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--fm-primary, #1048cb);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  font-family: var(--fm-font-body, 'Open Sans', sans-serif);
  transition: all .2s;
}
.fm-btn-edit-link:hover {
  opacity: .88;
  color: #fff;
  transform: translateY(-1px);
}
.fm-btn-edit-link::before { content: '✏️'; font-size: 12px; }

