/* ============================================================================
 * Auth modal (login / register / OAuth).
 * Desktop / tablette : modal centre, max-width 460-500px.
 * Mobile (<=768px)   : carte centree (meme logique que desktop), max-height
 *                      limitee au viewport pour scroll interne si besoin.
 * ============================================================================ */

.zic-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
  animation: zauthFadeIn 0.2s ease-out;
}

.zic-auth-overlay.is-open {
  display: flex;
}

/* L'ancien gate `.zic-auth-overlay { display: none }` a ete retire : la modal
   est dorenavant utilisable sur mobile (cf. plan landing mobile responsive).
   Les regles plein-ecran mobile vivent dans le bloc @media en bas du fichier. */

@keyframes zauthFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes zauthSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.zic-auth-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 10px 30px rgba(109, 40, 217, 0.18);
  animation: zauthSlideUp 0.28s cubic-bezier(.2,.9,.3,1.2);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1A0A3D;
  box-sizing: border-box;
}

@media (min-width: 1025px) {
  .zic-auth-card { max-width: 500px; padding: 32px; }
}

.zic-auth-card *, .zic-auth-card *::before, .zic-auth-card *::after { box-sizing: border-box; }

.zic-auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.zic-auth-tabs {
  display: inline-flex;
  background: #F7F8FC;
  border: 1px solid #E0E5F0;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.zic-auth-tab {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #8E95A9;
  font-family: inherit;
  transition: background 0.18s ease, color 0.18s ease;
}

.zic-auth-tab.is-active {
  background: #6D28D9;
  color: #fff;
}

.zic-auth-close {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2D3142;
  transition: background 0.15s ease;
}

.zic-auth-close:hover { background: #F2F0F8; }

.zic-auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.zic-auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zic-auth-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #5A6178;
  letter-spacing: 0.02em;
}

.zic-auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #F7F8FC;
  border: 1.5px solid #E0E5F0;
  border-radius: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.zic-auth-input-wrap:focus-within {
  border-color: #6D28D9;
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.12);
}

.zic-auth-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-size: 15px;
  color: #1A0A3D;
  font-family: inherit;
  min-width: 0;
}

.zic-auth-suffix {
  padding-right: 14px;
  font-size: 14px;
  color: #8E95A9;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
}

.zic-auth-toggle {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0 14px;
  height: 100%;
  cursor: pointer;
  color: #8E95A9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zic-auth-toggle:hover { color: #6D28D9; }

.zic-auth-error {
  min-height: 18px;
  font-size: 12.5px;
  color: #DC2626;
  margin-top: -4px;
}

/* Password strength meter */
.zic-pw-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.zic-pw-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: #E0E5F0;
  overflow: hidden;
}

.zic-pw-bar-fill {
  height: 100%;
  width: 0%;
  background: #DC2626;
  transition: width 0.2s ease, background 0.2s ease;
}

.zic-pw-label {
  font-size: 12px;
  font-weight: 600;
  color: #8E95A9;
  min-width: 64px;
  text-align: right;
}

.zic-pw-rules {
  background: #F7F8FC;
  border: 1px solid #E0E5F0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zic-pw-rules-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #5A6178;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.zic-pw-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: #8E95A9;
  transition: color 0.18s ease;
}

.zic-pw-rule .zic-pw-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #BFC4D1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.zic-pw-rule .zic-pw-check svg { opacity: 0; }

.zic-pw-rule.is-valid {
  color: #16A34A;
  text-decoration: line-through;
}

.zic-pw-rule.is-valid .zic-pw-check {
  background: #16A34A;
  border-color: #16A34A;
}

.zic-pw-rule.is-valid .zic-pw-check svg { opacity: 1; }

/* Terms checkbox */
.zic-auth-terms {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #5A6178;
  line-height: 1.45;
}

.zic-auth-terms input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid #BFC4D1;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  margin-top: 1px;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.zic-auth-terms input[type="checkbox"]:checked {
  background: #6D28D9;
  border-color: #6D28D9;
}

.zic-auth-terms input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px; left: 6px;
  width: 4px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.zic-auth-terms a { color: #6D28D9; font-weight: 600; text-decoration: underline; }

/* Submit button */
.zic-auth-submit {
  appearance: none;
  border: none;
  background: #6D28D9;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.18s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
}

.zic-auth-submit:hover:not(:disabled) { background: #5B21B6; }
.zic-auth-submit:active:not(:disabled) { transform: translateY(1px); }

.zic-auth-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.zic-auth-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: zauthSpin 0.8s linear infinite;
}

@keyframes zauthSpin { to { transform: rotate(360deg); } }

/* Divider */
.zic-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
}

.zic-auth-divider::before,
.zic-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #E0E5F0;
}

.zic-auth-divider span {
  font-size: 12.5px;
  color: #8E95A9;
}

/* OAuth grid */
.zic-oauth-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (min-width: 1025px) {
  .zic-oauth-grid { grid-template-columns: repeat(6, 1fr); }
}

.zic-oauth-btn {
  appearance: none;
  border: 1px solid #E0E5F0;
  background: #F7F8FC;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.zic-oauth-btn:hover:not(:disabled) {
  background: #fff;
  border-color: #6D28D9;
  transform: translateY(-1px);
}

.zic-oauth-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.zic-oauth-btn img { width: 26px; height: 26px; display: block; }

/* OAuth-in-progress overlay over the modal */
.zic-auth-busy {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.94);
  border-radius: inherit;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  z-index: 2;
}

.zic-auth-busy.is-open { display: flex; }

.zic-auth-busy-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 320px;
}

.zic-auth-busy-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(109, 40, 217, 0.18);
  border-top-color: #6D28D9;
  animation: zauthSpin 0.85s linear infinite;
}

.zic-auth-busy-title {
  font-size: 15px;
  font-weight: 700;
  color: #2D3142;
}

.zic-auth-busy-hint {
  font-size: 13px;
  color: #8E95A9;
  line-height: 1.45;
}

.zic-auth-busy-cancel {
  appearance: none;
  border: none;
  background: transparent;
  color: #6D28D9;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
}

.zic-auth-busy-cancel:hover { background: #F5F0FF; }

/* Top alert (errors / success) */
.zic-auth-alert {
  display: none;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.zic-auth-alert.is-error {
  display: block;
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.zic-auth-alert.is-success {
  display: block;
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #86EFAC;
}

/* Nav user menu (when logged in) */
.zic-user-menu {
  position: relative;
}

.zic-user-menu-trigger {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6D28D9;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid rgba(255,255,255,0.25);
}

.zic-user-menu-trigger img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

.zic-user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 130;
}

.zic-user-menu.is-open .zic-user-menu-panel { display: flex; }

.zic-user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #1A0A3D;
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
}

.zic-user-menu-item:hover { background: #F5F0FF; color: #6D28D9; }

.zic-user-menu-header {
  padding: 12px 12px 10px;
  border-bottom: 1px solid #F2F0F8;
  margin-bottom: 4px;
}

.zic-user-menu-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #2D3142;
}

.zic-user-menu-handle {
  font-size: 12px;
  color: #8E95A9;
  margin-top: 2px;
}

/* ============================================================================
   Auth modal — Mobile (<=768px) : carte centree (pas plein ecran), avec
   marges safe-area et hauteur max pour scroll interne si inscription longue.
   ============================================================================ */

@media (max-width: 768px) {
  .zic-auth-overlay {
    padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
    align-items: center;
    justify-content: center;
  }

  .zic-auth-card {
    width: 100%;
    max-width: min(460px, calc(100vw - 32px));
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    height: auto;
    border-radius: 20px;
    padding: 22px 20px 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 10px 30px rgba(109, 40, 217, 0.18);
    animation: zauthSlideUp 0.28s cubic-bezier(.2, 0.9, 0.3, 1.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .zic-auth-header {
    position: relative;
    top: auto;
    margin: 0 0 20px;
    padding: 0;
    background: transparent;
    border-bottom: none;
  }

  .zic-auth-tabs {
    flex: 1;
    justify-content: center;
  }
  .zic-auth-tab {
    flex: 1;
    text-align: center;
    min-height: 44px;
  }
  .zic-auth-close {
    width: 44px;
    height: 44px;
  }

  .zic-auth-form {
    gap: 14px;
  }

  .zic-auth-input {
    /* iOS evite le zoom auto sur focus si font-size >= 16px sur l'input. */
    font-size: 16px;
    padding: 14px;
    min-height: 48px;
  }

  .zic-auth-submit {
    width: 100%;
    min-height: 52px;
    margin-top: 8px;
  }

  .zic-oauth-grid {
    gap: 8px;
  }
  .zic-oauth-btn {
    padding: 14px;
    min-height: 56px;
  }

  .zic-pw-rules {
    padding: 10px 12px;
  }

  .zic-auth-busy {
    border-radius: inherit;
  }
}
