/* ============================================================
   VIPSCLUB Portal 2026 — Account Profile Form Module
   Figma: Desktop 339:8314 | Mobile 380:3276
   ============================================================ */

/* ── Outer wrapper ── */
.account-profile-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Profile Summary Card ── */
.account-profile-form__profile-card {
  background: var(--vips-bg-card);
  border: 1px solid var(--vips-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-subtle);
  padding: 24px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
  margin-bottom: 24px;
}

/* ── Left column (desktop): identity stacked above member-since/logout ── */
.account-profile-form__main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 120px;
}

.account-profile-form__identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.account-profile-form__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.account-profile-form__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--vips-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 32px;
  color: var(--vips-text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.account-profile-form__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-profile-form__name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 18px;
  line-height: 24px;
  color: var(--vips-dark);
  margin: 0;
  text-align: center;
}

.account-profile-form__email {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--vips-text-secondary);
  margin: 0;
  text-align: center;
}

.account-profile-form__member-since {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  line-height: 18px;
  color: var(--vips-text-secondary);
  margin: 0;
  text-align: center;
}

.account-profile-form__member-since-label {
  color: var(--vips-text-muted);
  margin-right: 4px;
}

.account-profile-form__logout {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 10px;
  line-height: 14px;
  color: var(--vips-red);
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.account-profile-form__logout:hover {
  text-decoration: underline;
}

/* ── Stat Cards (right) ── */
.account-profile-form__stats {
  display: flex;
  gap: 16px;
  flex: 1;
}

.account-profile-form__stat {
  flex: 1;
  background: var(--vips-text-white);
  border-radius: var(--radius-xl);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.account-profile-form__stat-number {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 28px;
  line-height: 34px;
  color: var(--vips-dark);
}

.account-profile-form__stat-label {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--vips-text-secondary);
}

/* ── Tab Bar ── */
.account-profile-form__tabs {
  display: flex;
  border-bottom: 1px solid var(--vips-border);
  margin-bottom: 24px;
}

.account-profile-form__tab {
  padding: 14px 24px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  line-height: 20px;
  color: var(--vips-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
  margin-bottom: -1px;
}

.account-profile-form__tab.is-active {
  color: var(--vips-dark);
  font-weight: 700;
  border-bottom-color: var(--vips-dark);
}

.account-profile-form__tab:hover {
  color: var(--vips-dark);
}

.account-profile-form__tab:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Tab Panels ── */
.account-profile-form__panel {
  display: block;
}

.account-profile-form__panel[hidden] {
  display: none;
}

/* ── Personal Details Panel header ── */
.account-profile-form__panel-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.account-profile-form__edit-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  color: var(--vips-dark-subtle);
  background: none;
  border: 1px solid var(--vips-dark-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.account-profile-form__edit-btn:hover {
  background: var(--vips-bg-input);
}

.account-profile-form__edit-btn:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 2px;
}

/* ── Form wrap — white card ── */
.account-profile-form__form-wrap {
  background: var(--vips-bg-card);
  border: 1px solid var(--vips-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-subtle);
  padding: 24px;
}

/* ── HubSpot form: 2-column grid ── */
.account-profile-form__form-wrap .hs-form,
.account-profile-form__wealth-card .hs-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
  row-gap: 20px;
}

.account-profile-form__form-wrap .hs-form .hs-submit,
.account-profile-form__wealth-card .hs-form .hs-submit {
  grid-column: 1 / -1;
  margin-top: 8px;
}

/* ── Field labels ── */
.account-profile-form__form-wrap .hs-label,
.account-profile-form__form-wrap label,
.account-profile-form__wealth-card .hs-label,
.account-profile-form__wealth-card label {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 21px;
  color: #1a1a1a;
  margin-bottom: 6px;
}

/* ── Inputs, selects, textareas ── */
.account-profile-form__form-wrap input.hs-input,
.account-profile-form__form-wrap select.hs-input,
.account-profile-form__form-wrap textarea.hs-input,
.account-profile-form__wealth-card input.hs-input,
.account-profile-form__wealth-card select.hs-input,
.account-profile-form__wealth-card textarea.hs-input {
  width: 100%;
  height: 43px;
  padding: 0 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: #616161;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.account-profile-form__form-wrap textarea.hs-input,
.account-profile-form__wealth-card textarea.hs-input {
  height: auto;
  min-height: 80px;
  padding: 10px;
  resize: vertical;
}

.account-profile-form__form-wrap input.hs-input:focus,
.account-profile-form__form-wrap select.hs-input:focus,
.account-profile-form__form-wrap textarea.hs-input:focus,
.account-profile-form__wealth-card input.hs-input:focus,
.account-profile-form__wealth-card select.hs-input:focus,
.account-profile-form__wealth-card textarea.hs-input:focus {
  outline: none;
  border-color: var(--vips-dark);
}

/* ── Submit button ── */
.account-profile-form__form-wrap .hs-button.primary,
.account-profile-form__wealth-card .hs-button.primary {
  height: 47px;
  padding: 0 24px;
  background: #212121;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.account-profile-form__form-wrap .hs-button.primary:hover,
.account-profile-form__wealth-card .hs-button.primary:hover {
  background: #3f3f47;
}

.account-profile-form__form-wrap .hs-button.primary:focus-visible,
.account-profile-form__wealth-card .hs-button.primary:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 2px;
}

/* ── Error messages ── */
.account-profile-form__form-wrap .hs-error-msgs,
.account-profile-form__wealth-card .hs-error-msgs {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.account-profile-form__form-wrap .hs-error-msg,
.account-profile-form__wealth-card .hs-error-msg {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 16px;
  color: var(--vips-red);
}

/* ── Field description ── */
.account-profile-form__form-wrap .hs-field-desc,
.account-profile-form__wealth-card .hs-field-desc {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 16px;
  color: var(--vips-text-secondary);
  margin: 4px 0 0;
}

/* ── Remove HS default styling that may interfere ── */
.account-profile-form__form-wrap .hs-form .input,
.account-profile-form__wealth-card .hs-form .input {
  margin: 0;
}

.account-profile-form__form-wrap .hs-form fieldset,
.account-profile-form__wealth-card .hs-form fieldset {
  max-width: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* ── Email field: always locked regardless of editing state ── */
.account-profile-form__form-wrap .hs_email input.hs-input {
  pointer-events: none !important;
  background: #f9f9f9 !important;
  color: var(--vips-text-secondary) !important;
}

/* ── Form locked state (entire form is read-only — covers date pickers, custom widgets, any future fields) ── */
.account-profile-form__form-wrap--locked .hs-form {
  pointer-events: none;
}

.account-profile-form__form-wrap--locked input.hs-input,
.account-profile-form__form-wrap--locked select.hs-input,
.account-profile-form__form-wrap--locked textarea.hs-input,
.account-profile-form__form-wrap--locked .hs-fieldtype-date input,
.account-profile-form__form-wrap--locked .hs-dateinput input {
  background: #f9f9f9;
  color: var(--vips-text-secondary);
  cursor: default;
}

.account-profile-form__form-wrap--locked .hs-submit {
  display: none;
}

/* ── Form unlocked state (after Edit Profile click) ── */
.account-profile-form__form-wrap--editing .hs-form {
  pointer-events: auto;
}

.account-profile-form__form-wrap--editing input.hs-input,
.account-profile-form__form-wrap--editing select.hs-input,
.account-profile-form__form-wrap--editing textarea.hs-input {
  background: #fff;
  color: #212121;
  cursor: auto;
}

.account-profile-form__form-wrap--editing .hs-submit {
  display: block;
}

/* ── Wealth Hub Card ── */
.account-profile-form__wealth-card {
  background: var(--vips-bg-card);
  border: 1px solid var(--vips-border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ── Placeholder (editor only) ── */
.account-profile-form__placeholder {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 22px;
  color: var(--vips-text-secondary);
  background: var(--vips-bg-input);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
}

.account-profile-form__placeholder p {
  margin: 0;
}

/* ── Custom DOB field — text input with calendar icon (replaces broken HubSpot Pikaday) ── */
.account-profile-form__dob-wrap {
  position: relative;
  width: 100%;
}

.account-profile-form__form-wrap input.account-profile-form__native-dob {
  width: 100%;
  height: 43px;
  padding: 0 40px 0 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: #616161;
  box-sizing: border-box;
}

.account-profile-form__form-wrap input.account-profile-form__native-dob:focus {
  outline: none;
  border-color: var(--vips-dark);
}

.account-profile-form__form-wrap--locked input.account-profile-form__native-dob {
  background: #f9f9f9;
  color: var(--vips-text-secondary);
}

/* Hidden native date picker — used only via showPicker() when icon is clicked */
.account-profile-form__dob-picker {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

.account-profile-form__dob-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--vips-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.account-profile-form__dob-btn:hover {
  color: var(--vips-dark);
  background: #f7f7f7;
}

.account-profile-form__dob-btn:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 1px;
}

.account-profile-form__form-wrap--locked .account-profile-form__dob-btn {
  display: none;
}

.account-profile-form__dob-error {
  color: var(--vips-red);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 16px;
  margin: 4px 0 0;
  display: none;
}

/* ── Profile Image Field — full-width row at top of form ── */
.account-profile-form__form-wrap .hs_profile_image_file {
  grid-column: 1 / -1;
  order: -1;
}

/* Hide the native HubSpot file input — we replace it with custom avatar UI.
   Use opacity/position rather than display:none so the input stays in the
   accessibility tree and React keeps it tracked. */
.account-profile-form__form-wrap .hs_profile_image_file input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

/* Custom avatar uploader block (injected by JS) */
.account-profile-form__avatar-uploader {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 0 4px;
}

.account-profile-form__avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--vips-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 32px;
  color: var(--vips-text-secondary);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.account-profile-form__avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-profile-form__avatar-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-profile-form__avatar-hint {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 16px;
  color: var(--vips-text-secondary);
}

.account-profile-form__avatar-edit {
  align-self: flex-start;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 20px;
  color: #fff;
  background: var(--vips-dark);
  border: none;
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  margin-top: 2px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.account-profile-form__avatar-edit:hover {
  background: #3f3f47;
}

.account-profile-form__avatar-edit:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 2px;
}

/* Hide the edit button when the form is locked — only visible after Edit Profile click */
.account-profile-form__form-wrap--locked .account-profile-form__avatar-edit {
  display: none;
}

/* Hide the helper hint when locked too — keeps the locked view clean */
.account-profile-form__form-wrap--locked .account-profile-form__avatar-hint {
  display: none;
}

/* ── Crop Modal ── */
.account-profile-form__crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.account-profile-form__crop-modal.is-open {
  display: flex;
}

.account-profile-form__crop-dialog {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-profile-form__crop-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  line-height: 24px;
  color: var(--vips-dark);
  margin: 0;
}

/* File-picker dropzone (shown until a file is chosen) */
.account-profile-form__crop-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--vips-text-secondary);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.account-profile-form__crop-dropzone:hover,
.account-profile-form__crop-dropzone.is-drag {
  border-color: var(--vips-dark);
  background: #f7f7f7;
}

.account-profile-form__crop-dropzone strong {
  display: block;
  color: var(--vips-dark);
  font-weight: 600;
  margin-bottom: 4px;
}

.account-profile-form__crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.account-profile-form__crop-stage:active {
  cursor: grabbing;
}

.account-profile-form__crop-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Circular mask overlay — rendered as a radial gradient that dims everything outside the circle */
.account-profile-form__crop-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 49.5%, rgba(0,0,0,0.55) 50%);
  border-radius: 8px;
}

.account-profile-form__crop-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-profile-form__crop-zoom-label {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--vips-text-secondary);
  min-width: 50px;
}

.account-profile-form__crop-zoom input[type="range"] {
  flex: 1;
  accent-color: var(--vips-dark);
}

.account-profile-form__crop-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.account-profile-form__crop-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.account-profile-form__crop-btn--secondary {
  background: #fff;
  border-color: #ddd;
  color: var(--vips-dark);
}

.account-profile-form__crop-btn--secondary:hover {
  background: #f7f7f7;
}

.account-profile-form__crop-btn--primary {
  background: var(--vips-dark);
  color: #fff;
}

.account-profile-form__crop-btn--primary:hover {
  background: #3f3f47;
}

.account-profile-form__crop-btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.account-profile-form__crop-btn:focus-visible {
  outline: 2px solid var(--vips-dark);
  outline-offset: 2px;
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
  .account-profile-form__avatar-uploader {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  .account-profile-form__avatar-meta {
    align-items: center;
  }

  /* Center the Change photo button to match the centered image + hint above it
     (base rule sets align-self:flex-start for the desktop row layout). */
  .account-profile-form__avatar-edit {
    align-self: center;
  }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {

  .account-profile-form--hide-mobile {
    display: none;
  }

  .account-profile-form__profile-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    border-radius: 10px;
    border-width: 0.698px;
  }

  /* Flatten .__main so identity / stats / meta become direct flex children of the
     profile card, then re-order to match the mobile design:
     identity (avatar/name/email) → stats → meta (member-since/logout). */
  .account-profile-form__main {
    display: contents;
  }
  .account-profile-form__identity { order: 1; }
  .account-profile-form__stats    { order: 2; }
  .account-profile-form__meta     { order: 3; }

  .account-profile-form__stats {
    width: 100%;
    gap: 8px;
  }

  .account-profile-form__stat {
    padding: 16px 8px;
  }

  .account-profile-form__stat-number {
    font-size: 22px;
  }

  .account-profile-form__stat-label {
    font-size: 11px;
  }

  .account-profile-form__tab {
    padding: 12px 16px;
    font-size: 14px;
  }

  .account-profile-form__wealth-card {
    border-radius: 10px;
    border-width: 0.698px;
  }

  /* Form: single column on mobile */
  .account-profile-form__form-wrap .hs-form,
  .account-profile-form__wealth-card .hs-form {
    grid-template-columns: 1fr;
  }

  .account-profile-form__form-wrap {
    padding: 16px;
    border-radius: 10px;
    border-width: 0.698px;
  }

}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .account-profile-form__tab,
  .account-profile-form__edit-btn {
    transition: none;
  }
}

/* ── Per-instance style overrides ── */
{% if module.style_overrides.background_color.color %}
.account-profile-form {
  background-color: ;
}
{% endif %}

{% if module.style_overrides.padding_top %}
.account-profile-form {
  padding-top: px;
}
{% endif %}

{% if module.style_overrides.padding_bottom %}
.account-profile-form {
  padding-bottom: px;
}
{% endif %}
