/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-screen {
    display: none;
    min-height: 100vh;
    position: relative;
    overflow: hidden !important;
}

.login-screen.active {
    display: block;
}

.login-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #5BBFB5 0%, #8DD4B8 18%, #C5E8C0 35%, #EAF2D0 50%, #C5E8C0 65%, #8DD4B8 82%, #5BBFB5 100%);
}

.login-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 40%);
}

.login-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.login-card {
    background: white;
    border-radius: 32px;
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
}

.login-logo {
    width: 88px;
    height: 88px;
    margin: 0 auto 24px;
    background: white;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #E8F5E9;
    box-shadow: 0 4px 20px rgba(124, 179, 66, 0.15), 0 1px 4px rgba(0, 0, 0, 0.05);
    padding: 16px;
}

.login-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 15px;
}

.input-group {
    margin-bottom: 24px;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.input-field {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--bg-main);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-green);
    background: white;
    box-shadow: 0 0 0 4px rgba(124, 179, 66, 0.1);
}

/* Ojo para ver la contraseña */
.input-field-pass {
    padding-right: 52px;
}

.pass-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Los demás campos de contraseña (recuperar, cambiar): el botón lo añade
   main.js dentro de este envoltorio. Selector con .search-field delante para
   ganarle al relleno de `.search-field input` (listado.css va después). */
.pass-campo {
    position: relative;
    display: block;
}

.search-field .pass-campo input {
    padding-right: 52px;
}

.pass-toggle:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: -4px;
    border-radius: 12px;
}

.pass-toggle .ojo-tachado,
.pass-toggle.visible .ojo-abierto {
    display: none;
}

.pass-toggle.visible .ojo-tachado {
    display: block;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    position: relative;
}

.checkbox-wrapper input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-wrapper input:checked {
    background: var(--primary-green);
    border-color: var(--primary-green);
}

.checkbox-wrapper input:checked::after {
    /* Centrado respecto a la casilla, no con left/top a ojo: el reset global
       (* { box-sizing: border-box }) no alcanza a ::after, asi que el tick
       media 2 px mas de lo calculado y quedaba bajo y a la derecha. El
       -60% lo sube un poco: el vertice de la "V" pesa abajo. */
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 9px;
    box-sizing: content-box;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.checkbox-wrapper label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 1;
}

.forgot-password-link {
    font-size: 13px;
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
    margin-left: auto;
    transition: all 0.3s ease;
}

.forgot-password-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-primary {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(124, 179, 66, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 179, 66, 0.4);
}
/* Elevarse al pasar por encima solo lo hacen "Entrar" y "Nueva devolución";
   los de recuperar la contraseña solo cambian de color */
.btn-primary.rec-boton:hover {
    transform: none;
    box-shadow: 0 4px 16px rgba(124, 179, 66, 0.3);
    background: linear-gradient(135deg, var(--primary-dark), #33691E);
}

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

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.privacy-link {
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.privacy-link:hover {
    color: var(--primary-green);
    text-decoration: underline;
}

/* ============================================
   LOGIN PROGRESS MODAL
   ============================================ */

.login-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

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

.login-modal {
    background: white;
    border-radius: 20px;
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease;
}

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

.login-modal-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.login-step {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.35;
    transition: opacity 0.3s;
}

.login-step.active {
    opacity: 1;
}

.login-step.done {
    opacity: 0.7;
}

.login-step-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.login-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: loginSpin 0.8s linear infinite;
}

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

.login-step-wait {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e0e0e0;
    margin: 0 6px;
}

.login-step.active .login-step-wait {
    display: none;
}

.login-step.active .login-step-icon::after {
    content: '';
    display: none;
}

.login-step.active .login-step-icon {
    position: relative;
}

.login-step.active .login-step-icon .login-step-wait {
    display: none;
}

.login-step.done .login-step-wait {
    width: 22px;
    height: 22px;
    background: var(--primary-green);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-step.done .login-step-wait::after {
    content: '✓';
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.login-step-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.login-step.active .login-step-text {
    font-weight: 600;
}

.login-step.done .login-step-text {
    color: var(--text-secondary);
}

.login-modal-progress {
    height: 4px;
    background: #e8e8e8;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.login-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-green), var(--primary-dark));
    border-radius: 2px;
    transition: width 0.4s ease;
}

.login-modal-status {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
}

/* ══════════════════════════════════════
   PAGINATION CONTROLS
   ══════════════════════════════════════ */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 0 8px;
}
.pagination-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    /* Eran var(--border) y var(--text), que no existen: salian sin borde */
    border: 1.5px solid #E5E7EB;
    background: #fff;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.pagination-btn:active { transform: scale(0.92); }
.pagination-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.pagination-active {
    /* Era var(--primary), que no existe en ningun sitio: el fondo se quedaba
       transparente y el numero, blanco sobre blanco. La pagina actual
       simplemente no se veia. */
    background: var(--primary-green);
    color: #fff;
    border-color: var(--primary-green);
    font-weight: 700;
}
.pagination-info {
    font-size: 12px;
    color: var(--text-light);
    margin-left: 8px;
}

/* ══════════════════════════════════════
   UPLOAD PROGRESS OVERLAY
   ══════════════════════════════════════ */
.upload-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.upload-overlay.active { display: flex; }
.upload-card {
    background: #fff;
    border-radius: 24px;
    padding: 40px 28px 32px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
    animation: uploadCardIn 0.35s cubic-bezier(0.34,1.4,0.64,1) forwards;
    overflow: hidden;
}
@keyframes uploadCardIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Sending state ── */
.upload-sending { display: block; }
.upload-loader {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    border: 4px solid #f0f0f0;
    border-top-color: var(--primary-green);
    animation: loaderSpin 0.75s linear infinite;
}
@keyframes loaderSpin {
    to { transform: rotate(360deg); }
}
.upload-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.upload-status {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
    min-height: 18px;
}
.upload-progress-bar {
    width: 100%;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green), #34d399);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}
.upload-progress-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ── Upload percentage text ── */
.upload-percent {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-green);
    text-align: center;
    margin-top: 10px;
    min-height: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

/* ── Fases del envío (js/devolucion.js, fasesEnvio) ──
   Debajo de la barra: lo hecho en verde, lo que está en marcha girando y lo
   que falta en gris. Con la lista, el texto de estado de arriba sobra. */
.upload-sending.con-fases .upload-status { display: none; }
.upload-sending.con-fases .upload-loader { width: 48px; height: 48px; margin-bottom: 14px; }
.upload-fases {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    text-align: left;
}
.upload-fase {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}
.upload-fase-marca {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 0;
    border-radius: 50%;
    border: 2px solid #E0E0E0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
}
.upload-fase.activa { color: var(--text-primary); font-weight: 600; }
.upload-fase.activa .upload-fase-marca {
    border-color: #E8F5E9;
    border-top-color: var(--primary-green);
    animation: loaderSpin 0.75s linear infinite;
}
.upload-fase.hecha { color: var(--text-primary); }
.upload-fase.hecha .upload-fase-marca { background: var(--primary-green); border-color: var(--primary-green); }
.upload-fase.hecha .upload-fase-marca::before { content: '✓'; }
.upload-fase.aviso { color: var(--text-primary); }
.upload-fase.aviso .upload-fase-marca { background: var(--cta); border-color: var(--cta); }
.upload-fase.aviso .upload-fase-marca::before { content: '!'; }
.upload-fase.error { color: #C62828; }
.upload-fase.error .upload-fase-marca { background: #E53935; border-color: #E53935; }
.upload-fase.error .upload-fase-marca::before { content: '✕'; }

/* ── Success state ── */
.upload-success {
    display: none;
    position: relative;
    padding: 16px 0 8px;
    overflow: visible;
}
.upload-success.show {
    display: block;
    animation: successFadeIn 0.3s ease forwards;
}
@keyframes successFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Green circle with check */
.success-icon-wrap {
    width: 88px;
    height: 88px;
    margin: 0 auto 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7CB342, #4CAF50);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    animation: iconPop 0.55s cubic-bezier(0.34,1.56,0.64,1) forwards;
    box-shadow: 0 10px 40px rgba(124, 179, 66, 0.45), 0 0 0 0 rgba(124,179,66,0.3);
}
.upload-success.show .success-icon-wrap {
    animation: iconPop 0.55s cubic-bezier(0.34,1.56,0.64,1) forwards,
               iconGlow 1.5s ease 0.6s infinite;
}
@keyframes iconPop {
    0% { transform: scale(0) rotate(-20deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}
@keyframes iconGlow {
    0%, 100% { box-shadow: 0 10px 40px rgba(124,179,66,0.45), 0 0 0 0px rgba(124,179,66,0.2); }
    50% { box-shadow: 0 10px 40px rgba(124,179,66,0.45), 0 0 0 12px rgba(124,179,66,0.08); }
}
.success-icon-wrap svg {
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
}
.upload-success.show .success-icon-wrap svg {
    animation: checkDraw 0.35s ease 0.35s forwards;
}
@keyframes checkDraw {
    to { stroke-dashoffset: 0; }
}

.success-title {
    /* Tamaño, grosor y margen los pone devolucion.css (se carga después y era
       lo que se veía); aquí solo el arranque de la animación de entrada. */
    opacity: 0;
}
.upload-success.show .success-title {
    animation: textSlideUp 0.4s ease 0.25s forwards;
}
@keyframes textSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Animated dots */
.success-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    opacity: 0;
}
.upload-success.show .success-dots {
    animation: textSlideUp 0.3s ease 0.45s forwards;
}
.success-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-green);
}
.upload-success.show .success-dots span {
    animation: dotPulse 1.2s ease-in-out 0.6s infinite;
}
.success-dots span:nth-child(2) { animation-delay: 0.75s; }
.success-dots span:nth-child(3) { animation-delay: 0.9s; }
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40% { transform: scale(1.5); opacity: 1; }
}

/* ============================================
   MOBILE OPTIMIZATION (≤480px)
   ============================================ */

@media (max-width: 480px) {
    .login-container {
        padding: 16px;
    }

    .login-card {
        padding: 24px 16px;
        border-radius: 24px;
    }

    .login-logo {
        width: 72px;
        height: 72px;
        margin-bottom: 16px;
        padding: 12px;
    }

    .login-title {
        font-size: 26px;
    }

    .login-subtitle {
        margin-bottom: 24px;
        font-size: 14px;
    }

    .input-group {
        margin-bottom: 16px;
    }

    .input-field {
        padding: 14px 14px 14px 44px;
        font-size: 14px;
    }

    .input-field-pass {
        padding-right: 50px;
    }

    .checkbox-wrapper {
        margin-bottom: 20px;
    }

    .btn-primary {
        padding: 16px;
        font-size: 15px;
    }

    .login-footer {
        margin-top: 16px;
        padding-top: 16px;
    }

    .login-modal {
        padding: 24px 20px;
    }

    .upload-card {
        padding: 28px 20px 24px;
    }
}

/* ============================================
   BOTÓN EN ESPERA (Entrar / Iniciar Sesión)
   ============================================

   Entre pulsar y la respuesta del servidor el botón solo se apagaba, sin más
   señal. En una conexión móvil lenta eso se lee como que la aplicación se ha
   quedado colgada. El modal de progreso aparece DESPUÉS de validar las
   credenciales —a propósito, para no enseñar los cuatro pasos a quien se ha
   equivocado de contraseña—, así que este giro cubre ese hueco.

   El contenido se oculta pero conserva su sitio (`visibility` en el icono y
   `color: transparent` en el texto, que es un nodo suelto y no se puede
   seleccionar aparte). Así el botón no cambia de tamaño ni da el salto típico
   de sustituir el texto por "Cargando…". */

.btn-primary.cargando {
    position: relative;
    cursor: progress;
    color: transparent;
}

.btn-primary.cargando > * {
    visibility: hidden;
}

.btn-primary.cargando::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    /* Reutiliza los keyframes del indicador del modal. */
    animation: loginSpin 0.7s linear infinite;
}

/* Quien pide menos movimiento ve un punto que late en vez de un giro. */
@media (prefers-reduced-motion: reduce) {
    .btn-primary.cargando::after {
        animation: loginLatido 1.2s ease-in-out infinite;
        border-top-color: rgba(255, 255, 255, 0.35);
    }
}

@keyframes loginLatido {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ── ¿Olvidaste la contraseña? ── */
#recuperarFullscreen .rec-boton { margin-top: 8px; }
.rec-aviso {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #F1F8E9;
    color: var(--primary-dark);
    font-size: 14px;
    line-height: 1.45;
}
.rec-codigo {
    font-size: 24px !important;
    font-weight: 700;
    letter-spacing: .35em;
    text-align: center;
    font-family: Consolas, Menlo, monospace;
}
.rec-otro {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-green);
    cursor: pointer;
}
.rec-otro:disabled { color: var(--text-light); cursor: default; }

/* "Entrar con otra cuenta" bajo el Entrar de la bienvenida (móvil compartido) */
.login-otra-cuenta {
    width: 100%;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    background: transparent;
    border: 2px solid var(--primary-dark, #558B2F);
    border-radius: 16px;
    padding: 14px 18px;
    color: var(--primary-dark, #558B2F);
    font: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.login-otra-cuenta:hover,
.login-otra-cuenta:active { background: rgba(85, 139, 47, 0.08); }
.login-otra-cuenta:focus-visible { outline: 3px solid rgba(85, 139, 47, 0.35); outline-offset: 2px; }
.login-otra-cuenta svg { flex-shrink: 0; }
