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

:root {
    --primary: #1e1f64;
    --primary-dark: #4693e5;
    --primary-light: #464d92;
    --accent: #2474ba;
    --bg-main: #ffffff;
    --bg-card: #f8fafc;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: rgba(0, 0, 0, 0.1);
    --glow: rgba(99, 102, 241, 0.15);
}

body.theme-dark {
    --primary: #141a51;
    --primary-dark: #f7f7ff;
    --primary-light: #177e81;
    --accent: #4b75ab;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(129, 140, 248, 0.2);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
    background: radial-gradient(circle at 20% 20%, var(--primary) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, var(--accent) 0%, transparent 50%);
}

.theme-toggle-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

.theme-toggle {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50px;
    padding: 0.4rem;
    display: flex;
    gap: 0.3rem;
    box-shadow: 0 4px 12px var(--shadow);
    position: relative;
    transition: all 0.3s ease;
}

.theme-option {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 600;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-option:hover {
    color: var(--text-primary);
}

.theme-option.active {
    color: white;
}

.theme-slider {
    position: absolute;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 12px var(--glow);
    z-index: 1;
    height: calc(100% - 0.8rem);
    top: 0.4rem;
}

body.theme-light .theme-slider {
    left: 0.4rem;
    width: calc(50% - 0.55rem);
}

body.theme-dark .theme-slider {
    left: calc(50% + 0.15rem);
    width: calc(50% - 0.55rem);
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    z-index: 1;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.flip-wrapper {
    position: relative;
    width: 100%;
}

.flip-container {
    position: relative;
    width: 100%;
}

.card-side {
    width: 100%;
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: 0 20px 60px var(--shadow), 0 0 0 1px var(--border);
    overflow: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 1;
    transform: translateY(0);
}

.card-side.back {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.flip-container.flipped .card-side.front {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.flip-container.flipped .card-side.back {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.card-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
}

.form-section {
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.welcome-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.welcome-section::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px, 30px 30px;
    background-position: 0 0, 25px 25px;
    animation: float 30s linear infinite;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(50px, 50px) rotate(360deg);
    }
}

.welcome-content {
    position: relative;
    z-index: 1;
}

.logo-container {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container img {
    max-width: 180px;
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.logo-container img:hover {
    transform: scale(1.05);
}

.logo-fallback {
    font-size: 2.5rem;
    color: white;
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
}

.welcome-section h2 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.welcome-section p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 2.5rem;
    color: rgba(255, 255, 255, 0.95);
    max-width: 380px;
}

.form-section h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    position: absolute;
    left: 1rem;
    top: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    pointer-events: none;
    background: transparent;
    z-index: 1;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 1rem;
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--glow);
}

.form-group input:focus+label,
.form-group input:not(:placeholder-shown)+label {
    top: -0.7rem;
    left: 0.8rem;
    font-size: 0.8rem;
    color: var(--primary);
    background: var(--bg-card);
    padding: 0 0.4rem;
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
    cursor: pointer;
}

.form-group select:not([value=""])+label,
.form-group select:focus+label {
    top: -0.7rem;
    left: 0.8rem;
    font-size: 0.8rem;
    color: var(--primary);
    background: var(--bg-card);
    padding: 0 0.4rem;
}

.form-group select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

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

.phone-input-container select {
    width: 35%;
    min-width: 110px;
}

.phone-input-container input {
    flex: 1;
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 3.5rem;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 2;
    padding: 0.3rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.toggle-password:hover {
    color: var(--primary);
    background: var(--bg-hover);
}

.toggle-password svg {
    width: 1.4rem;
    height: 1.4rem;
    display: block;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

.checkbox-container input[type="checkbox"] {
    width: 1.3rem;
    height: 1.3rem;
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: 6px;
    appearance: none;
    background-color: var(--bg-main);
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.checkbox-container input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-container input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 0.35rem;
    top: 0.1rem;
    width: 0.35rem;
    height: 0.7rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    border: 2px solid white;
    background: transparent;
    padding: 0.9rem 2.5rem;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn-ghost::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.btn-ghost:hover::before {
    width: 300px;
    height: 300px;
}

.btn-ghost:hover {
    color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.3);
}

.btn-ghost span {
    position: relative;
    z-index: 1;
}

.btn-google {
    width: 100%;
    padding: 0.9rem;
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-google:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.error {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid var(--danger);
}

.success {
    color: var(--success);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid var(--success);
}

.link {
    text-align: center;
    margin-top: 1.5rem;
}

.link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.link a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.link a:hover::after {
    width: 100%;
}

.divider {
    margin: 1.5rem 0;
    text-align: center;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider span {
    position: relative;
    background: var(--bg-card);
    padding: 0 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px var(--shadow);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    color: var(--primary);
    background: var(--bg-hover);
    transform: rotate(90deg);
}

.hidden-fields {
    display: none;
}

.code-display {
    background: var(--bg-main);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    margin: 1rem 0;
}

.code-display .code-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.3rem;
    margin-bottom: 0.5rem;
}

.code-display .code-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

@media (max-width: 968px) {
    .card-content {
        grid-template-columns: 1fr;
    }

    .welcome-section {
        order: 1;
        min-height: 300px;
    }

    .form-section {
        order: 2;
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 640px) {
    .theme-toggle-container {
        top: 1rem;
        right: 1rem;
    }

    .theme-toggle {
        padding: 0.3rem;
    }

    .theme-option {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .page-wrapper {
        padding: 1rem 0.5rem;
    }

    .form-section {
        padding: 2rem 1.5rem;
    }

    .welcome-section {
        padding: 2rem 1.5rem;
        min-height: 250px;
    }

    .welcome-section h2 {
        font-size: 2.2rem;
    }

    .form-section h2 {
        font-size: 1.8rem;
    }

    .modal-content {
        padding: 2rem 1.5rem;
    }

    .logo-container img {
        max-width: 150px;
    }
}

/* ==== ACCESIBILIDAD: prefers-reduced-motion (2026-07-24) ==== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
