/* =========================================
   Glaura — Mon profil page
   Per-field editing with verification flows
   ========================================= */

/* --- Page wrapper --- */
.profile-page {
  min-height: 100vh;
  padding: 0 0 80px;
  max-width: 600px;
  margin: 0 auto;
}

/* --- Avatar / Hero header --- */
.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 28px;
  gap: 12px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 8px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.18);
}

.profile-hero__name {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
  text-align: center;
}

.profile-hero__subtitle {
  font-family: var(--font);
  font-size: 13px;
  color: var(--color-text-tertiary);
  text-align: center;
  margin-top: -4px;
}

/* --- Section (each editable group) --- */
.profile-section {
  background: var(--color-bg);
  margin: 0 16px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.profile-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
  margin-bottom: 12px;
}

.profile-section__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

/* Section inner padding */
.profile-section > .profile-field,
.profile-section > .profile-form-grid,
.profile-section > .profile-actions,
.profile-section > .profile-feedback,
.profile-section > .profile-confirm,
.profile-section > .profile-otp {
  padding-left: 16px;
  padding-right: 16px;
}

.profile-section > .profile-actions {
  padding-bottom: 16px;
}

.profile-section > .profile-feedback {
  margin-left: 16px;
  margin-right: 16px;
}

.profile-section > .profile-otp,
.profile-section > .profile-confirm {
  margin-left: 16px;
  margin-right: 16px;
  margin-bottom: 16px;
}

/* --- Form grid (2 columns on wider screens) --- */
.profile-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: 4px;
}

@media (min-width: 480px) {
  .profile-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- Field --- */
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 16px;
}

.profile-field__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-field__label .required {
  color: var(--color-accent);
  margin-left: 2px;
}

/* Read-only state: value displayed as plain text */
.profile-field__input {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  width: 100%;
  -webkit-appearance: none;
}

.profile-field__input:disabled {
  background: transparent;
  border: none;
  padding: 2px 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  opacity: 1;
  cursor: default;
  border-radius: 0;
}

/* Empty disabled input placeholder */
.profile-field__input:disabled:placeholder-shown {
  color: var(--color-text-tertiary);
  font-style: italic;
  font-weight: 400;
}

.profile-field__input:focus {
  border-color: var(--color-accent);
  background: var(--color-bg);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.08);
}

/* Phone field with flag prefix + verify button */
.profile-field__phone-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.profile-field__phone-wrapper {
  display: flex;
  align-items: center;
  background: var(--color-bg-secondary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  flex: 1;
}

.profile-field__phone-wrapper:focus-within {
  border-color: var(--color-accent);
  background: var(--color-bg);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.08);
}

/* Disabled phone wrapper (read-only state) */
.profile-field__phone-wrapper:has(.profile-field__phone-input:disabled) {
  background: transparent;
  border-color: transparent;
}

.profile-field__phone-flag {
  padding: 11px 6px 11px 14px;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}

.profile-field__phone-input {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  background: transparent;
  border: none;
  outline: none;
  padding: 11px 14px 11px 0;
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
}

.profile-field__phone-input:disabled {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  opacity: 1;
  cursor: default;
  padding-left: 2px;
}

/* Verify button */
.btn-verify {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

.btn-verify:hover {
  background: var(--color-accent-hover);
}

.btn-verify:active {
  transform: scale(0.97);
}

.btn-verify:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Modifier button --- */
.btn-modifier {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(225, 29, 72, 0.06);
  border: none;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}

.btn-modifier:hover {
  background: rgba(225, 29, 72, 0.12);
  color: var(--color-accent-hover);
}

/* --- Action row (Annuler + Enregistrer) --- */
.profile-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-bottom: 16px;
}

.profile-actions--hidden {
  display: none;
}

.btn-annuler,
.btn-enregistrer {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-full);
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  border: none;
  letter-spacing: 0.01em;
}

.btn-annuler {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  flex: 1;
  border: 1.5px solid var(--color-border);
}

.btn-annuler:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-enregistrer {
  background: var(--color-accent);
  color: #fff;
  flex: 2;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.2);
}

.btn-enregistrer:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.28);
}

.btn-enregistrer:active {
  transform: scale(0.98);
}

.btn-enregistrer:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Confirmation overlay --- */
.profile-confirm {
  background: #fff8f0;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 4px;
}

.profile-confirm__text {
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 14px;
  line-height: 1.6;
}

.profile-confirm__text strong {
  color: var(--color-accent);
  word-break: break-all;
}

/* --- Inline OTP step --- */
.profile-otp {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  margin-top: 4px;
}

.profile-otp__text {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.profile-otp__text strong {
  color: var(--color-text);
  font-weight: 600;
}

.profile-otp__row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.profile-otp__input {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 150px;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.profile-otp__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.08);
}

.profile-otp__btn {
  flex-shrink: 0;
  flex: 1;
  padding: 0 20px;
  border-radius: var(--radius-sm) !important;
  min-height: 48px;
}

.profile-otp__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.profile-otp__countdown {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.profile-otp__resend {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s;
}

.profile-otp__resend:hover {
  color: var(--color-accent-hover);
}

/* --- Inline feedback --- */
.profile-feedback {
  display: none;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  line-height: 1.5;
}

.profile-feedback--success {
  display: block;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.profile-feedback--error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* --- Loading spinner --- */
.profile-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: profile-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* --- Logout section --- */
.profile-section-divider {
  margin: 16px 16px 0;
  display: flex;
  flex-direction: column;
}

.logout-form {
  width: 100%;
}

.profile-logout-btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(225, 29, 72, 0.05);
  border: 1.5px solid rgba(225, 29, 72, 0.15);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.profile-logout-btn::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e11d48' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.profile-logout-btn:hover {
  background: rgba(225, 29, 72, 0.1);
  border-color: rgba(225, 29, 72, 0.3);
}

/* --- Marketplace email/SMS preferences (push stays separate) --- */
.marketplace-preferences__header {
  margin-bottom: 6px;
}

.marketplace-preferences__intro,
.marketplace-preferences__service-note,
.marketplace-preferences__privacy {
  margin: 0;
  color: var(--color-text-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

.marketplace-preferences__intro {
  padding: 0 16px 12px;
}

.marketplace-preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 16px;
  padding: 14px 0;
  border-top: 1px solid var(--color-border-light);
  cursor: pointer;
}

.marketplace-preference__copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.marketplace-preference__copy strong {
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
}

.marketplace-preference__copy span,
.marketplace-preference__copy small {
  color: var(--color-text-tertiary);
  font-size: 12px;
  line-height: 1.4;
}

.marketplace-preference__copy small:not(:empty) {
  color: #9f1239;
}

.marketplace-switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
}

.marketplace-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.marketplace-switch__track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d9d5d6;
  transition: background .18s ease;
}

.marketplace-switch__track::after {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  margin: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}

.marketplace-switch input:checked + .marketplace-switch__track {
  background: var(--color-accent);
}

.marketplace-switch input:checked + .marketplace-switch__track::after {
  transform: translateX(18px);
}

.marketplace-switch input:focus-visible + .marketplace-switch__track {
  outline: 3px solid rgba(225, 29, 72, .2);
  outline-offset: 2px;
}

.marketplace-switch input:disabled + .marketplace-switch__track {
  cursor: not-allowed;
  opacity: .55;
}

.marketplace-preferences__service-note {
  padding: 8px 16px 0;
}

.marketplace-preferences__privacy {
  display: inline-block;
  margin: 7px 16px 14px;
  color: var(--color-accent);
  font-weight: 600;
}

.marketplace-preferences__feedback {
  margin-bottom: 16px;
}

/* --- Version / spacer at bottom --- */
.profile-footer-space {
  height: 24px;
}

/* --- Desktop adjustments --- */
@media (min-width: 768px) {
  .profile-page {
    padding-bottom: 40px;
  }

  .profile-hero {
    padding: 40px 32px 32px;
  }

  .profile-avatar {
    width: 84px;
    height: 84px;
    font-size: 32px;
  }

  .profile-hero__name {
    font-size: 20px;
  }

  .profile-section {
    margin: 0 0 12px;
  }

  .profile-section-divider {
    margin: 16px 0 0;
  }

  .profile-page {
    padding-left: 0;
    padding-right: 0;
  }
}

/* --- Small mobile (375px) --- */
@media (max-width: 390px) {
  .profile-section {
    margin: 0 12px 10px;
  }

  .profile-section-divider {
    margin: 12px 12px 0;
  }

  .profile-hero {
    padding: 24px 16px 20px;
  }

  .profile-otp__input {
    width: 120px;
    font-size: 19px;
    letter-spacing: 0.2em;
  }
}
