/* Luxa Forms - Frontend Styles
   Version: 1.0.0 | luxapress.com
----------------------------------------------- */

:root {
  --lxf-primary:     #2563eb;
  --lxf-primary-h:   #1d4ed8;
  --lxf-danger:      #dc2626;
  --lxf-success:     #16a34a;
  --lxf-border:      #d1d5db;
  --lxf-border-r:    #2563eb;
  --lxf-bg:          #ffffff;
  --lxf-text:        #111827;
  --lxf-muted:       #6b7280;
  --lxf-placeholder: #9ca3af;
  --lxf-radius:      6px;
  --lxf-transition:  0.15s ease;
  --lxf-font:        inherit;
}

.lxf-form-wrap { max-width: 720px; font-family: var(--lxf-font); }

.lxf-form-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.lxf-form-description { color: #6b7280; margin-bottom: 1.5rem; }

/* ---- Form messages ---- */
.lxf-form-messages:empty { display: none; }
.lxf-form-messages { padding: 0.75rem 1rem; border-radius: var(--lxf-radius); margin-bottom: 1.25rem; }
.lxf-form-messages.lxf-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.lxf-form-messages.lxf-error   { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }

/* ---- Fields grid ---- */
.lxf-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.lxf-field {
  box-sizing: border-box;
}

.lxf-field--width-100 { width: 100%; }
.lxf-field--width-75  { width: calc(75% - 0.5rem); }
.lxf-field--width-66  { width: calc(66.666% - 0.5rem); }
.lxf-field--width-50  { width: calc(50% - 0.5rem); }
.lxf-field--width-33  { width: calc(33.333% - 0.5rem); }
.lxf-field--width-25  { width: calc(25% - 0.5rem); }

@media (max-width: 600px) {
  .lxf-field { width: 100% !important; }
}

/* ---- Label ---- */
.lxf-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--lxf-text);
  margin-bottom: 0.375rem;
}
.lxf-required { color: var(--lxf-danger); margin-left: 2px; }

/* ---- Inputs ---- */
.lxf-input,
.lxf-form input[type=text],
.lxf-form input[type=email],
.lxf-form input[type=number],
.lxf-form input[type=tel],
.lxf-form input[type=url],
.lxf-form input[type=date],
.lxf-form input[type=time],
.lxf-form input[type=file],
.lxf-form select,
.lxf-form textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1.5px solid var(--lxf-border);
  border-radius: var(--lxf-radius);
  background: var(--lxf-bg);
  color: var(--lxf-text);
  font-size: 0.9375rem;
  line-height: 1.5;
  box-sizing: border-box;
  transition: border-color var(--lxf-transition), box-shadow var(--lxf-transition);
  outline: none;
}

.lxf-input:focus,
.lxf-form input:focus,
.lxf-form select:focus,
.lxf-form textarea:focus {
  border-color: var(--lxf-border-r);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/**
 * input[type="color"] override — see ColorPickerField, which gets
 * class="lxf-input" the same as every other field via the shared
 * build_attrs() helper (AbstractField), but a native color input
 * renders as a small browser-drawn swatch button, NOT a text-like
 * box — the generic width:100%/padding rule above stretches that
 * swatch into the flattened, near-invisible sliver reported in
 * testing, instead of leaving it as its own compact control.
 * Deliberately placed AFTER the generic block above (equal
 * specificity — one class + one attribute selector either way — so
 * cascade ORDER, not a specificity fight, is what makes this win;
 * simpler than chasing a higher-specificity selector for one
 * override).
 */
.lxf-form input[type="color"] {
  width: 3.5rem;
  height: 2.5rem;
  padding: 0.25rem;
  cursor: pointer;
}

.lxf-input.lxf-has-error,
.lxf-field--has-error .lxf-input {
  border-color: var(--lxf-danger);
}

.lxf-form textarea { resize: vertical; min-height: 100px; }
.lxf-form select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.6rem center; background-size: 14px; padding-right: 2rem; }

/* ---- Radio / Checkbox ---- */
.lxf-radio-group,
.lxf-checkbox-group { display: flex; flex-direction: column; gap: 0.4rem; }

.lxf-radio-label,
.lxf-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.lxf-radio,
.lxf-checkbox {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: var(--lxf-primary);
}

/* ---- File ---- */
.lxf-file-wrap { position: relative; }
.lxf-file-hint { margin: 0.3rem 0 0; font-size: 0.8rem; color: #6b7280; }

/**
 * Selected-files list — supplements (does NOT replace) the native
 * <input type="file">'s own "Choose Files" button + OS-drawn "N
 * files" text. That native text is browser/OS chrome, not something
 * in the DOM we control — no CSS can restyle or hide it reliably
 * across browsers without replacing the native file input's actual
 * functionality entirely (a fully custom button + drag-and-drop
 * reimplementation), which is a bigger scope than this fix. Instead,
 * assets/js/frontend.js renders an actually useful list of the real
 * selected file names + sizes right below the native input on every
 * 'change' — the native "3 files" text still shows (an accepted,
 * unavoidable minor redundancy), but the file names/sizes a person
 * actually cares about seeing are now visible too.
 */
.lxf-file-selected-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.lxf-file-selected-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: #374151;
}
.lxf-file-selected-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lxf-file-selected-item__size {
  color: #9ca3af;
  margin-left: auto;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.lxf-file-selected-item__remove {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
}
.lxf-file-selected-item__remove:hover {
  background: #fee2e2;
  color: #991b1b;
}


/* ---- Description ---- */
.lxf-description { margin: 0.3rem 0 0; font-size: 0.8125rem; color: #6b7280; }

/* ---- Error message ---- */
.lxf-field__error { display: block; font-size: 0.8125rem; color: var(--lxf-danger); min-height: 1.2em; margin-top: 0.25rem; }

/* ---- Layout fields ---- */
.lxf-field--divider {
  width: 100% !important;
  margin: 0.5rem 0;
}
.lxf-divider {
  border: none;
  border-top: 1px solid var(--lxf-border);
  margin: 0;
}

/**
 * BUG FIX: same underlying issue as .lxf-field--divider above (and as
 * luxa-forms-multistep's own `.lxf-fields > .lxf-step` rule — see
 * that plugin's frontend-multistep.css for the fullest writeup of
 * this exact bug class) — .lxf-fields is `display:flex` with NO
 * explicit flex-direction, so it defaults to `row`, making WIDTH the
 * flex main axis. SpacerField::render() sets an inline `height` but
 * never a `width` — a completely empty <div> with no `width` and no
 * content has nothing to give it a main-axis (width) size, so it
 * collapsed to 0px wide regardless of what height was configured,
 * making it invisible. (Setting `flex-direction: column` on
 * `.lxf-fields` would also "fix" this — width would become the CROSS
 * axis and auto-stretch to fill the row via the default
 * `align-items: stretch` — but that would break every OTHER field's
 * width:50/33/25% side-by-side column layout, which specifically
 * depends on `.lxf-fields` staying row-direction. Scoping the fix to
 * just this one field type, the same way Divider's own width rule
 * already does, is correct here — not a global container change.)
 */
.lxf-field--spacer {
  width: 100% !important;
}

.lxf-field--heading {
  width: 100% !important;
  margin-top: 0.5rem;
}
.lxf-heading {
  margin: 0 0 0.25rem;
  font-weight: 700;
  color: var(--lxf-text);
}
.lxf-heading-sub { margin: 0; color: #6b7280; font-size: 0.9rem; }

.lxf-field--html {
  width: 100% !important;
  line-height: 1.6;
  color: var(--lxf-text);
}
.lxf-field--html > *:first-child { margin-top: 0; }
.lxf-field--html > *:last-child  { margin-bottom: 0; }

/* ---- Submit button ---- */
.lxf-submit-wrap { margin-top: 1.25rem; }
.lxf-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  background: var(--lxf-primary);
  color: #fff;
  border: none;
  border-radius: var(--lxf-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--lxf-transition), transform var(--lxf-transition);
}
.lxf-submit-btn:hover { background: var(--lxf-primary-h); }
.lxf-submit-btn:active { transform: scale(0.98); }
.lxf-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Spinner */
.lxf-submit-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lxf-spin 0.6s linear infinite;
}
.lxf-form--submitting .lxf-submit-spinner { display: inline-block; }
.lxf-form--submitting .lxf-submit-text { opacity: 0.8; }

@keyframes lxf-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   New field types — giai đoạn 1
   ========================================================================== */

/* Toggle */
.lxf-toggle-field { display: inline-flex; align-items: center; cursor: pointer; }
.lxf-toggle-field input { position: absolute; opacity: 0; width: 0; height: 0; }
.lxf-toggle-field__slider {
  position: relative; width: 42px; height: 24px;
  background: var(--lxf-border); border-radius: 999px;
  transition: background var(--lxf-transition);
}
.lxf-toggle-field__slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform var(--lxf-transition);
}
.lxf-toggle-field input:checked + .lxf-toggle-field__slider { background: var(--lxf-primary); }
.lxf-toggle-field input:checked + .lxf-toggle-field__slider::before { transform: translateX(18px); }
.lxf-toggle-field input:focus-visible + .lxf-toggle-field__slider { outline: 2px solid var(--lxf-primary); outline-offset: 2px; }

/* Slider */
.lxf-slider-field { display: flex; align-items: center; gap: 0.75rem; }
.lxf-slider-field input[type="range"] { flex: 1; accent-color: var(--lxf-primary); }
.lxf-slider-field__value {
  min-width: 2.5rem; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 0.875rem; color: var(--lxf-text, #374151);
}

/* Rating */
.lxf-rating-field { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.lxf-rating-field__input { position: absolute; opacity: 0; width: 0; height: 0; }
.lxf-rating-field__star {
  font-size: 1.75rem; line-height: 1; color: var(--lxf-border); cursor: pointer;
  transition: color var(--lxf-transition);
}
.lxf-rating-field__input:checked ~ .lxf-rating-field__star,
.lxf-rating-field__star:hover,
.lxf-rating-field__star:hover ~ .lxf-rating-field__star {
  color: #f59e0b;
}
.lxf-rating-field__input:focus-visible + .lxf-rating-field__star { outline: 2px solid var(--lxf-primary); outline-offset: 2px; }

/* Password */
.lxf-password-field { position: relative; }
.lxf-password-field input { padding-right: 2.5rem; width: 100%; }
.lxf-password-field__toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; opacity: 0.6;
  padding: 0.25rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.lxf-password-field__toggle .dashicons {
  font-size: 1.125rem; color: var(--lxf-muted); width: 1.125rem; height: 1.125rem; line-height: 1;
}
.lxf-password-field__toggle:hover { opacity: 1; }
.lxf-password-field__meter { height: 4px; border-radius: 999px; background: var(--lxf-border); margin-top: 0.5rem; overflow: hidden; }
.lxf-password-field__meter span { display: block; height: 100%; width: 0%; transition: width var(--lxf-transition), background var(--lxf-transition); }
.lxf-password-field__meter--weak span   { background: var(--lxf-danger); }
.lxf-password-field__meter--fair span   { background: #f59e0b; }
.lxf-password-field__meter--strong span { background: #16a34a; }

/* Consent */
.lxf-consent-field { display: flex; align-items: flex-start; gap: 0.5rem; cursor: pointer; font-size: 0.9375rem; line-height: 1.5; }
.lxf-consent-field input { margin-top: 0.2rem; accent-color: var(--lxf-primary); }
.lxf-consent-field a { color: var(--lxf-primary); text-decoration: underline; }

/* Layout: Paragraph / Section / Spacer / Alert */
.lxf-paragraph { margin: 0; line-height: 1.6; }
.lxf-section-title { margin: 0 0 0.25rem; font-size: 1.0625rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.lxf-section-desc { margin: 0 0 0.5rem; color: #6b7280; font-size: 0.875rem; }
.lxf-section-rule { border: none; border-top: 1px solid var(--lxf-border); margin: 0.5rem 0 1rem; }

.lxf-alert { padding: 0.75rem 1rem; border-radius: var(--lxf-radius); border: 1px solid; font-size: 0.9375rem; line-height: 1.5; }
.lxf-alert--info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.lxf-alert--warning  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.lxf-alert--success  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.lxf-alert--danger   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
