/* ===================================
   AG Gallery Modal — v6
   Full-screen inmersivo sin panel.
   Botón WhatsApp en topbar.
   =================================== */

/* ── Overlay ── */
.ag-gallery-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    overflow: hidden;
    background: #04040e;
}
.ag-gallery-modal.active {
    display: block;
}

/* ── Contenedor ── */
.ag-gallery-container {
    position: absolute;
    inset: 0;
}

/* ── Foto de fondo desenfocada ── */
.ag-blur-bg {
    position: absolute;
    inset: -14%;
    background-size: cover;
    background-position: center;
    filter: blur(60px) brightness(0.20) saturate(1.8);
    transition: background-image 0.22s ease;
    z-index: 0;
    will-change: background-image;
}

/* ── Sección de imagen ── */
.ag-gallery-image-section {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    cursor: grab;
}
.ag-gallery-image-section:active { cursor: grabbing; }

.ag-gallery-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 68px 52px 10px;
}

.ag-gallery-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 10px;
    box-shadow:
        0 40px 120px rgba(0,0,0,0.80),
        0 0 0 1px rgba(255,255,255,0.05);
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform-origin: center center;
}

.ag-gallery-image.is-loading {
    opacity: 0;
    transform: scale(0.97);
}

/* ── Spinner ── */
.ag-gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border: 2.5px solid rgba(255,255,255,0.10);
    border-top-color: rgba(255,255,255,0.80);
    border-radius: 50%;
    animation: agSpin 0.7s linear infinite;
    z-index: 5;
    display: none;
}
@keyframes agSpin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* ── Barra superior: contador izq + cerrar der ── */
.ag-gallery-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: linear-gradient(180deg, rgba(0,0,0,0.72) 0%, transparent 100%);
    z-index: 30;
}

.ag-gallery-counter {
    color: rgba(255,255,255,0.75);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3.5px;
    font-family: 'Courier New', monospace;
    user-select: none;
}

.ag-gallery-close {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.ag-gallery-close:hover {
    background: rgba(255,255,255,0.22);
    transform: rotate(90deg) scale(1.1);
}
.ag-gallery-close i { color: #fff; font-size: 15px; }

/* ── Flechas laterales ── */
.ag-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.22s ease;
    opacity: 0;
}
.ag-gallery-modal.active .ag-gallery-arrow { opacity: 0.60; }
.ag-gallery-arrow:hover { background: rgba(255,255,255,0.20); opacity: 1; transform: translateY(-50%) scale(1.08); }
.ag-gallery-arrow.disabled { opacity: 0.08 !important; cursor: not-allowed; pointer-events: none; }
.ag-gallery-arrow i { color: #fff; font-size: 14px; }
.ag-gallery-prev { left: 20px; }
.ag-gallery-next { right: 20px; }

/* ── Dots de navegación (panel imagen) ── */
.ag-gallery-dots {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 7px;
    z-index: 12;
}
.ag-gallery-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.30);
    transition: all 0.25s ease;
    cursor: pointer;
    border: none;
    padding: 0;
}
.ag-gallery-dot.active {
    background: #ffffff;
    width: 22px;
    border-radius: 4px;
}
.ag-gallery-dot:hover { background: rgba(255,255,255,0.65); }

/* Ocultar dots si hay más de 18 imágenes */
.ag-gallery-dots.hidden { display: none; }

/* ── Botón WhatsApp en topbar ── */
.ag-gallery-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: #ffffff;
    text-decoration: none;
    padding: 0 16px;
    height: 38px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: background 0.22s ease, box-shadow 0.22s ease;
    box-shadow: 0 4px 16px rgba(37,211,102,0.40);
    white-space: nowrap;
}
.ag-gallery-wa-btn:hover {
    background: #1fba58;
    box-shadow: 0 6px 22px rgba(37,211,102,0.55);
    color: #ffffff;
}
.ag-gallery-wa-btn i { font-size: 18px; }
.ag-gallery-wa-btn span { display: none; }

@media (min-width: 480px) {
    .ag-gallery-wa-btn span { display: inline; }
}

/* Gallery trigger */
.gallery-trigger { cursor: pointer; }

/* ── Responsive: desktop ── */
@media (min-width: 768px) {
    .ag-gallery-image-wrap { padding: 68px 90px 28px; }
    .ag-gallery-dots { bottom: 28px; }
}

@media (min-width: 992px) {
    .ag-gallery-arrow { opacity: 0; }
    .ag-gallery-modal.active:hover .ag-gallery-arrow,
    .ag-gallery-modal.active .ag-gallery-arrow:focus { opacity: 0.55; }
    .ag-gallery-arrow:hover { opacity: 1 !important; }
}
.ag-gallery-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
}

/* Gradiente de fade hacia arriba */
.ag-gallery-panel::before {
    content: '';
    display: block;
    height: 100px;
    background: linear-gradient(0deg, rgba(0,0,0,0.88) 0%, transparent 100%);
    pointer-events: none;
}

/* Cuerpo del panel */
.ag-gallery-panel-body {
    background: rgba(8, 8, 22, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 14px 20px 18px;
}

/* Cabecera siempre visible: título + botón expandir */
.ag-gallery-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ag-gallery-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Botón expandir / contraer descripción */
.ag-gallery-expand-btn {
    flex-shrink: 0;
    height: 28px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.ag-gallery-expand-btn:hover { border-color: rgba(255,255,255,0.5); }
.ag-gallery-expand-btn .btn-label {
    color: rgba(255,255,255,0.75);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.ag-gallery-expand-btn i { color: rgba(255,255,255,0.6); font-size: 10px; transition: transform 0.3s ease; }
.ag-gallery-panel.expanded .ag-gallery-expand-btn i { transform: rotate(180deg); }

/* Descripción: colapsada por defecto */
.ag-gallery-panel-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                opacity   0.35s ease;
    opacity: 0;
}
.ag-gallery-panel.expanded .ag-gallery-panel-detail {
    max-height: 360px;
    opacity: 1;
}

/* Contenido del detalle */
.ag-gallery-panel-detail-inner {
    padding-top: 18px;
}

.ag-gallery-subtitle {
    font-size: 9.5px;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 3.5px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ag-gallery-subtitle::before {
    content: '';
    width: 16px;
    height: 1.5px;
    background: #4a4aff;
    border-radius: 2px;
    flex-shrink: 0;
}

.ag-gallery-description {
    font-size: 14px;
    line-height: 1.80;
    color: #ffffff;
    margin-bottom: 0;
}
.ag-gallery-description p { margin-bottom: 10px; color: #ffffff; }
.ag-gallery-description p:last-child { margin-bottom: 0; }

.ag-gallery-contact-btn {
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #191970;
    color: #ffffff;
    text-decoration: none;
    padding: 13px 0;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: all 0.26s ease;
    box-shadow: 0 5px 22px rgba(25,25,112,0.45);
    width: 100%;
}
.ag-gallery-contact-btn:hover {
    background: #25d366;
    box-shadow: 0 8px 28px rgba(37,211,102,0.48);
    color: #ffffff;
}
.ag-gallery-contact-btn i { font-size: 18px; }

/* Gallery trigger */
.gallery-trigger { cursor: pointer; }

/* ── Responsive: desktop (panel horizontal) ── */
@media (min-width: 768px) {

    .ag-gallery-image-wrap {
        padding: 68px 90px 10px;
    }

    .ag-gallery-panel {
        flex-direction: row;
        align-items: stretch;
        padding: 0 36px 28px;
        background: none;
    }

    .ag-gallery-panel::before { display: none; }

    .ag-gallery-panel-body {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 18px 28px;
        border-radius: 16px;
        width: 100%;
        background: rgba(8, 8, 22, 0.80);
    }

    .ag-gallery-panel-head {
        width: 100%;
        flex-direction: row;
        align-items: center;
    }

    .ag-gallery-title {
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Botón expandir visible en desktop */
    .ag-gallery-expand-btn { display: flex; }

    .ag-gallery-panel-detail {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-height 0.36s ease, opacity 0.28s ease;
    }
    .ag-gallery-panel.expanded .ag-gallery-panel-detail {
        max-height: 300px;
        opacity: 1;
    }

    /* En desktop expandido: layout en columna dentro del panel-body */
    .ag-gallery-panel.expanded .ag-gallery-panel-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .ag-gallery-panel.expanded .ag-gallery-panel-head {
        width: 100%;
    }

    .ag-gallery-panel-detail-inner {
        padding-top: 4px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .ag-gallery-subtitle { display: flex; }

    .ag-gallery-description {
        font-size: 13px;
        color: rgba(255,255,255,0.88);
        display: block;
        overflow: visible;
        -webkit-line-clamp: unset;
        margin-bottom: 0;
    }
    .ag-gallery-description p { display: block; margin-bottom: 8px; }
    .ag-gallery-description p:last-child { margin-bottom: 0; }

    /* Estado colapsado desktop: 1 línea tenue debajo del título */
    .ag-gallery-panel-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }
    .ag-gallery-panel:not(.expanded) .ag-gallery-panel-head::after {
        content: attr(data-preview);
        font-size: 12px;
        color: rgba(255,255,255,0.50);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 480px;
        display: block;
    }

    .ag-gallery-contact-btn {
        margin-top: 0;
        width: auto;
        padding: 12px 24px;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .ag-gallery-dots { bottom: 100px; }
}

@media (min-width: 992px) {
    .ag-gallery-arrow { opacity: 0; }
    .ag-gallery-modal.active:hover .ag-gallery-arrow,
    .ag-gallery-modal.active .ag-gallery-arrow:focus { opacity: 0.55; }
    .ag-gallery-arrow:hover { opacity: 1 !important; }
}
