:root {
    --ink: #15171c;
    --ink-soft: #33363d;
    --paper: #fdfcfb;
    --surface: #ffffff;
    --text: #15171c;
    --text-secondary: #5b5f68;
    --text-muted: #8b8f97;
    --accent: #004AAD;
    --accent-hover: #004a8c;
    --accent-tint: #e6f1fc;
    --border: #d1d1d1;
    --error: #b3261e;
    --error-bg: #fbeaea;
    --error-border: #f3cfc9;
    --success: #1c7a4d;
    --success-bg: #e5f4ec;
    --radius-input: 0px;
    --radius-panel: 16px;
    --radius-otp: 0px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-stack: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Manrope', var(--font-stack);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Evita que el cuerpo de la página genere scroll/deslizamiento innecesario */
html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-stack);
    background: var(--paper);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ink), var(--accent));
    z-index: 20;
}

main {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 1rem;
}

/* Tarjeta contenedora centrada */
.wrapper {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: var(--radius-panel);
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* ============================================
   HEADER: Logo + Nombre al lado + Título
   ============================================ */
.brand-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.brand-identity {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem; /* Margen inferior en PC para separar del título */
}

.brand-logo {
    width: 35px;
    height: 35px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1;
}

.brand-header h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

#mainSubtitleText {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    margin-bottom: 0.5rem; /* Margen inferior para el subtítulo en PC */
    line-height: 1.3;
}

/* Estados ocultos y animaciones */
.progress-wrap {
    display: none;
}

.step-container {
    display: none;
    width: 100%;
    animation: fadeSlideIn 0.3s ease;
}

.step-container.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.title-container {
    margin-bottom: 1.5rem;
    text-align: left;
}

.title-container h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.title-container p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   INPUTS (Línea inferior estilo Microsoft)
   ============================================ */
.form-group {
    position: relative;
    margin-bottom: 1.25rem;
    text-align: left;
}

.input-container {
    position: relative;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    transition: border-color var(--transition);
    height: 48px;
    display: flex;
    align-items: center;
}

.input-container:hover {
    border-bottom-color: #8b8f97;
}

.input-container:focus-within {
    border-bottom-color: var(--accent);
}

.input-container.has-value:not(.error-input):not(:focus-within) {
    border-bottom-color: var(--accent);
}

.input-container.error-input {
    border-bottom-color: var(--error) !important;
}

.input-container label {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: all 0.2s ease;
    background: transparent;
    padding: 0;
    z-index: 2;
    white-space: nowrap;
}

.input-container input:focus ~ label,
.input-container input:not(:placeholder-shown) ~ label,
.input-container.has-value input ~ label {
    top: -6px !important;
    font-size: 0.75rem !important;
    color: var(--accent) !important;
}

.input-container.error-input input:focus ~ label,
.input-container.error-input input:not(:placeholder-shown) ~ label,
.input-container.error-input.has-value input ~ label {
    color: var(--error) !important;
}

input {
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-stack);
    outline: none;
    border-radius: 0;
}

.password-container {
    position: relative;
    display: flex;
    align-items: center;
}

.toggle-password {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 5;
    padding: 0 4px;
}

.custom-dropdown {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    box-shadow: 0 8px 20px rgba(21, 23, 28, 0.12);
    display: none;
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
}

.custom-dropdown.open {
    display: block;
}

.dropdown-option {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text);
    transition: background 0.2s;
    cursor: pointer;
}

.dropdown-option:hover {
    background-color: #f5f3f0;
}

.dropdown-option.selected {
    background-color: var(--accent-tint);
    color: var(--accent);
    font-weight: 600;
}

.phone-row {
    display: flex;
    gap: 0.5rem;
}

.otp-inputs-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 1.25rem;
}

.otp-box {
    width: 45px;
    height: 50px;
    font-size: 1.4rem;
    text-align: center;
    border: none;
    border-bottom: 1px solid var(--border);
    outline: none;
    background: transparent;
    color: var(--text);
    transition: border-color 0.2s;
}

.otp-box:focus {
    border-bottom-color: var(--accent);
}

.resend-row {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    text-align: left;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.pw-strength {
    margin-top: 0.6rem;
}

.pw-strength-track {
    height: 4px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.pw-strength-fill {
    height: 100%;
    width: 0%;
    background: var(--error);
    border-radius: 999px;
    transition: width 0.25s ease, background-color 0.25s ease;
}

.pw-strength-label {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 1em;
}

.email-suggestions-box {
    text-align: left;
    margin-top: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    padding: 0.5rem;
    background: #faf9f7;
}

.email-suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.email-suggestion-item:hover {
    background: var(--accent-tint);
}

.email-suggestion-item input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.email-suggestion-item label {
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    flex: 1;
    position: static;
    background: transparent;
    padding: 0;
}

.spinner-container {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--accent-tint);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.row-group {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.row-group .form-group {
    flex: 1;
    min-width: 0;
}

.error-banner {
    display: none;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error);
    padding: 0.85rem;
    border-radius: var(--radius-input);
    margin-bottom: 1.25rem;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
}

.error-banner.active {
    display: block;
}

.legal-policy-text {
    text-align: left;
    margin-bottom: 1.25rem;
}

.legal-policy-text h4 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
    margin-top: 0.6rem;
}

.legal-policy-text h4:first-child {
    margin-top: 0;
}

.legal-policy-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.terms-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    font-size: 0.9rem;
    color: var(--text);
}

.terms-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.terms-checkbox label {
    cursor: pointer;
}

/* Modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(21, 23, 28, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-overlay.active {
    display: flex;
}

.success-modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-panel);
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(21, 23, 28, 0.2);
    animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.92); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.success-icon-badge {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.25rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon-badge svg {
    display: block;
}

/* ============================================
   BOTONES
   ============================================ */
.btn-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2rem;
    gap: 0.5rem;
}

.btn {
    padding: 0.6rem 1.75rem;
    background-color: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    min-height: 40px;
    line-height: 1.2;
}

.btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: transparent;
    color: var(--accent);
    border: none;
    padding-left: 0;
    padding-right: 0;
    font-weight: 600;
    min-height: auto;
    line-height: 1.2;
}

.btn-secondary:hover:not(:disabled) {
    background-color: transparent;
    text-decoration: underline;
}

/* ============================================
   FOOTER (Términos, Privacidad, Idioma)
   ============================================ */
footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 1.25rem;
    width: 100%;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.otp-simulated-msg {
    background: var(--accent-tint);
    color: var(--accent-hover);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-input);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px dashed var(--accent);
}

.otp-simulated-msg code {
    background: var(--surface);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 2px;
    border: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE (Móviles)
   ============================================ */
@media (max-width: 480px) {
    main {
        padding: 1rem 0.5rem;
        align-items: flex-start;
    }
    
    .wrapper {
        padding: 1.5rem 1.25rem;
        box-shadow: none;
        background: transparent;
    }

    .brand-header {
        margin-bottom: 1.5rem;
        gap: 0.5rem;
    }

    .brand-identity {
        margin-bottom: 1.25rem; 
    }

    .brand-logo {
        width: 35px; 
        height: 35px; 
    }

    .brand-name {
        font-size: 1.5rem; 
    }
    
    .brand-header h1 {
        font-size: 1.25rem;
    }

    #mainSubtitleText,
    .title-container p {
        margin-bottom: 1.25rem;
    }

    footer {
        justify-content: center;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
}
