:root {
    --brand-green: #1D4F2B;
    --brand-green-dark: #143820;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-input: #f9fafb;
    --border-input: #e5e7eb;
    --card-bg: #ffffff;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.wrapper {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    align-items: center;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background: url("../images/HomeAlsurPeru.png") center center / cover no-repeat;
    transform: scale(1.2);
    transform-origin: center center;
    animation: loginBgZoom 1.4s ease-out forwards;
    will-change: transform;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(29, 79, 43, 0.4));
    pointer-events: none;
}

@keyframes loginBgZoom {
    from {
        transform: scale(1.2);
    }

    to {
        transform: scale(1);
    }
}

/* ==================== App name (superior izquierda) ==================== */
.system-watermark {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 0px));
    left: max(20px, env(safe-area-inset-left, 0px));
    right: auto;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: none;
}

.system-watermark-icon {
    width: 42px;
    height: 42px;
    background: #1D4F2B;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.system-watermark-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.system-watermark-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
    white-space: nowrap;
    line-height: 1.1;
}

.system-watermark-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ==================== Card ==================== */
.auth-wrapper {
    width: 100%;
    max-width: 440px;
    padding: 20px;
    padding-top: max(84px, calc(env(safe-area-inset-top, 0px) + 68px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    animation: slideUp 0.6s ease-out;
}

.auth-card {
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    padding: 40px 36px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.85);
}

.auth-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--brand-green), #2d7a42);
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-logo img {
    height: 131px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.auth-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--brand-green);
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 28px;
    line-height: 1.45;
}

/* ==================== Inputs ==================== */
.input-container {
    position: relative;
    margin-bottom: 18px;
    text-align: left;
}

.input-field {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    transition: color 0.3s ease;
    pointer-events: none;
}

.custom-input {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px 14px 48px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.3s ease;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.custom-input:focus {
    background: white;
    border-color: var(--brand-green);
    box-shadow: 0 4px 12px rgba(29, 79, 43, 0.1);
    outline: none;
}

.custom-input:focus + .input-icon {
    color: var(--brand-green);
}

.custom-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
    margin-left: 4px;
}

.is-invalid {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
}

.error-msg {
    color: #ef4444;
    font-size: 12px;
    margin-top: 6px;
    margin-left: 4px;
    display: block;
}

/* ==================== Acciones ==================== */
.auth-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    min-height: 44px;
}

.checkbox-wrapper input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-green);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-wrapper label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.forgot-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--brand-green);
    text-decoration: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.forgot-link:hover {
    color: var(--brand-green-dark);
    text-decoration: underline;
}

.btn-primary-custom {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    background: var(--brand-green);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(29, 79, 43, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    touch-action: manipulation;
}

.btn-primary-custom:hover,
.btn-primary-custom:focus {
    background: var(--brand-green-dark);
    color: white;
    outline: none;
}

.btn-primary-custom:active {
    transform: translateY(1px);
}

.btn-secondary-custom {
    width: 100%;
    min-height: 48px;
    margin-top: 12px;
    padding: 12px 16px;
    background: transparent;
    color: var(--brand-green);
    border: 2px solid var(--brand-green);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    text-decoration: none;
    touch-action: manipulation;
}

.btn-secondary-custom:hover,
.btn-secondary-custom:focus {
    background: rgba(29, 79, 43, 0.08);
    color: var(--brand-green-dark);
    outline: none;
}

.btn-secondary-custom:active {
    transform: translateY(1px);
}

.auth-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: -12px 0 22px;
    line-height: 1.45;
}

.auth-card .alert {
    text-align: left;
    font-size: 14px;
    border-radius: 12px;
    margin-bottom: 20px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (hover: hover) {
    .btn-primary-custom:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(29, 79, 43, 0.4);
    }

    .btn-secondary-custom:hover {
        transform: translateY(-1px);
    }

    .auth-logo:hover {
        transform: scale(1.02);
    }
}

/* ==================== Celulares ==================== */
@media (max-width: 575.98px) {
    .system-watermark {
        top: max(12px, env(safe-area-inset-top, 0px));
        left: max(12px, env(safe-area-inset-left, 0px));
        gap: 8px;
    }

    .system-watermark-icon {
        width: 34px;
        height: 34px;
        font-size: 13px;
        border-radius: 8px;
    }

    .system-watermark-text {
        font-size: 14px;
        letter-spacing: 0.3px;
    }

    .system-watermark-subtitle {
        font-size: 10px;
        padding: 2px 7px;
        letter-spacing: 0.8px;
    }

    .auth-wrapper {
        padding-top: max(68px, calc(env(safe-area-inset-top, 0px) + 52px));
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }

    .auth-card {
        padding: 28px 20px 24px;
        border-radius: 20px;
    }

    .auth-logo img {
        height: 108px;
    }

    .auth-title {
        font-size: 20px;
    }

    .auth-subtitle {
        font-size: 13px;
        margin-bottom: 22px;
    }

    .auth-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-bottom: 20px;
    }

    .forgot-link {
        margin-left: 0;
        padding-left: 28px;
    }
}

@media (max-width: 360px) {
    .system-watermark-text {
        font-size: 12px;
    }

    .system-watermark-subtitle {
        font-size: 9px;
    }

    .auth-card {
        padding: 24px 16px 20px;
        border-radius: 16px;
    }
}

/* Landscape / pantallas bajas: el formulario debe poder desplazarse */
@media (max-height: 700px) {
    .wrapper {
        align-items: flex-start;
    }

    .auth-wrapper {
        padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 48px));
    }

    .auth-card {
        padding-top: 24px;
        padding-bottom: 20px;
    }

    .auth-logo {
        margin-bottom: 12px;
    }

    .auth-subtitle {
        margin-bottom: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none;
        transform: scale(1);
    }

    .auth-wrapper {
        animation: none;
    }
}
