/* ============================================================
   Lucas Gallery Pro — Frontend Styles v12
============================================================ */

/* ===== BASE ===== */
.lg-gallery {
    width: 100%;
    box-sizing: border-box;
}
.lg-gallery *,
.lg-gallery *::before,
.lg-gallery *::after { box-sizing: border-box; }

.lg-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--lg-radius, 4px);
}
.lg-link {
    display: block;
    overflow: hidden;
    position: relative;
    border-radius: var(--lg-radius, 4px);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    width: 100%;
    text-align: left;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.lg-item img {
    display: block;
    width: 100%;
}
/* <picture> envuelve <img> — debe comportarse igual que el img */
.lg-item picture {
    display: block;
    width: 100%;
    height: 100%;
}
.lg-item picture img {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   LAYOUTS
============================================================ */

/* GRID — CSS puro, columnas iguales */
.lg-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--lg-cols, 3), 1fr);
    gap: var(--lg-gap, 8px);
}
.lg-layout-grid .lg-item img {
    height: 220px;
    object-fit: cover;
}

/*
 * MASONRY — orden CORRELATIVO 1,2,3...
 * Posicionamiento JS: cada .lg-item recibe position:absolute
 * con top/left/width/height calculados por applyMasonry().
 * El contenedor también es position:relative (asignado por JS).
 */
.lg-layout-masonry {
    /* Mientras carga JS, ocultamos para evitar flash desordenado */
    position: relative;
    min-height: 200px;
}
.lg-layout-masonry .lg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* JUSTIFIED — controlado por JS */
.lg-layout-justified {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}
.lg-layout-justified .lg-item {
    overflow: hidden;
    flex-shrink: 0;
}
.lg-layout-justified .lg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* MOSAIC — CSS puro */
.lg-layout-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--lg-cols, 3), 1fr);
    gap: var(--lg-gap, 8px);
    grid-auto-rows: 200px;
}
.lg-layout-mosaic .lg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.lg-layout-mosaic .lg-item:nth-child(1) {
    grid-column: span 2;
    grid-row: span 2;
}
.lg-layout-mosaic .lg-item:nth-child(7n+1):not(:first-child) {
    grid-column: span 2;
    grid-row: span 2;
}

/* ============================================================
   HOVER
============================================================ */
.lg-hover-zoom .lg-item img {
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}
.lg-hover-zoom .lg-item:hover img { transform: scale(1.08); }

.lg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.38);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    gap: 8px;
}
.lg-hover-overlay .lg-item:hover .lg-overlay,
.lg-hover-overlay .lg-link:hover .lg-overlay { opacity: 1; }
.lg-overlay-icon {
    width: 36px; height: 36px; color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.lg-overlay-caption {
    color: #fff;
    font-size: 0.85rem;
    text-align: center;
    padding: 0 12px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    line-height: 1.3;
}

.lg-caption {
    padding: 6px 8px 8px;
    font-size: 0.82rem;
    color: #555;
    text-align: center;
    line-height: 1.4;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 680px) {
    .lg-layout-grid .lg-item img { height: 160px; }
    .lg-layout-mosaic { grid-auto-rows: 150px; }
}
@media (max-width: 420px) {
    .lg-layout-mosaic .lg-item:nth-child(1) {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* GALERÍA ANCHO COMPLETO EN MÓVIL */
@media (max-width: 480px) {
    .lg-gallery {
        width:        100vw !important;
        max-width:    100vw !important;
        position:     relative !important;
        left:         50% !important;
        right:        50% !important;
        margin-left:  -50vw !important;
        margin-right: -50vw !important;
        box-sizing:   border-box !important;
    }
}

/* ============================================================
   LIGHTBOX
============================================================ */
.lg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999990;
    display: none;
    align-items: center;
    justify-content: center;
}
.lg-lightbox.lg-active { display: flex; }

.lg-lb-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.95);
    cursor: pointer;
}

.lg-lb-close {
    position: fixed;
    top: 14px; right: 16px;
    z-index: 10;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 42px; height: 42px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    padding: 0;
    line-height: 1;
}
.lg-lb-close:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg);
}

.lg-lb-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
    font-size: 1.5rem;
}
.lg-lb-nav:hover { background: rgba(255,255,255,0.28); }
.lg-lb-nav:disabled { opacity: 0.18; cursor: default; pointer-events: none; }
.lg-lb-prev { left: 10px; }
.lg-lb-next { right: 10px; }

.lg-lb-container {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95vw;
    max-height: 95vh;
}

.lg-lb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-width: 90vw;
    max-height: 82vh;
    cursor: zoom-in;
    border-radius: 3px;
}
.lg-lb-img-wrap.lg-zoomed { cursor: grab; overflow: visible; }
.lg-lb-img-wrap.lg-zoomed:active { cursor: grabbing; }

.lg-lb-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
}

.lg-lb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    min-height: 80px;
}
.lg-lb-spinner {
    width: 38px; height: 38px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: lg-spin 0.75s linear infinite;
}
@keyframes lg-spin { to { transform: rotate(360deg); } }

.lg-lb-toolbar {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 90vw;
    padding: 10px 0 0;
    gap: 10px;
    flex-wrap: wrap;
}
.lg-lb-counter {
    color: rgba(255,255,255,0.55);
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 44px;
}
.lg-lb-caption {
    color: rgba(255,255,255,0.85);
    font-size: 0.88rem;
    flex: 1;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.lg-lb-actions { display: flex; gap: 6px; flex-shrink: 0; }
.lg-lb-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.22);
    color: #fff;
    padding: 6px 13px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.2;
}
.lg-lb-btn:hover { background: rgba(255,255,255,0.24); transform: translateY(-1px); }
.lg-lb-btn:active { transform: translateY(0); }
.lg-lb-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

@media (max-width: 600px) {
    .lg-lightbox { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
    .lg-lb-nav { width: 38px; height: 38px; font-size: 1.2rem; }
    .lg-lb-prev { left: 4px; }
    .lg-lb-next { right: 4px; }
    .lg-lb-close { top: 10px; right: 10px; width: 36px; height: 36px; }
    .lg-lb-img { max-width: 100vw !important; max-height: 70vh !important; }
    .lg-lb-img-wrap { max-width: 100vw !important; max-height: 70vh !important; }
    .lg-lb-toolbar { padding: 8px 6px 0; gap: 5px; flex-wrap: wrap; }
    .lg-lb-btn { padding: 5px 10px; font-size: 0.72rem; }
    .lg-lb-caption { font-size: 0.78rem; max-width: 60vw; }
    .lg-lb-counter { min-width: 36px; }
}

/* ============================================================
   TOAST
============================================================ */
#lg-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 9999999;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s ease;
}
#lg-toast.lg-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#lg-toast.lg-toast--success { border-left: 4px solid #4caf50; }
#lg-toast.lg-toast--error   { border-left: 4px solid #f44336; }
@media (max-width: 480px) {
    #lg-toast {
        bottom: 20px;
        font-size: 13px;
        padding: 10px 18px;
        max-width: 88vw;
        white-space: normal;
        text-align: center;
    }
}
