*, *::before, *::after { box-sizing: border-box; }

/* Elimina tap highlight azul en iOS/Android */
* { -webkit-tap-highlight-color: transparent; }

/* Previene scroll horizontal en móvil causado por cualquier elemento desbordado */
html { overflow-x: hidden; }

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f4f4;
    color: #222;
    min-height: 100vh;
    overflow-x: hidden;
    /* Safe area para iPhone con notch / Dynamic Island */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
    background: #f1c40f;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
header h1 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: bold;
    color: #000;
}

/* ── Contenedor principal ────────────────────────────────────────────────── */
.container {
    max-width: 860px;
    margin: 36px auto;
    padding: 0 16px;
}

/* ── Pasos ───────────────────────────────────────────────────────────────── */
.steps {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}
.step {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: bold;
    background: #fff;
    color: #aaa;
    border-right: 1px solid #ddd;
}
.step:last-child { border-right: none; }
.step.activo   { background: #f1c40f; color: #000; }
.step.completo { background: #d4edda; color: #155724; }

/* ── Tarjetas (cards) ────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 28px 32px;
    margin-bottom: 24px;
}
.card h2 {
    margin: 0 0 20px;
    font-size: 1.1rem;
    border-bottom: 3px solid #f1c40f;
    padding-bottom: 8px;
}

/* ── Socio info ──────────────────────────────────────────────────────────── */
.socio-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fffbe6;
    border: 1px solid #f1c40f;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.socio-info > * { min-width: 0; }
.socio-info .nombre {
    font-size: 1.15rem;
    font-weight: bold;
    overflow-wrap: break-word;
    word-break: break-word;
}
.socio-info .cedula {
    font-size: 0.9rem;
    color: #666;
}

/* ── Tarjetas registradas ────────────────────────────────────────────────── */
.tarjeta-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #fafafa;
}
/* min-width: 0 es necesario para que los hijos flex puedan encogerse
   por debajo de su contenido natural (evita overflow en móvil) */
.tarjeta-item > * { min-width: 0; }
.tarjeta-item .badge-tipo {
    font-size: 0.75rem;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 12px;
    background: #222;
    color: #f1c40f;
    white-space: nowrap;
    flex-shrink: 0;
}
.tarjeta-item .nro {
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 1px;
    flex: 1;
    overflow-wrap: break-word;
    word-break: break-word;
}
.tarjeta-item .banco   { font-size: 0.85rem; color: #555; overflow-wrap: break-word; }
.tarjeta-item .vence   { font-size: 0.8rem; color: #888; white-space: nowrap; flex-shrink: 0; }
.badge-activo   { background: #d4edda; color: #155724; border-radius: 12px; padding: 2px 10px; font-size: 0.78rem; font-weight: bold; }
.badge-inactivo { background: #f8d7da; color: #721c24; border-radius: 12px; padding: 2px 10px; font-size: 0.78rem; font-weight: bold; }

/* ── Formulario ──────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

label {
    display: block;
    font-size: 0.82rem;
    font-weight: bold;
    margin-bottom: 4px;
    color: #444;
}
label .req { color: #c0392b; }

input[type=text],
input[type=email],
input[type=date],
input[type=tel],
input[type=password],
select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.15s;
    /* Safari iOS: elimina estilo nativo de inputs y selects */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Previene que Safari iOS redondee inputs por defecto */
    -webkit-border-radius: 6px;
}
/* Flecha personalizada para select (reemplaza la que quita -webkit-appearance) */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
input:focus, select:focus {
    outline: none;
    border-color: #f1c40f;
    box-shadow: 0 0 0 2px rgba(241,196,15,0.25);
}

.radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 8px 0;
}
.radio-group label {
    margin: 0;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
    /* Elimina delay de 300ms en iOS (doble-tap zoom) */
    touch-action: manipulation;
    -webkit-appearance: none;
}
.btn-primary  { background: #f1c40f; color: #000; }
.btn-primary:hover  { background: #d4a900; }
.btn-secondary { background: #555; color: #fff; }
.btn-secondary:hover { background: #333; }
.btn-success  { background: #27ae60; color: #fff; }
.btn-success:hover  { background: #1e8449; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger   { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; font-weight: bold; }

/* ── Mensajes ────────────────────────────────────────────────────────────── */
.msg {
    padding: 11px 16px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.93rem;
    display: none;
}
.msg.ok    { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.msg.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.msg.show  { display: block; }
.campo-invalido { border-color: #e53935 !important; box-shadow: 0 0 0 3px rgba(229,57,53,0.2) !important; }
input[readonly] { background-color: #f0f0f0; color: #555; cursor: not-allowed; }
select:disabled { background-color: #f0f0f0; color: #555; cursor: not-allowed; opacity: 1; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Enlace restaurar contraseña ────────────────────────────────────────── */
.recuperar-pass {
    margin-top: 8px;
    text-align: right;
    font-size: 0.84rem;
}
.recuperar-pass a {
    color: #5a8dee;
    text-decoration: none;
}
.recuperar-pass a:hover { text-decoration: underline; }

/* ── Separador acciones ──────────────────────────────────────────────────── */
.acciones {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ── Sección oculta ──────────────────────────────────────────────────────── */
.seccion { display: none; }
.seccion.visible { display: block; }

/* ── Logo ────────────────────────────────────────────────────────────────── */
.logo-wrap { text-align: center; margin-bottom: 18px; }
.logo-wrap img { max-height: 60px; }

/* ── Icono del header ────────────────────────────────────────────────────── */
.header-icon { font-size: 1.6rem; }

/* ── Tarjeta visual (card preview) ──────────────────────────────────────── */
/* Gradientes por marca — reemplazan inline style, eliminan unsafe-inline del CSP */
.card-visual.cv-brand-visa       { background: linear-gradient(135deg, #1a1f71 0%, #1a2a4a 100%); }
.card-visual.cv-brand-mastercard { background: linear-gradient(135deg, #eb001b 0%, #1a2a4a 100%); }
.card-visual.cv-brand-amex       { background: linear-gradient(135deg, #007bc1 0%, #1a2a4a 100%); }
.card-visual.cv-brand-diners     { background: linear-gradient(135deg, #004a97 0%, #1a2a4a 100%); }

.card-visual {
    background: linear-gradient(135deg, #1a2a4a 0%, #2c4a7c 100%);
    border-radius: 12px;
    padding: 22px 24px 18px;
    color: #fff;
    position: relative;
    max-width: 340px;
    width: 100%;
    margin: 0 auto 24px;
    font-family: 'Courier New', monospace;
}
.card-visual .cv-chip   { font-size: 1.6rem; margin-bottom: 14px; }
.card-visual .cv-number { font-size: 1.18rem; letter-spacing: 2px; margin-bottom: 14px; font-weight: bold; }
.card-visual .cv-bottom { display: flex; justify-content: space-between; font-size: 0.8rem; }
.card-visual .cv-tipo   { position: absolute; top: 18px; right: 20px; font-size: 1.8rem; }
.card-visual .cv-label  { font-size: 0.68rem; opacity: .7; }
.card-visual .cv-right  { text-align: right; }

/* ── Campos del formulario con margen inferior ───────────────────────────── */
.form-field      { margin-bottom: 14px; }
.form-field-tight { margin-bottom: 4px; }

/* ── Input con icono de tipo de tarjeta ──────────────────────────────────── */
.input-card-wrap { position: relative; }
.input-card-wrap input { padding-right: 42px; } /* espacio para el ícono, evita solapamiento */
.input-card-wrap .tipo-icon {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%); font-size: 1.3rem; pointer-events: none;
}

/* ── Hint bajo el input ──────────────────────────────────────────────────── */
.hint { font-size: 0.78rem; color: #888; margin-top: 4px; }

/* ── Timeline del proceso de registro ────────────────────────────────────── */
.timeline-proceso { display: none; margin: 20px 0 10px; border: 1px solid #e0e0e0; border-radius: 10px; background: #f9f9f9; padding: 18px 20px; }
.tl-item      { display: flex; align-items: flex-start; gap: 14px; }
.tl-item > *  { min-width: 0; } /* evita overflow de texto largo en móvil */
.tl-connector { width: 2px; height: 20px; background: #ddd; margin: 4px 0 4px 14px; transition: background .4s; }
.tl-connector.done { background: #4caf50; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; border: 2px solid #ddd; background: #fff; transition: all .3s; }
.tl-dot.pending { border-color: #ccc; color: #bbb; }
.tl-dot.loading { border-color: #f0a500; color: #f0a500; animation: tl-pulse 1s infinite; }
.tl-dot.success { border-color: #4caf50; color: #4caf50; background: #e8f5e9; }
.tl-dot.error   { border-color: #e53935; color: #e53935; background: #ffebee; }
@keyframes tl-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(240,165,0,.4); } 50% { box-shadow: 0 0 0 6px rgba(240,165,0,0); } }
.tl-body   { flex: 1; min-width: 0; padding-top: 3px; }
.tl-titulo { font-weight: 600; font-size: .87rem; color: #333; margin-bottom: 5px; overflow-wrap: break-word; }
.tl-detalle { display: none; font-size: .78rem; font-family: 'Courier New', monospace; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; padding: 8px 12px; word-break: break-all; overflow-wrap: break-word; line-height: 1.6; overflow-x: auto; }
.tl-detalle.visible { display: block; }
.tl-token-value { color: #1565c0; font-weight: bold; font-size: .82rem; }
.tl-ok  { color: #2e7d32; }
.tl-err { color: #c62828; }

/* ── Utilidades ──────────────────────────────────────────────────────────── */
.divider   { border: none; border-top: 1px solid #eee; margin: 20px 0; }
.text-muted { color: #888; font-size: 0.87rem; }
.lista-tarjetas-vacia { text-align: center; color: #999; padding: 18px 0; font-size: 0.93rem; }

#bloque-pass { display: none; }


.icono-socio   { font-size: 2rem; }
.tarjeta-icono { font-size: 1.5rem; }
.badge-fedu    { background: #e8f5e9; color: #2e7d32; border-radius: 12px; padding: 2px 10px; font-size: 0.78rem; font-weight: bold; }
.lista-error   { color: #c0392b; }
.spinner-sm    { width: 12px !important; height: 12px !important; border-width: 2px !important; margin: 0 !important; }
.texto-debito  { color: #e65100; }

/* ── Nota de seguridad ───────────────────────────────────────────────────── */
.security-note { display: flex; align-items: flex-start; gap: 10px; background: #eaf4fb; border: 1px solid #b8d9f0; border-radius: 8px; padding: 12px 16px; font-size: 0.82rem; color: #1a5276; margin-bottom: 20px; }
.security-note .icon { font-size: 1.2rem; flex-shrink: 0; }

/* ── Checkbox personalizado ──────────────────────────────────────────────── */
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-input { width: 18px; height: 18px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 768px) {
    .container { max-width: 100%; }
    .card { padding: 22px 20px; }
}

/* Móvil */
@media (max-width: 600px) {
    /* Layout base */
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: 1; }
    .container { margin: 12px auto; }

    /* Header */
    header { padding: 12px 16px; gap: 10px; }
    header h1 { font-size: 1rem; }
    .header-icon { font-size: 1.2rem; }

    /* Card visual */
    .card-visual { padding: 18px 16px 14px; }
    .card-visual .cv-number { font-size: 1rem; letter-spacing: 1px; }

    /* Nota de seguridad */
    .security-note { flex-direction: column; gap: 6px; padding: 10px 12px; }

    /* Logo */
    .logo-wrap img { max-height: 48px; }

    /* Card */
    .card { padding: 18px 14px; border-radius: 8px; margin-bottom: 16px; }
    .card h2 { font-size: 1rem; margin-bottom: 14px; }

    /* Pasos — texto más corto */
    .steps { margin-bottom: 16px; }
    .step { font-size: 0.68rem; padding: 8px 4px; line-height: 1.3; }

    /* Inputs y selects — targets táctiles más grandes, evita zoom en iOS */
    input[type=text],
    input[type=email],
    input[type=date],
    input[type=tel],
    input[type=password],
    select {
        padding: 11px 12px;
        font-size: 1rem;      /* 16px mínimo evita zoom automático en iOS */
        min-height: 44px;     /* Target táctil recomendado por Apple HIG */
    }

    /* Botones full-width en móvil */
    .acciones { flex-direction: column; gap: 10px; }
    .btn { width: 100%; justify-content: center; padding: 13px 16px; font-size: 1rem; }

    /* Tarjetas registradas — stackear en móvil */
    .tarjeta-item {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    .tarjeta-item .nro {
        width: 100%;
        font-size: 0.95rem;
    }
    .tarjeta-item .banco,
    .tarjeta-item .vence { font-size: 0.8rem; }

    /* Socio info */
    .socio-info { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; }
    .socio-info .nombre { font-size: 1rem; }
}

/* Pantallas muy pequeñas: iPhone SE 1ª gen, Moto G4, Galaxy A series ≤ 360px */
@media (max-width: 360px) {
    header { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
    header h1 { font-size: 0.88rem; }
    .header-icon { font-size: 1.1rem; }

    .card { padding: 14px 10px; }

    /* Pasos: acortar aún más para que entren en 320px */
    .step { font-size: 0.6rem; padding: 7px 2px; }

    /* Card visual: reducir fuente y espaciado para que el número quepa */
    .card-visual { padding: 14px 12px 12px; }
    .card-visual .cv-number { font-size: 0.85rem; letter-spacing: 0.5px; }
    .card-visual .cv-chip   { font-size: 1.3rem; margin-bottom: 10px; }
    .card-visual .cv-tipo   { font-size: 1.4rem; top: 12px; right: 12px; }

    /* Botones: fuente un poco menor para no truncar texto */
    .btn { font-size: 0.9rem; padding: 12px 12px; }

    /* Nota de seguridad */
    .security-note { font-size: 0.78rem; }
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 40px 14px 16px;
    border-radius: 8px;
    font-size: 0.93rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    line-height: 1.45;
    word-break: break-word;
}
.toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}
.toast-ok    { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.toast-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.toast-warn  { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.65;
    line-height: 1;
    padding: 0;
}
.toast-close:hover { opacity: 1; }
@media (max-width: 480px) {
    .toast { right: 12px; left: 12px; min-width: 0; max-width: none; top: 12px; }
}

/* ── Overlay de carga ────────────────────────────────────────────────────── */
.overlay-cargando {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
}
.overlay-cargando.overlay-activo {
    display: flex;
}
.overlay-spinner {
    background: #fff;
    border-radius: 12px;
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
}
.overlay-spinner .spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
}
.overlay-texto {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

/* Modal de alerta previa al registro */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    padding: 20px;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.visible {
    display: flex;
}
.modal-card {
    width: min(720px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
    padding: 24px;
}
.modal-card h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: #222;
}
.modal-body p {
    margin: 0 0 14px;
    line-height: 1.55;
    color: #333;
}
.modal-body ol {
    margin: 0 0 14px;
    padding-left: 20px;
}
.modal-body ol li {
    margin-bottom: 14px;
    line-height: 1.55;
    color: #333;
}
.modal-note {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fff8e1;
    border: 1px solid #f1c40f;
    font-weight: 600;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.form-bloqueado {
    opacity: 0.65;
}
.form-bloqueado .card-visual {
    filter: grayscale(0.15);
}

@media (max-width: 600px) {
    .modal-backdrop {
        padding: 12px;
    }
    .modal-card {
        padding: 18px 16px;
        max-height: calc(100vh - 24px);
    }
    .modal-actions {
        flex-direction: column-reverse;
    }
    .modal-actions .btn {
        width: 100%;
    }
}
