@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;600&display=swap");

:root {
    --glass: rgba(255, 255, 255, 0.15);
    --radius: 15px;
}

* {
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

body {
    margin: 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    color: #fff;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

h1,
h2 {
    text-align: center;
    margin-top: 0;
}

/* ---------- LOGIN GLASS + ANIMACIONES ---------- */
.login-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    margin: auto;
    text-align: center;
    color: #fff;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.login-header {
    margin-bottom: 1.5rem;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

/* Inputs con animación */
.input-group {
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

.input-group label {
    position: absolute;
    top: 0.8rem;
    left: 1rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
    pointer-events: none;
}

.input-group input:focus+label,
.input-group input:not(:placeholder-shown)+label {
    top: -0.6rem;
    left: 0.8rem;
    font-size: 0.75rem;
    color: #fff;
}

/* Botón con spinner */
.btn-login {
    position: relative;
    padding: 0.8rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

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

.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

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

.btn-login.loading .btn-spinner {
    display: inline-block;
}

/* Footer */
.login-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Responsive */
@media (max-width: 480px) {
    .login-glass {
        padding: 2rem 1.5rem;
    }

    .btn-login {
        font-size: 0.9rem;
    }
}

/* Selector de idioma */
.lang-switch {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.lang-switch select {
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2rem;
    padding: 0.45rem 2.2rem 0.45rem 0.9rem;
    font-size: 0.9rem;
    color: #fff;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
    transition: background 0.25s ease;
}

.lang-switch select:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Formulario */
.admin-form {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.admin-form label {
    font-size: 0.9rem;
    font-weight: 600;
}

.admin-form input {
    padding: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.95rem;
}

.admin-form input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

/* Botones */
.btn-save,
.btn-csv,
.btn-img,
.btn-gallery,
.btn-reset {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.7rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
}

.btn-save {
    background: #10b981;
}

.btn-gallery {
    background: #00d4ff;
}

/* Responsive */
@media (max-width: 600px) {
    .admin-actions {
        grid-template-columns: 1fr;
    }
}

.prizes-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    overflow-y: scroll;
    height: 610px;
}

.prize-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.8rem;
}

.prize-item input {
    padding: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-add {
    margin-top: 1rem;
    padding: 0.7rem;
    border: none;
    border-radius: 12px;
    background: #FFC107;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-remove {
    background: #f43f5e;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    transform: scale(1.1);
}

.img-container {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
}

.drop-zone {
    padding: 1rem;
    font-size: 0.9rem;
}

.drop-zone.drag-over {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

.img-preview {
    width: 100%;
    border-radius: 10px;
    margin-top: 0.5rem;
    display: none;
}

/* ---------- GALERÍA DE IMÁGENES ---------- */
.galeria {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.galeria h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.galeria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.galeria-item {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.galeria-item:hover {
    transform: scale(1.05);
    border-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* === MODAL MEJORADO === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 20px;
    max-width: 90%;
    max-height: 90vh;
    width: 900px;
    overflow: hidden;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #fff;
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff6b6b;
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.8rem;
    max-height: 65vh;
    overflow-y: auto;
}

/* Scroll personalizado */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.galeria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 1rem;
}

.galeria-item {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.galeria-item:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border-color: #00d4ff;
}

.galeria-item:active {
    transform: translateY(-3px) scale(1.02);
}

/* Estado vacío */
#galleryEmpty {
    text-align: center;
    color: #888;
    font-style: italic;
    margin: 2rem 0;
    font-size: 1.1rem;
}

/* === BARRA SUPERIOR ADMIN === */
.admin-top-bar {
    display: flex;
    justify-content: end;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

/* === BOTÓN IR AL SORTEO === */
.btn-raffle {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-raffle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

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

/* =========================================
   FIX: MEJORA VISUAL PARA MÓVILES (PREMIOS)
   ========================================= */
@media (max-width: 768px) {
    .prize-item {
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* Dos columnas */
        grid-template-areas:
            "name name"
            "value img"
            "gallery remove";
        gap: 10px;
        background: rgba(255, 255, 255, 0.05);
        padding: 15px;
        border-radius: 12px;
        margin-bottom: 15px;
    }

    /* Asignamos cada input a su área */
    .prize-item input[data-field="name"] {
        grid-area: name;
        width: 100%;
    }

    .prize-item input[data-field="value"] {
        grid-area: value;
        width: 100%;
    }

    .prize-item .img-container {
        grid-area: img;
        margin: 0;
    }

    /* Botones más grandes para el dedo */
    .prize-item .btn-gallery {
        grid-area: gallery;
        width: 100%;
        padding: 10px;
        margin: 0;
    }

    .prize-item .btn-remove {
        grid-area: remove;
        width: 100%;
        padding: 10px;
        margin: 0;
    }

    /* Ajuste del contenedor de imagen */
    .drop-zone {
        padding: 5px;
        font-size: 10px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}