/* =========================================
   1. ESTILOS BASE Y TIPOGRAFÍA
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;1,700&family=Poppins:wght@300;400;600&display=swap');

body {
    background-color: #f3e5f5;
    background-image: linear-gradient(135deg, #f3e5f5 0%, #fff8e1 50%, #f3e5f5 100%);
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    color: #512da8;
    position: relative;
    overflow-x: hidden; /* Evita scroll horizontal accidental */
}

/* Grandes numerales XV en el fondo */
body::before {
    content: "XV";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Playfair Display', serif;
    font-size: 50vh;
    font-weight: bold;
    color: rgba(103, 58, 183, 0.05);
    z-index: -1;
}

/* =========================================
   2. CONTENEDOR PRINCIPAL (INVITACIÓN)
   ========================================= */
.container {
    text-align: center;
    background: white;
    padding: 60px 30px;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    max-width: 450px;
    width: 90%;
    position: relative;
    border: 2px solid #e1bee7;
    z-index: 10;
}

/* Flores en las esquinas */
.container::before,
.container::after {
    content: ""; position: absolute; width: 100px; height: 100px; background-size: contain; background-repeat: no-repeat; opacity: 0.8; z-index: -1;
}
.container::before { background-image: url('images/flower-corner-tr.png'); top: -10px; right: -10px; }
.container::after { background-image: url('images/flower-corner-bl.png'); bottom: -10px; left: -10px; }

/* Animación de Mariposas */
.butterfly {
    position: absolute; width: 30px; height: 30px; background-size: contain; background-repeat: no-repeat; animation: float 10s infinite ease-in-out; opacity: 0.6; z-index: 1;
}
@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(15px, 20px) rotate(10deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Cabecera */
h1 { font-family: 'Playfair Display', serif; font-size: 3.5rem; margin: 0 0 5px 0; color: #673ab7; }
.anos { margin: 0 0 20px 0; font-size: 1.2rem; color: #b39ddb; font-weight: 600; }
.subtitle { font-family: 'Playfair Display', serif; font-style: italic; font-size: 1rem; margin-bottom: 30px; color: #512da8; }

/* =========================================
   3. FORMULARIO Y BOTONES
   ========================================= */
input[type="text"], input[type="password"] {
    width: 100%; padding: 15px; margin: 10px 0; border: 1px solid #d1c4e9; border-radius: 12px; box-sizing: border-box; font-size: 1rem; transition: 0.3s;
}
input[type="text"]:focus, input[type="password"]:focus {
    border-color: #673ab7; outline: none; box-shadow: 0 0 10px rgba(103, 58, 183, 0.2);
}

.file-label {
    display: block; background: #ede7f6; padding: 20px; border-radius: 12px; border: 2px dashed #b39ddb; cursor: pointer; margin-bottom: 20px; transition: 0.3s; color: #673ab7; font-weight: 600;
}
.file-label:hover { background: #d1c4e9; border-color: #673ab7; }
.file-label input { display: none; }

button[type="submit"] {
    background-image: linear-gradient(135deg, #673ab7 0%, #512da8 100%); color: white; border: none; padding: 18px 30px; border-radius: 30px; font-size: 1.1rem; cursor: pointer; width: 100%; font-weight: 600; box-shadow: 0 5px 15px rgba(103, 58, 183, 0.4); transition: transform 0.3s, box-shadow 0.3s;
}
button[type="submit"]:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(103, 58, 183, 0.6); }

.admin-link { font-size: 0.8rem; color: #b39ddb; text-decoration: none; margin-top: 30px; display: inline-block; }
.admin-link:hover { color: #673ab7; text-decoration: underline; }

/* =========================================
   4. GRILLA DE FOTOS ESTRICTA (¡NO MÁS FOTOS GIGANTES!)
   ========================================= */
.preview-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    gap: 10px !important;
    margin: 20px 0 !important;
    width: 100% !important;
    justify-content: center !important;
}

.preview-image, .admin-img {
    width: 100% !important;
    height: 80px !important;       /* FORZAMOS ALTURA MÁXIMA */
    max-width: 80px !important;    /* FORZAMOS ANCHO MÁXIMO */
    object-fit: cover !important;  /* Recorta perfecto sin deformar */
    border-radius: 8px !important;
    border: 2px solid #d1c4e9 !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    cursor: pointer !important;
    margin: 0 auto !important;     /* Centra el cuadrito en su celda */
    transition: transform 0.2s;
}

.preview-image:hover, .admin-img:hover {
    transform: scale(1.1);
    border-color: #673ab7 !important;
}

/* =========================================
   5. VISOR CARRUSEL FULLSCREEN (CENTRADITO)
   ========================================= */
.lightbox {
    display: none; /* Oculto por defecto */
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.95);
    z-index: 99999;
    justify-content: center; /* Centra horizontalmente */
    align-items: center;     /* Centra verticalmente */
}

.lightbox.active {
    display: flex !important; /* Forza que use Flexbox al activarse */
}

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    max-width: 800px;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 75vh; /* Evita que se salga de la pantalla arriba o abajo */
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.8);
    object-fit: contain; /* Muestra la foto completa sin recortar */
}

.close-btn {
    position: absolute;
    top: -45px; right: 0;
    color: white;
    font-size: 40px;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
    z-index: 100000;
}

.lightbox-nav {
    display: flex;
    gap: 20px;
    margin-top: 25px;
    width: 100%;
    justify-content: center;
}

.lightbox-nav button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 1rem;
    padding: 12px 25px;
    border-radius: 30px;
    cursor: pointer;
    transition: 0.3s;
    font-family: 'Poppins', sans-serif;
    min-width: 120px;
}

.lightbox-nav button:hover { background: white; color: black; }

/* =========================================
   6. PANEL DE ADMINISTRADOR (ORDENADO)
   ========================================= */
.admin-body { 
    background: #f4f4f9; 
    padding: 20px; 
    display: block; /* Quita el flex de body para admin */
}

.admin-wrapper { 
    max-width: 900px; 
    margin: 0 auto; 
    padding-top: 20px; 
}

.family-section {
    background: white; border-radius: 15px; padding: 20px; margin-bottom: 25px; box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.family-header {
    display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #f3e5f5; padding-bottom: 15px; margin-bottom: 15px; flex-wrap: wrap; gap: 15px;
}

.family-header h3 { margin: 0; color: #512da8; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.badge { background: #ede7f6; color: #673ab7; font-size: 0.8rem; padding: 4px 10px; border-radius: 20px; }
.btn-download-all { background: linear-gradient(135deg, #673ab7 0%, #512da8 100%); color: white; padding: 10px 20px; border-radius: 25px; text-decoration: none; font-size: 0.85rem; font-weight: 600; text-align: center; }

.photo-carousel {
    display: flex; overflow-x: auto; gap: 10px; padding-bottom: 15px; scroll-snap-type: x mandatory;
}
.photo-carousel::-webkit-scrollbar { height: 8px; }
.photo-carousel::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.photo-carousel::-webkit-scrollbar-thumb { background: #d1c4e9; border-radius: 10px; }

.carousel-item { flex: 0 0 auto; width: 80px; position: relative; scroll-snap-align: start; }