/* ================================================================
   Astra Modal Login + Account Dropdown  –  modal-login.css  v1.1
   Place in: child-theme/modal-login/modal-login.css
   ================================================================ */

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  --aml-accent:       #2563eb;
  --aml-accent-hover: #1d4ed8;
  --aml-surface:      #ffffff;
  --aml-bg:           #f8fafc;
  --aml-border:       #e2e8f0;
  --aml-text:         #0f172a;
  --aml-muted:        #64748b;
  --aml-error:        #dc2626;
  --aml-success:      #16a34a;
  --aml-radius:       14px;
  --aml-shadow:       0 20px 60px -10px rgba(0,0,0,.22), 0 4px 20px rgba(0,0,0,.08);
  --aml-overlay-bg:   rgba(15,23,42,.55);
  --aml-transition:   .18s cubic-bezier(.4,0,.2,1);
}

/* ── Overlay ─────────────────────────────────────────────── */
.aml-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--aml-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--aml-transition);
}
.aml-overlay:not([hidden]) { opacity: 1; }
.aml-overlay[hidden]       { display: none !important; }

/* ── Modal card ──────────────────────────────────────────── */
.aml-modal {
  background: var(--aml-surface);
  border-radius: var(--aml-radius);
  box-shadow: var(--aml-shadow);
  padding: 2.5rem 2.25rem 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  transform: translateY(24px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
  opacity: 0;
}
.aml-overlay:not([hidden]) .aml-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── Close button ────────────────────────────────────────── */
.aml-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--aml-bg);
  color: var(--aml-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--aml-transition), color var(--aml-transition);
}
.aml-close:hover { background: var(--aml-border); color: var(--aml-text); }

/* ── Brand / Logo ────────────────────────────────────────── */
.aml-brand {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}
.aml-brand img  { max-height: 48px; width: auto; }
.aml-site-name  { font-size: 1.1rem; font-weight: 700; color: var(--aml-text); letter-spacing: -.02em; }

/* ── Headings ────────────────────────────────────────────── */
.aml-heading {
  font-size: 1.5rem; font-weight: 700;
  color: var(--aml-text); letter-spacing: -.03em;
  margin: 0 0 .25rem; text-align: center;
}
.aml-sub { color: var(--aml-muted); font-size: .875rem; text-align: center; margin: 0 0 1.5rem; }

/* ── Message bar ─────────────────────────────────────────── */
.aml-message {
  border-radius: 8px;
  padding: .75rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
}
.aml-message[hidden]  { display: none; }
.aml-message.is-error   { background: #fef2f2; color: var(--aml-error);   border: 1px solid #fecaca; }
.aml-message.is-success { background: #f0fdf4; color: var(--aml-success); border: 1px solid #bbf7d0; }

/* ── Form fields ─────────────────────────────────────────── */
.aml-form { display: flex; flex-direction: column; gap: 1rem; }
.aml-field { display: flex; flex-direction: column; gap: .4rem; position: relative; }
.aml-field label { font-size: .8125rem; font-weight: 600; color: var(--aml-text); letter-spacing: .01em; }
.aml-field input[type="text"],
.aml-field input[type="password"] {
  width: 100%;
  padding: .65rem .85rem;
  border: 1.5px solid var(--aml-border);
  border-radius: 9px;
  font-size: .9375rem;
  color: var(--aml-text);
  background: var(--aml-bg);
  outline: none;
  transition: border-color var(--aml-transition), box-shadow var(--aml-transition);
  box-sizing: border-box;
}
.aml-field input:focus {
  border-color: var(--aml-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.aml-field--password input { padding-right: 2.75rem; }

.aml-toggle-pw {
  position: absolute; right: .6rem; bottom: .6rem;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--aml-muted);
  border-radius: 5px;
  transition: color var(--aml-transition);
}
.aml-toggle-pw:hover { color: var(--aml-text); }
.aml-eye { width: 18px; height: 18px; }

/* ── Remember + Forgot row ───────────────────────────────── */
.aml-row  { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.aml-remember {
  display: flex; align-items: center; gap: .45rem;
  font-size: .8125rem; color: var(--aml-muted);
  cursor: pointer; user-select: none;
}
.aml-remember input { accent-color: var(--aml-accent); cursor: pointer; }
.aml-lost-pw {
  font-size: .8125rem; color: var(--aml-accent);
  text-decoration: none;
  transition: color var(--aml-transition);
}
.aml-lost-pw:hover { color: var(--aml-accent-hover); text-decoration: underline; }

/* ── Submit button ───────────────────────────────────────── */
.aml-btn {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; padding: .75rem 1.25rem;
  background: var(--aml-accent); color: #fff;
  border: none; border-radius: 10px;
  font-size: .9375rem; font-weight: 600; letter-spacing: .01em;
  cursor: pointer;
  transition: background var(--aml-transition), transform var(--aml-transition), box-shadow var(--aml-transition);
  margin-top: .25rem;
}
.aml-btn:hover   { background: var(--aml-accent-hover); box-shadow: 0 4px 14px rgba(37,99,235,.35); transform: translateY(-1px); }
.aml-btn:active  { transform: translateY(0); }
.aml-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; box-shadow: none; }

.aml-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aml-spin .7s linear infinite;
}
.aml-spinner[hidden] { display: none; }
@keyframes aml-spin { to { transform: rotate(360deg); } }

/* ── Register link ───────────────────────────────────────── */
.aml-register { text-align: center; font-size: .8125rem; color: var(--aml-muted); margin-top: 1.25rem; }
.aml-register a { color: var(--aml-accent); font-weight: 600; text-decoration: none; }
.aml-register a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   ASTRA ACCOUNT ICON — intercept styling
   We keep Astra's own icon visible and just make it
   position:relative so the dropdown can anchor to it.
   ══════════════════════════════════════════════════════════ */

/* Make the Astra account wrap the dropdown anchor point */
.ast-header-account { position: relative !important; }
.ast-header-account-wrap {
  position: relative !important;
  cursor: pointer;
}

/* Visual cue: glow accent ring when dropdown is open */
.ast-header-account-wrap.aml-is-open .ast-header-account-link {
  color: var(--aml-accent) !important;
}

/* ══════════════════════════════════════════════════════════
   DROPDOWN WRAP + PANEL
   ══════════════════════════════════════════════════════════ */
.aml-dropdown-wrap {
  /* injected into .ast-header-account-wrap by JS */
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 99998;
}

.aml-dropdown {
  min-width: 240px;
  background: var(--aml-surface);
  border: 1px solid var(--aml-border);
  border-radius: var(--aml-radius);
  box-shadow: var(--aml-shadow);
  overflow: hidden;
  transform-origin: top right;
  transform: scale(.95) translateY(-6px);
  opacity: 0;
  transition: transform var(--aml-transition), opacity var(--aml-transition);
}
.aml-dropdown:not([hidden]) { transform: scale(1) translateY(0); opacity: 1; }
.aml-dropdown[hidden]       { display: none; }

/* Dropdown header — avatar + name */
.aml-dropdown-header {
  padding: .9rem 1rem .8rem;
  border-bottom: 1px solid var(--aml-border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.aml-dropdown-avatar {
  position: relative;
  flex-shrink: 0;
  width: 38px; height: 38px;
}
.aml-dropdown-avatar img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--aml-border);
  display: block;
}
.aml-avatar-fallback-sm {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--aml-accent);
  color: #fff;
  font-size: .9rem; font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
}
.aml-dropdown-header > div { min-width: 0; }
.aml-dropdown-header strong {
  display: block;
  font-size: .875rem; font-weight: 700; color: var(--aml-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aml-dropdown-header span {
  display: block;
  font-size: .75rem; color: var(--aml-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Dropdown list */
.aml-dropdown-list { list-style: none; margin: 0; padding: .4rem; }
.aml-dropdown-list li a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  font-size: .875rem; font-weight: 500;
  color: var(--aml-text) !important;
  text-decoration: none !important;
  transition: background var(--aml-transition), color var(--aml-transition);
  white-space: nowrap;
}
.aml-dropdown-list li a:hover {
  background: var(--aml-bg);
  color: var(--aml-accent) !important;
}
.aml-dropdown-list li a svg {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--aml-muted);
  transition: color var(--aml-transition);
}
.aml-dropdown-list li a:hover svg { color: var(--aml-accent); }

.aml-dropdown-divider {
  height: 0;
  border: none;
  border-top: 1px solid var(--aml-border);
  margin: .35rem .75rem;
}

a.aml-logout        { color: var(--aml-error) !important; }
a.aml-logout svg    { color: var(--aml-error) !important; }
a.aml-logout:hover  { background: #fef2f2 !important; color: var(--aml-error) !important; }

/* ── Focus-visible rings ─────────────────────────────────── */
.aml-btn:focus-visible,
.aml-close:focus-visible,
.ast-header-account-wrap:focus-visible {
  outline: 2.5px solid var(--aml-accent);
  outline-offset: 2px;
}

/* ── Responsive: bottom-sheet on mobile ──────────────────── */
@media (max-width: 600px) {
  .aml-modal {
    padding: 2rem 1.25rem 1.75rem;
    border-radius: 18px 18px 0 0;
    max-width: 100%;
    margin-bottom: 0;
    align-self: flex-end;
  }
  .aml-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .aml-dropdown-wrap {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  .aml-dropdown { min-width: 220px; }
}
