/* ==========================================================================
   Vista del cliente · diseño profesional y responsive
   ========================================================================== */

body.client-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    background:
        radial-gradient(900px 520px at 90% -10%, rgba(233, 87, 63, .30), transparent 60%),
        radial-gradient(760px 520px at -10% 110%, rgba(59, 99, 180, .38), transparent 60%),
        #14213a;
}

.client-card {
    width: min(480px, 100%);
    padding: 38px 34px 30px;
    border: 0;
    border-radius: 22px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .40), 0 2px 0 rgba(255, 255, 255, .5) inset;
    animation: card-in .45s cubic-bezier(.2, .7, .2, 1) both;
}

.client-card [hidden] { display: none !important; }

/* ---------- Cabecera ---------- */

.client-card .brand { justify-content: center; margin-bottom: 26px; font-size: 19px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }

.client-card .eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #fdece8;
    color: #d04a34;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.3px;
    text-transform: uppercase;
}

.client-card h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.15; letter-spacing: -.5px; }
.request-head h1 { margin: 0; font-size: 24px; }
.client-card > p, .client-card form + p { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.client-card p strong { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Insignia de estado (en vivo) ---------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 16px;
    padding: 6px 13px;
    border-radius: 999px;
    background: #fdece8;
    color: #d04a34;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    transition: background .2s, color .2s;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse-dot 1.6s ease-out infinite; }

.status-pill[data-state="ready"] { background: #e0f4e9; color: #17694a; }
.status-pill[data-state="used"] { background: #eef1f6; color: #667085; }
.status-pill[data-state="ready"] .status-dot, .status-pill[data-state="used"] .status-dot, .status-pill[data-state="expired"] .status-dot { animation: none; }
.status-pill[data-state="expired"] { background: #fbe4e2; color: #c0392b; }

/* ---------- Identidad de la plataforma ---------- */

.request-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 4px; }

.request-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    color: #fff;
    font: 700 20px 'Space Grotesk', sans-serif;
    font-style: normal;
    box-shadow: 0 6px 14px rgba(20, 33, 58, .18);
}

.request-icon.has-img { overflow: hidden; background: transparent !important; box-shadow: none; }
.request-icon.has-img img { width: 100%; height: 100%; object-fit: contain; }

.request-email { display: block; margin-top: 3px; color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }

/* ---------- Membresía del cliente (días restantes) ---------- */

.membership {
    --m: #1f8a5b;
    --m-soft: #e3f5ec;
    margin: 18px 0 4px;
    padding: 16px 18px;
    border: 1px solid color-mix(in srgb, var(--m) 28%, #fff);
    border-radius: 16px;
    background: linear-gradient(180deg, #fff, var(--m-soft));
    text-align: left;
    animation: card-in .4s ease both;
}
.membership.is-warn { --m: #c47a10; --m-soft: #fff4dc; }
.membership.is-over { --m: #c0392b; --m-soft: #fbe4e2; }

.membership-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.membership-title { color: var(--ink); font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.membership-title small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.membership-days { flex: none; color: var(--m); font-size: 13px; font-weight: 700; text-align: right; white-space: nowrap; }
.membership-days b { font: 700 30px/1 'Space Grotesk', sans-serif; letter-spacing: -.5px; }

.membership-bar { height: 8px; margin: 12px 0 10px; overflow: hidden; border-radius: 999px; background: rgba(20, 33, 58, .08); }
.membership-bar span { display: block; height: 100%; border-radius: inherit; background: var(--m); transition: width .6s ease; }

.membership-foot { display: block; margin-top: 10px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.membership-bar + .membership-foot { margin-top: 0; }
.membership-foot strong { color: var(--m); font-weight: 700; }

/* ---------- Formulario ---------- */

.client-card form { display: flex; flex-direction: column; gap: 18px; text-align: left; }
.client-card .field label { font-size: 13px; font-weight: 700; color: #34405a; }

.client-card .field input[type="email"] {
    width: 100%;
    padding: 14px 15px;
    border: 1.5px solid #d5dae3;
    border-radius: 12px;
    background: #fff;
    font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}

.client-card .field input[type="email"]:focus {
    outline: none;
    border-color: var(--coral);
    box-shadow: 0 0 0 4px rgba(233, 87, 63, .15);
}

.client-card .btn { min-height: 48px; border-radius: 12px; font-size: 15px; }
.client-card .btn-primary { background: linear-gradient(135deg, #f0654b, #e04a31); box-shadow: 0 8px 20px rgba(233, 87, 63, .32); }
.client-card .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(233, 87, 63, .38); }
.client-card .btn-primary:active { transform: translateY(0); }
.client-card .btn:focus-visible { outline: 3px solid rgba(20, 33, 58, .35); outline-offset: 2px; }

.client-card .hint { margin: 20px 0 0; color: #8a94a6; font-size: 12.5px; text-align: center; }
.client-card .alert { margin: 0 0 18px; text-align: left; border-radius: 12px; line-height: 1.5; }

/* Aviso de error: se puede cerrar y se desvanece al corregir (ver cliente.php). */
.client-alert { display: flex; align-items: flex-start; gap: 10px; max-height: 240px; overflow: hidden; animation: card-in .3s ease both; transition: opacity .3s, max-height .3s, margin .3s, padding .3s; }
.client-alert > span { flex: 1; }
.client-alert-close { flex: none; width: 26px; height: 26px; margin: -3px -6px -3px 0; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .7; }
.client-alert-close:hover { background: rgba(192, 57, 43, .1); opacity: 1; }
.client-alert.is-leaving { opacity: 0; max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }

/* Campo con el dato equivocado: borde rojo hasta que el cliente lo corrige. */
.client-card .field.is-invalid input,
.client-card .field.is-invalid input:focus { border-color: #c0392b; background: #fffafa; box-shadow: 0 0 0 4px rgba(192, 57, 43, .12); outline: none; }
.client-card .field.is-invalid .platform-option span { border-color: #e7b7b1; }
.client-card .field.is-invalid > label { color: #c0392b; }

/* ---------- Selector de plataforma ---------- */

/* Flexbox en vez de grid: con 2, 3, 4 o más plataformas (son dinámicas), la última
   fila se centra sola en vez de dejar un hueco vacío. */
.platform-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.platform-option { position: relative; flex: 1 1 90px; max-width: 130px; cursor: pointer; }
.platform-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }

.platform-option span {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 16px 6px 13px;
    border: 2px solid #e3e7ee;
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}

.platform-option:hover span { border-color: #c9d0dc; transform: translateY(-2px); }

.platform-option i {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    color: #fff;
    font: 700 20px 'Space Grotesk', sans-serif;
    font-style: normal;
    box-shadow: 0 6px 14px rgba(20, 33, 58, .18);
}

.platform-option i.has-img { overflow: hidden; background: transparent; box-shadow: none; }
.platform-option i.has-img img { width: 100%; height: 100%; object-fit: contain; }

.platform-option input:checked + span { border-color: var(--coral); background: #fff8f6; box-shadow: 0 0 0 4px rgba(233, 87, 63, .14); }

.platform-option input:checked + span::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--coral) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 11px no-repeat;
}

.platform-option input:focus-visible + span { outline: 3px solid rgba(20, 33, 58, .4); outline-offset: 2px; }

/* ---------- Pasos ---------- */

.steps { display: flex; margin: 24px 0 8px; padding: 0; list-style: none; color: var(--muted); font-size: 12px; text-align: center; }
.steps li { position: relative; flex: 1; padding-top: 24px; }
.steps li::before { content: ''; position: absolute; top: 0; left: 50%; width: 16px; height: 16px; transform: translateX(-50%); border-radius: 50%; background: #d6dbe4; z-index: 1; }
.steps li::after { content: ''; position: absolute; top: 7px; left: calc(-50% + 10px); width: calc(100% - 20px); height: 2px; background: #d6dbe4; }
.steps li:first-child::after { display: none; }
.steps li.done { color: var(--green); font-weight: 600; }
.steps li.done::before, .steps li.done::after { background: var(--green); }
.steps li.active { color: var(--ink); font-weight: 700; }
.steps li.active::before { background: var(--coral); box-shadow: 0 0 0 5px rgba(233, 87, 63, .22); }

/* ---------- Espera ---------- */

.waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 20px 0 14px;
    padding: 28px 16px;
    border: 1px solid #e6eaf1;
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fafc, #f1f4f9);
    text-align: center;
}

.waiting strong { font-size: 16px; }
.waiting small { color: var(--muted); line-height: 1.5; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--coral); animation: pulse 1.6s ease-out infinite; }

.request-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: #eef1f6;
    color: var(--muted);
    font-size: 13px;
}

.request-timer strong { color: var(--ink); font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-variant-numeric: tabular-nums; }
#view-waiting { text-align: center; }
#view-waiting .hint { margin: 12px 0 16px; }

/* ---------- Código listo ---------- */

.client-code {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 22px 0 14px;
    padding: 26px 18px;
    border: 1px solid #bfe6d1;
    border-radius: 18px;
    background: linear-gradient(180deg, #edf9f2, #e0f4e9);
    color: #17694a;
    animation: card-in .4s ease both;
}

.client-code span { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.client-code strong { max-width: 100%; font-family: 'Space Grotesk', sans-serif; font-size: 42px; letter-spacing: 6px; line-height: 1.1; user-select: all; overflow-wrap: anywhere; color: #0f5a3d; }
#view-ready .hint { margin: 6px 0 16px; }

.copy-btn { margin-top: 4px; }
.client-new { width: 100%; margin-top: 14px; }
#view-used, #view-expired { margin-top: 18px; }

/* ---------- Pie ---------- */

.client-footer { margin: 0; color: rgba(255, 255, 255, .55); font-size: 12px; text-align: center; }

/* ---------- Animaciones ---------- */

@keyframes card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(233, 87, 63, .55); } 70% { box-shadow: 0 0 0 14px rgba(233, 87, 63, 0); } 100% { box-shadow: 0 0 0 0 rgba(233, 87, 63, 0); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
    .client-card, .client-code, .pulse, .status-dot { animation: none; }
    .platform-option:hover span, .client-card .btn-primary:hover { transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
    body.client-page { justify-content: flex-start; padding-top: 24px; }
    .client-card { padding: 28px 20px 24px; border-radius: 20px; }
    .client-card h1 { font-size: 24px; }
    .client-card .brand { margin-bottom: 20px; }
    .platform-options { gap: 8px; }
    .platform-option { flex-basis: 78px; max-width: 100px; }
    .platform-option span { padding: 13px 4px 11px; font-size: 12px; }
    .platform-option i { width: 40px; height: 40px; font-size: 18px; }
    .client-code strong { font-size: 34px; letter-spacing: 4px; }
    .steps { font-size: 11px; }
}

@media (max-width: 340px) {
    .platform-option { flex-basis: 100%; max-width: none; }
    .platform-option span { flex-direction: row; justify-content: flex-start; padding: 10px 14px; }
    .client-code strong { font-size: 28px; letter-spacing: 3px; }
}

/* ---------- Autenticador (2FA): código que cambia cada 30 s ---------- */

.status-pill[data-state="totp"] { background: #e0f4e9; color: #17694a; }
.status-pill[data-state="totp"] .status-dot, .status-pill[data-state="revoked"] .status-dot { animation: none; }
.status-pill[data-state="revoked"] { background: #fbe4e2; color: #c0392b; }

.totp {
    --t: #17694a;
    --t-strong: #0f5a3d;
    --t-soft: #e0f4e9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 22px 0 14px;
    padding: 22px 18px 20px;
    border: 1px solid #bfe6d1;
    border-radius: 18px;
    background: linear-gradient(180deg, #edf9f2, #e0f4e9);
    color: var(--t);
    text-align: center;
    animation: card-in .4s ease both;
    transition: border-color .3s, background .3s;
}
.totp.is-ending { --t: #9a5b00; --t-strong: #7a4700; border-color: #f1d28f; background: linear-gradient(180deg, #fff9ea, #fff1d2); }
.totp-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.totp-main { display: flex; align-items: center; justify-content: center; gap: 16px; max-width: 100%; }
.totp-code {
    color: var(--t-strong);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 44px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 4px;
    line-height: 1.1;
    white-space: nowrap;
    user-select: all;
    transition: color .3s, opacity .2s;
}
.totp.is-new .totp-code { animation: totp-in .45s ease; }
.totp.is-stale .totp-code { opacity: .4; }
.totp-ring { position: relative; flex: none; width: 50px; height: 50px; }
.totp-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.totp-ring circle { fill: none; stroke-width: 4; }
.totp-ring-bg { stroke: rgba(23, 105, 74, .15); }
.totp-ring-fg { stroke: var(--t); stroke-dasharray: 100; stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; }
.totp-ring b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--t-strong); font: 700 15px 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }
.totp-note { margin: 0; font-size: 13px; font-weight: 600; }
.totp-steps { margin: 4px 0 14px; padding: 14px 16px 14px 34px; border: 1px solid var(--line, #e6e9ef); border-radius: 14px; background: #f8fafc; color: #4a5568; font-size: 13px; line-height: 1.5; text-align: left; }
.totp-steps li + li { margin-top: 6px; }
.totp-steps strong { color: var(--ink, #1b2433); }
#view-totp .request-timer { text-align: center; }
#view-revoked { margin-top: 18px; }

@keyframes totp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .totp, .totp.is-new .totp-code { animation: none; }
    .totp-ring-fg { transition: none; }
}
@media (max-width: 480px) {
    .totp-code { font-size: 36px; letter-spacing: 3px; }
    .totp-main { gap: 12px; }
    .totp-ring { width: 44px; height: 44px; }
}
@media (max-width: 340px) {
    .totp-code { font-size: 30px; letter-spacing: 2px; }
}
/* .login-card p trae margen inferior: dentro de la tarjeta del código no aplica. */
.totp .totp-note { margin: 0; }
.totp .copy-btn { margin-top: 2px; }

/* ---------- Código del correo (junto al del autenticador) ---------- */
.mailcode { --mc: #2f6fdb; margin: 20px 0 0; padding: 14px 16px; border: 1px solid #d6e2f7; border-radius: 16px; background: linear-gradient(180deg, #f6f9ff, #edf3fd); text-align: left; animation: card-in .4s ease both; transition: border-color .3s, background .3s; }
.mailcode + .totp { margin-top: 12px; }
.mailcode-head { display: flex; align-items: center; gap: 8px; color: var(--mc); }
.mailcode-head strong { color: var(--ink); font-size: 13.5px; }
.mailcode-tag { margin-left: auto; padding: 3px 9px; border-radius: 999px; background: rgba(47, 111, 219, .12); color: var(--mc); font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.mailcode-wait { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.mailcode-wait .pulse { flex: none; width: 10px; height: 10px; margin: 0 4px; background: var(--mc); box-shadow: none; animation: mailcode-pulse 1.8s ease-out infinite; }
.client-card .mailcode-wait p { flex: 1; margin: 0; color: #4a5568; font-size: 13px; line-height: 1.45; }
.mailcode-check { flex: none; padding: 8px 12px; border: 1px solid #c9d8f3; border-radius: 10px; background: #fff; color: var(--mc); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: background .15s; }
.mailcode-check:hover:not(:disabled) { background: #f3f7ff; }
.mailcode-check:disabled { opacity: .6; cursor: progress; }
.mailcode-ready { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.mailcode-value { flex: 1; color: #0f5a3d; font: 700 34px/1.15 'Space Grotesk', sans-serif; letter-spacing: 5px; overflow-wrap: anywhere; user-select: all; }
.client-card .mailcode-copy { flex: none; width: auto; min-height: 40px; margin: 0; padding: 0 16px; font-size: 13.5px; }
.client-card .mailcode-used { margin: 8px 0 0; color: #667085; font-size: 13px; }
.mailcode[data-state="ready"] { --mc: #17694a; border-color: #bfe6d1; background: linear-gradient(180deg, #edf9f2, #e0f4e9); }
.mailcode[data-state="ready"] .mailcode-tag { background: rgba(23, 105, 74, .12); }
.mailcode[data-state="used"] { --mc: #667085; border-color: #e3e7ee; background: #f6f7f9; }
.mailcode.is-new { animation: mailcode-in .6s ease 2; }
@keyframes mailcode-pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 111, 219, .5); } 70% { box-shadow: 0 0 0 10px rgba(47, 111, 219, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 111, 219, 0); } }
@keyframes mailcode-in { 50% { box-shadow: 0 0 0 5px rgba(31, 138, 91, .25); } }
@media (max-width: 480px) {
    .mailcode-wait { flex-wrap: wrap; }
    .mailcode-check { width: 100%; }
    .mailcode-value { font-size: 28px; letter-spacing: 3px; }
}
@media (prefers-reduced-motion: reduce) {
    .mailcode, .mailcode.is-new, .mailcode-wait .pulse { animation: none; }
}

/* ---------- Cualquier pantalla: celulares pequeños, iPhone, tabletas y horizontal ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.client-page { overflow-x: hidden; }
.client-card img { max-width: 100%; height: auto; }
/* En celulares los campos usan 16 px: así el iPhone no agranda la pantalla al tocarlos. */
@media (max-width: 640px) {
    .client-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    .client-page select,
    .client-page textarea { font-size: 16px !important; }
}
/* Celular horizontal (poca altura): la tarjeta empieza arriba y se desplaza normal. */
@media (max-height: 520px) and (orientation: landscape) {
    body.client-page { justify-content: flex-start; padding-top: 16px; padding-bottom: 16px; }
}

/* Plataformas: todas del mismo ancho y alto (la última fila sigue centrada) y nombres largos centrados. */
.platform-option { display: flex; flex-grow: 0; flex-basis: 96px; }
.platform-option span { flex: 1; justify-content: flex-start; text-align: center; line-height: 1.25; }
@media (max-width: 480px) {
    .platform-option { flex-basis: 84px; }
}
@media (max-width: 340px) {
    .platform-option { flex-basis: 100%; }
    .platform-option span { text-align: left; }
}
