/* ============================================================
   AG Account popup — ONE centred dialog for the whole public site.
   Replaces the old Mi Cuenta side panel (index.html) and the ad-hoc
   modal that cursos.html built inline, so the login, the sign-up, the
   password recovery and the "which email did I use?" flow all look and
   behave identically wherever the visitor happens to be.

   Theming: the site's dark mode is `body.dark` (script.js:92, shop.js:265)
   driven by localStorage `ag_theme`. Every colour below is a token that
   `body.dark` redefines, which is what fixes the old modal rendering as a
   solid white sheet on a dark page.
   ============================================================ */

:root {
    --agp-sheet:      #ffffff;
    --agp-sheet-alt:  #f7f5fb;
    --agp-ink:        #1a1030;
    --agp-ink-soft:   #555068;
    --agp-ink-faint:  #8c839e;
    --agp-line:       #e5e1ef;
    --agp-line-soft:  #efecf6;
    --agp-field:      #ffffff;
    --agp-accent:     #9b59b6;
    --agp-accent-2:   #a8e063;
    --agp-danger:     #d63031;
    --agp-danger-bg:  rgba(214, 48, 49, 0.08);
    --agp-scrim:      rgba(15, 10, 26, 0.72);
    --agp-shadow:     0 28px 80px rgba(26, 16, 48, 0.30);
}

body.dark {
    --agp-sheet:      #191330;
    --agp-sheet-alt:  #221a3d;
    --agp-ink:        #f0ecf8;
    --agp-ink-soft:   #c4bdd8;
    --agp-ink-faint:  #9990b0;
    --agp-line:       #332a52;
    --agp-line-soft:  #2a2245;
    --agp-field:      #221a3d;
    --agp-accent:     #c39bd3;
    --agp-accent-2:   #a8e063;
    --agp-danger:     #ff7675;
    --agp-danger-bg:  rgba(255, 118, 117, 0.12);
    --agp-scrim:      rgba(5, 3, 12, 0.80);
    --agp-shadow:     0 28px 80px rgba(0, 0, 0, 0.60);
}

/* ---------- scrim + sheet ---------- */
.agp-scrim {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: var(--agp-scrim);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.22s ease;
}
.agp-scrim.agp-in { opacity: 1; }

.agp-sheet {
    position: relative;
    width: min(520px, 100%);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    background: var(--agp-sheet);
    color: var(--agp-ink);
    border-radius: 22px;
    box-shadow: var(--agp-shadow);
    padding: 30px 28px 26px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transform: translateY(14px) scale(0.98);
    transition: transform 0.24s cubic-bezier(0.34, 1.3, 0.5, 1);
}
.agp-scrim.agp-in .agp-sheet { transform: none; }
.agp-sheet.agp-wide { width: min(620px, 100%); }

.agp-close {
    position: absolute;
    top: 13px;
    right: 13px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--agp-sheet-alt);
    color: var(--agp-ink-faint);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.agp-close:hover { background: var(--agp-accent); color: #fff; }

/* ---------- header ---------- */
.agp-head { text-align: center; margin-bottom: 18px; }
.agp-badge {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agp-accent-2), var(--agp-accent));
    color: #fff;
    font-size: 1.45rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(155, 89, 182, 0.35);
}
.agp-head h2 { margin: 0; font-size: 1.22rem; font-weight: 800; color: var(--agp-ink); line-height: 1.3; }
.agp-head p  { margin: 6px 0 0; font-size: 0.83rem; color: var(--agp-ink-faint); line-height: 1.5; }

/* ---------- tabs ---------- */
.agp-tabs {
    display: flex;
    border-bottom: 1px solid var(--agp-line);
    margin-bottom: 18px;
}
.agp-tab {
    flex: 1;
    padding: 11px 8px;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--agp-ink-faint);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.agp-tab:hover { color: var(--agp-ink-soft); }
.agp-tab.agp-on { color: var(--agp-accent); border-bottom-color: var(--agp-accent); }

/* ---------- fields ---------- */
.agp-field { margin-bottom: 13px; text-align: left; }
.agp-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}
.agp-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--agp-ink-faint);
    margin-bottom: 5px;
}
.agp-field input,
.agp-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--agp-line);
    border-radius: 11px;
    background: var(--agp-field);
    color: var(--agp-ink);
    font: inherit;
    font-size: 0.92rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* iOS zooms the page when a focused field is under 16px */
    -webkit-appearance: none;
    appearance: none;
}
.agp-field select {
    /* the arrow, drawn so it never inherits an OS light-mode chevron */
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238c839e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 11px;
    padding-right: 34px;
}
.agp-field input:focus,
.agp-field select:focus {
    outline: none;
    border-color: var(--agp-accent);
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.16);
}
.agp-field input::placeholder { color: var(--agp-ink-faint); opacity: 0.75; }
.agp-field input:disabled,
.agp-field select:disabled { opacity: 0.5; cursor: not-allowed; }
.agp-field input[type="date"] { min-height: 43px; }
body.dark .agp-field input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }

.agp-hint { font-size: 0.72rem; color: var(--agp-ink-faint); margin: 4px 0 0; line-height: 1.45; }

/* password reveal */
.agp-pw-wrap { position: relative; }
.agp-pw-wrap input { padding-right: 42px; }
.agp-pw-eye {
    position: absolute;
    top: 50%; right: 8px;
    transform: translateY(-50%);
    background: none; border: 0;
    color: var(--agp-accent);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

/* ---------- buttons ---------- */
.agp-btn {
    width: 100%;
    padding: 13px 20px;
    border: 0;
    border-radius: 13px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
}
.agp-btn:disabled { opacity: 0.6; cursor: progress; }
.agp-btn-primary {
    background: linear-gradient(135deg, var(--agp-accent), var(--agp-accent-2));
    color: #fff;
    box-shadow: 0 8px 22px rgba(155, 89, 182, 0.30);
}
.agp-btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(155, 89, 182, 0.38); }
.agp-btn-ghost {
    background: var(--agp-sheet-alt);
    color: var(--agp-ink-soft);
    border: 1px solid var(--agp-line);
}
.agp-btn-ghost:not(:disabled):hover { border-color: var(--agp-accent); color: var(--agp-accent); }
.agp-btn-google {
    background: var(--agp-sheet);
    color: var(--agp-ink);
    border: 1px solid var(--agp-line);
}
.agp-btn-google:hover { border-color: var(--agp-accent); }

.agp-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--agp-accent);
    cursor: pointer;
    text-decoration: none;
}
.agp-link:hover { text-decoration: underline; }
.agp-linkrow { text-align: center; margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }

/* ---------- divider ---------- */
.agp-or {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 16px 0;
    color: var(--agp-ink-faint);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.agp-or::before, .agp-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--agp-line);
}

/* ---------- messages ---------- */
.agp-err {
    margin: 0 0 11px;
    min-height: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--agp-danger);
    text-align: left;
    line-height: 1.5;
}
.agp-err:empty { display: none; }
.agp-ok {
    margin: 0 0 11px;
    padding: 10px 13px;
    border-radius: 11px;
    background: rgba(0, 184, 148, 0.12);
    color: #00b894;
    font-size: 0.83rem;
    font-weight: 700;
    line-height: 1.5;
}
.agp-ok:empty { display: none; }

/* The disclaimer the owner wants read BEFORE any data is typed.
   Red, prominent, and never collapsed away. */
.agp-legal-red {
    margin: 0 0 14px;
    padding: 13px 15px;
    border: 1.5px solid var(--agp-danger);
    border-radius: 12px;
    background: var(--agp-danger-bg);
    color: var(--agp-danger);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.6;
    text-align: left;
}

.agp-terms-box {
    max-height: 210px;
    overflow-y: auto;
    padding: 14px 16px;
    margin-bottom: 14px;
    border: 1px solid var(--agp-line);
    border-radius: 12px;
    background: var(--agp-sheet-alt);
    color: var(--agp-ink-soft);
    font-size: 0.79rem;
    line-height: 1.65;
    text-align: left;
}
.agp-terms-box h4 {
    margin: 0 0 6px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--agp-accent);
}
/* styles.css resets list-style globally, which swallowed the bullets here. */
.agp-terms-box ul { margin: 0 0 10px; padding-left: 20px; list-style: disc outside; }
.agp-terms-box li { margin-bottom: 5px; }
.agp-terms-box p:last-child { margin-bottom: 0; }

.agp-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 0.83rem;
    line-height: 1.5;
    color: var(--agp-ink-soft);
    text-align: left;
    cursor: pointer;
}
.agp-check input {
    width: 19px; height: 19px;
    margin: 1px 0 0;
    flex-shrink: 0;
    accent-color: var(--agp-accent);
    cursor: pointer;
}

/* ---------- step indicator for the recovery flow ---------- */
.agp-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-bottom: 16px;
}
.agp-step {
    width: 26px; height: 5px;
    border-radius: 3px;
    background: var(--agp-line);
    transition: background 0.25s;
}
.agp-step.agp-on { background: var(--agp-accent); }

/* ---------- masked-email candidate list ---------- */
.agp-cand {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 9px;
    border: 1px solid var(--agp-line);
    border-radius: 12px;
    background: var(--agp-sheet-alt);
    color: var(--agp-ink);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}
.agp-cand:hover { border-color: var(--agp-accent); transform: translateX(2px); }
.agp-cand span { display: block; font-size: 0.74rem; font-weight: 600; color: var(--agp-ink-faint); margin-top: 3px; }

/* ---------- phone / narrow ---------- */
@media (max-width: 560px) {
    .agp-scrim { padding: 0; align-items: flex-end; }
    .agp-sheet {
        width: 100%;
        max-height: 94vh;
        border-radius: 22px 22px 0 0;
        padding: 26px 18px 22px;
        transform: translateY(26px);
    }
    .agp-row { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .agp-scrim, .agp-sheet, .agp-btn { transition: none; }
    .agp-sheet { transform: none; }
}
