/* Profile settings — panneau latéral (style Framer Motion / spring) */

#modal-profile-settings.profile-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 10001;
  pointer-events: none;
  visibility: hidden;
}

#modal-profile-settings.profile-drawer-root.visible {
  pointer-events: auto;
  visibility: visible;
}

#modal-profile-settings .profile-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  backdrop-filter: blur(4px);
}

#modal-profile-settings.visible .profile-drawer-overlay {
  opacity: 1;
}

#modal-profile-settings.closing .profile-drawer-overlay {
  opacity: 0;
}

#modal-profile-settings .profile-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  max-width: 100%;
  background: #fff;
  box-shadow: -12px 0 48px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  padding-top: env(safe-area-inset-top, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

#modal-profile-settings.visible .profile-drawer {
  transform: translateX(0);
}

#modal-profile-settings.closing .profile-drawer {
  transform: translateX(100%);
  transition-duration: 0.32s;
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}

#modal-profile-settings .profile-drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top, 0px) + 12px) 20px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(180deg, #fafafa 0%, #fff 100%);
}

#modal-profile-settings .profile-drawer-header > div:first-child {
  min-width: 0;
  flex: 1;
}

#modal-profile-settings .profile-drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#modal-profile-settings .profile-drawer-header h2 {
  margin: 0;
  font-family: var(--font-title, Poppins, sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
}

#modal-profile-settings .profile-drawer-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}

#modal-profile-settings .profile-close {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

#modal-profile-settings .profile-close:hover {
  background: #f3f4f6;
  color: #111827;
  transform: scale(1.05);
}

#modal-profile-settings .profile-drawer-body {
  flex: 1;
  display: grid;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: minmax(148px, 176px) minmax(0, 1fr);
  grid-template-rows: 1fr;
  grid-template-areas: "nav main";
}

#modal-profile-settings .profile-nav-mobile {
  display: none;
  grid-area: nav;
}

#modal-profile-settings .profile-nav-scroll-wrap {
  grid-area: nav;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid #e5e7eb;
  background: #fafafa;
}

#modal-profile-settings .profile-settings-nav {
  height: 100%;
  padding: 10px 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#modal-profile-settings .profile-settings-main {
  grid-area: main;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#modal-profile-settings .profile-nav-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 11px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.3;
}

#modal-profile-settings .profile-nav-text-short {
  display: none;
}

#modal-profile-settings .profile-nav-item:hover {
  background: #f3f4f6;
  color: #111827;
}

#modal-profile-settings .profile-nav-item.active {
  background: linear-gradient(90deg, rgba(32, 58, 124, 0.12), transparent);
  color: #203a7c;
  font-weight: 600;
  border-right: 3px solid #203a7c;
}

#modal-profile-settings .profile-settings-content {
  flex: 1;
  min-height: 0;
  padding: 20px 24px max(28px, env(safe-area-inset-bottom, 0px) + 16px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#modal-profile-settings .profile-nav-mobile-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

#modal-profile-settings .profile-section-select {
  width: 100%;
  min-height: 48px;
  padding: 12px 40px 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #111827;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  appearance: none;
  cursor: pointer;
}

#modal-profile-settings .profile-panel {
  display: none;
}

#modal-profile-settings .profile-panel.active {
  display: block;
  animation: profilePanelIn 0.35s cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes profilePanelIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

#modal-profile-settings .profile-panel h2 {
  font-family: var(--font-title, Poppins, sans-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 6px;
}

#modal-profile-settings .profile-sub {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.55;
  margin: 0 0 20px;
}

#modal-profile-settings .profile-saved {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 13px;
  color: #16a34a;
  font-weight: 600;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: #ecfdf5;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#modal-profile-settings .profile-saved.show {
  opacity: 1;
  transform: translateY(0);
}

/* Tablette : barre horizontale scrollable */
@media (max-width: 900px) {
  #modal-profile-settings .profile-drawer {
    width: min(100vw, 100%);
  }

  #modal-profile-settings .profile-drawer-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav"
      "main";
  }

  #modal-profile-settings .profile-nav-mobile {
    display: none;
  }

  #modal-profile-settings .profile-nav-scroll-wrap {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    position: relative;
  }

  #modal-profile-settings .profile-nav-scroll-wrap::before,
  #modal-profile-settings .profile-nav-scroll-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    z-index: 2;
    pointer-events: none;
  }

  #modal-profile-settings .profile-nav-scroll-wrap::before {
    left: 0;
    background: linear-gradient(90deg, #fff 30%, transparent);
  }

  #modal-profile-settings .profile-nav-scroll-wrap::after {
    right: 0;
    background: linear-gradient(270deg, #fff 30%, transparent);
  }

  #modal-profile-settings .profile-settings-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    height: auto;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #modal-profile-settings .profile-settings-nav::-webkit-scrollbar {
    display: none;
  }

  #modal-profile-settings .profile-nav-item {
    flex: 0 0 auto;
    width: auto;
    min-height: 40px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    scroll-snap-align: center;
    white-space: nowrap;
    border-right: none;
  }

  #modal-profile-settings .profile-nav-text-full {
    display: none;
  }

  #modal-profile-settings .profile-nav-text-short {
    display: inline;
  }

  #modal-profile-settings .profile-nav-item:hover {
    background: #f3f4f6;
  }

  #modal-profile-settings .profile-nav-item.active {
    background: linear-gradient(90deg, #203a7c, #80348a);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(32, 58, 124, 0.25);
  }

  #modal-profile-settings .profile-settings-content {
    padding: 16px 18px max(24px, env(safe-area-inset-bottom, 0px) + 12px);
  }

  #modal-profile-settings .profile-field-row {
    grid-template-columns: 1fr;
  }

  #modal-profile-settings .profile-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile : sélecteur natif (meilleure ergonomie pour 10 sections) */
@media (max-width: 520px) {
  #modal-profile-settings .profile-drawer {
    width: 100%;
    max-width: 100%;
  }

  #modal-profile-settings .profile-drawer-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  #modal-profile-settings .profile-drawer-header h2 {
    font-size: 1.1rem;
  }

  #modal-profile-settings .profile-drawer-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  #modal-profile-settings .profile-drawer-body {
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav"
      "main";
  }

  #modal-profile-settings .profile-nav-mobile {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
    flex-shrink: 0;
  }

  #modal-profile-settings .profile-nav-scroll-wrap {
    display: none;
  }

  #modal-profile-settings .profile-settings-content {
    padding: 14px 16px max(20px, env(safe-area-inset-bottom, 0px) + 12px);
  }

  #modal-profile-settings .profile-community-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  #modal-profile-settings .profile-community-info {
    flex: 1 1 calc(100% - 58px);
  }

  #modal-profile-settings .profile-btn-outline {
    width: 100%;
    margin-top: 4px;
    min-height: 44px;
  }

  #modal-profile-settings .profile-photo-row {
    flex-direction: column;
    align-items: flex-start;
  }

  #modal-profile-settings .profile-invite-row {
    flex-direction: column;
  }

  #modal-profile-settings .profile-invite-row .profile-btn-primary {
    width: 100%;
    min-height: 48px;
  }

  #modal-profile-settings .profile-account-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #modal-profile-settings .profile-account-row .profile-btn-outline,
  #modal-profile-settings .profile-account-row .profile-btn-primary {
    width: 100%;
    min-height: 44px;
  }

  #modal-profile-settings .profile-toggle-row {
    gap: 12px;
    align-items: flex-start;
  }

  #modal-profile-settings .profile-chat-community {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #modal-profile-settings .profile-chat-community select {
    width: 100%;
    min-height: 44px;
  }

  #modal-profile-settings .profile-btn-primary {
    width: 100%;
    min-height: 48px;
  }

  #modal-profile-settings .profile-inline-form-actions {
    flex-direction: column;
  }

  #modal-profile-settings .profile-inline-form-actions button {
    width: 100%;
    min-height: 44px;
  }

  #modal-profile-settings .profile-field input,
  #modal-profile-settings .profile-field textarea,
  #modal-profile-settings .profile-field select,
  #modal-profile-settings .profile-section-select {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  #modal-profile-settings .profile-drawer-header-actions [data-lang-switcher] {
    display: none;
  }
}

/* ——— Formes & blocs (inchangés) ——— */

#modal-profile-settings .profile-community-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid #f3f4f6;
}

#modal-profile-settings .profile-community-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #203a7c, #80348a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

#modal-profile-settings .profile-community-info {
  flex: 1;
  min-width: 0;
}

#modal-profile-settings .profile-community-name {
  font-weight: 600;
  font-size: 14px;
}

#modal-profile-settings .profile-community-meta {
  font-size: 12px;
  color: #6b7280;
}

#modal-profile-settings .profile-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

#modal-profile-settings .profile-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #203a7c, #80348a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

#modal-profile-settings .profile-photo-link {
  border: none;
  background: none;
  color: #203a7c;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

#modal-profile-settings .profile-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

#modal-profile-settings .profile-field {
  margin-bottom: 16px;
}

#modal-profile-settings .profile-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

#modal-profile-settings .profile-field input,
#modal-profile-settings .profile-field textarea,
#modal-profile-settings .profile-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

#modal-profile-settings .profile-field textarea {
  min-height: 88px;
  resize: vertical;
}

#modal-profile-settings .profile-char-count {
  font-size: 12px;
  color: #9ca3af;
  text-align: right;
  margin-top: 4px;
}

#modal-profile-settings .profile-btn-primary {
  background: linear-gradient(90deg, #203a7c, #80348a);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

#modal-profile-settings .profile-btn-outline {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

#modal-profile-settings .profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

#modal-profile-settings .profile-stat-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

#modal-profile-settings .profile-stat-card label {
  font-size: 11px;
  color: #6b7280;
  display: block;
  margin-bottom: 4px;
}

#modal-profile-settings .profile-stat-card strong {
  font-size: 18px;
}

#modal-profile-settings .profile-stat-card strong.green {
  color: #16a34a;
}

#modal-profile-settings .profile-invite-row {
  display: flex;
  gap: 8px;
}

#modal-profile-settings .profile-invite-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
}

#modal-profile-settings .profile-empty {
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
  background: #f9fafb;
  border-radius: 10px;
}

#modal-profile-settings .profile-account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #f3f4f6;
  gap: 12px;
}

#modal-profile-settings .profile-inline-form {
  display: none;
  padding: 16px;
  background: #f9fafb;
  border-radius: 10px;
  margin: 12px 0;
}

#modal-profile-settings .profile-inline-form.open {
  display: block;
}

#modal-profile-settings .profile-inline-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

#modal-profile-settings .profile-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

#modal-profile-settings .profile-toggle {
  width: 44px;
  height: 24px;
  accent-color: #203a7c;
}

#modal-profile-settings .profile-chat-community {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

#modal-profile-settings .profile-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
