:root {
    --primary: #6C5CE7;
    --primary-hover: #5A4BCC;
    --bg-dark: #4d5a51;
    --text-main: #f7faf7;
    --text-muted: #c8d4c9;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.18);
    --danger: #ef4444;
    --success: #22c55e;
    --btn-bg-top: #f4f8f3;
    --btn-bg-bottom: #d8e5d6;
    --btn-text: #1a221c;
    --btn-shadow: rgba(26, 34, 28, 0.35);
    --focus-ring: rgba(232, 245, 228, 0.55);
}

html {
    height: 100%;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    position: relative;
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    max-height: 100vh;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    padding: max(env(safe-area-inset-top), clamp(6px, 1.5vmin, 14px))
        max(env(safe-area-inset-right), clamp(6px, 2vw, 14px))
        max(env(safe-area-inset-bottom), clamp(6px, 1.5vmin, 14px))
        max(env(safe-area-inset-left), clamp(6px, 2vw, 14px));
}

/* Dynamic background animations */
.background-animation {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.6;
    animation: float 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.shape1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #5c6d62;
    animation-delay: 0s;
}

.shape2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: #3d5c4e;
    animation-delay: -5s;
}

.shape3 {
    top: 40%;
    left: 40%;
    width: 40vw;
    height: 40vw;
    background: #6b5f56;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

/* Glassmorphism Form Container — cabe en el viewport sin scroll */
.form-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: min(500px, 100%);
    margin: 0 auto;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: clamp(14px, 3vmin, 24px);
    padding: clamp(14px, 3.5vmin, 28px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.form-container > #alert-box {
    flex-shrink: 0;
}

.form-header {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: clamp(8px, 2vmin, 18px);
}

.form-header h1 {
    font-size: clamp(1.15rem, 3.8vmin, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: clamp(4px, 1vmin, 8px);
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.form-header p {
    color: var(--text-muted);
    font-size: clamp(0.8rem, 2.4vmin, 0.95rem);
    font-weight: 400;
    line-height: 1.35;
}

#registro-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vmin, 12px);
    overflow: hidden;
}

.input-group {
    margin-bottom: 0;
    flex-shrink: 0;
}

.input-group label {
    display: block;
    font-size: clamp(0.78rem, 2.2vmin, 0.9rem);
    font-weight: 600;
    margin-bottom: clamp(3px, 0.8vmin, 6px);
    color: #e8f0e9;
    letter-spacing: 0.01em;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: clamp(8px, 2vmin, 14px) clamp(10px, 2.5vmin, 16px);
    border-radius: clamp(8px, 2vmin, 12px);
    background: rgba(28, 36, 30, 0.72);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: clamp(0.9rem, 2.8vmin, 1rem);
    line-height: 1.35;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-group input:focus,
.input-group select:focus {
    border-color: rgba(232, 245, 228, 0.65);
    box-shadow: 0 0 0 3px var(--focus-ring);
    background: rgba(22, 30, 24, 0.88);
}

.input-group input::placeholder {
    color: rgba(200, 212, 201, 0.55);
}

.help-text {
    display: block;
    margin-top: clamp(2px, 0.6vmin, 6px);
    font-size: clamp(0.68rem, 1.9vmin, 0.78rem);
    line-height: 1.25;
    color: #b8c8ba;
}

/* Select Styling */
.select-wrapper {
    position: relative;
}
.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
}
select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.submit-btn {
    width: 100%;
    flex-shrink: 0;
    padding: clamp(10px, 2.4vmin, 16px);
    border-radius: clamp(8px, 2vmin, 12px);
    background: linear-gradient(180deg, var(--btn-bg-top), var(--btn-bg-bottom));
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: var(--btn-text);
    font-size: clamp(0.95rem, 2.8vmin, 1.05rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    margin-top: clamp(4px, 1vmin, 10px);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 14px var(--btn-shadow);
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.35), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.submit-btn:hover::before {
    opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
    .submit-btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.03);
        box-shadow: 0 8px 22px var(--btn-shadow);
    }
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.input-group input:focus-visible,
.input-group select:focus-visible,
.submit-btn:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.input-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2) !important;
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(26, 34, 28, 0.25);
    border-top-color: var(--btn-text);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
    position: absolute;
}
@keyframes rotate {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Alert Styling */
.alert {
    flex-shrink: 0;
    padding: clamp(8px, 2vmin, 12px) clamp(10px, 2.5vmin, 14px);
    border-radius: 8px;
    margin-bottom: clamp(6px, 1.5vmin, 12px);
    font-size: clamp(0.82rem, 2.3vmin, 0.95rem);
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    animation: popIn 0.3s ease forwards;
}

.alert.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.alert.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86efac;
}

@keyframes popIn {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Pantallas bajas (landscape móvil, etc.): compactar sin scroll; subtítulo/ayudas recortados pero siguen en DOM (aria) */
@media (max-height: 640px) {
    .form-header p {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .help-text {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    #registro-form {
        gap: clamp(4px, 1vmin, 8px);
    }
}

@media (max-height: 520px) {
    .form-header h1 {
        margin-bottom: 2px;
    }
    .input-group input,
    .input-group select {
        padding: 6px 10px;
    }
}

@media (max-width: 600px) {
    .form-wrapper {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
