/* ============================================
   galeria.css - Estilos de galería híbrida
   Soporta Grid, Masonry y Slider
   ============================================ */

/* --- MODAL GENÉRICO --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(22, 18, 16, 0.55);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding: 72px 20px 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: min(100%, 420px);
    background: #fff;
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    border: 1px solid #e8ddd0;
    margin-top: 0;
    transform: translateY(0);
}

.modal-title {
    margin: 0 0 0.8rem;
    font-size: 1.4rem;
    color: #3d352c;
    font-family: 'Playfair Display', serif;
}

.modal-body {
    margin: 0 0 1.5rem;
    color: #5f5548;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

.modal-footer .btn {
    min-width: 110px;
}

/* --- CONTENEDOR PRINCIPAL --- */
.galeria-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Inter', sans-serif;
}

.galeria-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.galeria-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f5f5f5;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: #efefef;
    color: #000;
}

/* --- DASHBOARD --- */
.galeria-dashboard {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
}

.galeria-sidebar {
    background: #f9f9f9;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 24px 0;
    padding: 0;
}

.section-group {
    margin-bottom: 28px;
}

.section-group:last-child {
    margin-bottom: 0;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* --- DROP ZONE --- */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
}

.drop-zone:hover {
    border-color: #999;
    background: #f5f5f5;
}

.drop-zone.dragover {
    border-color: #6c63ff;
    background: #efeaff;
}

.drop-zone i {
    font-size: 40px;
    color: #999;
    margin-bottom: 12px;
    display: block;
}

.drop-zone p {
    margin: 8px 0;
    color: #333;
    font-weight: 500;
}

.drop-zone span {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* --- CONTROLES DE GALERÍA --- */
.gallery-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-row label {
    font-size: 12px;
    color: #555;
    font-weight: 500;
}

.control-row select,
.control-row input {
    padding: 8px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #333;
    font-family: inherit;
}

.control-row select:focus,
.control-row input:focus {
    outline: none;
    border-color: #6c63ff;
    box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.1);
}

.btn-save {
    padding: 8px 14px;
    background: #6c63ff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-save:hover {
    background: #5a52d5;
    transform: translateY(-1px);
}

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

/* --- ALERTAS --- */
.alert {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- MAIN CONTENT --- */
.galeria-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* --- LISTA ADMIN DE IMÁGENES --- */
.portfolio-admin-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
    min-height: 100px;
    align-content: flex-start;
}

.portfolio-admin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.portfolio-admin-item:hover {
    border-color: #6c63ff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.1);
}

.portfolio-admin-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.file-name {
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    color: #333;
}

.delete-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    opacity: 0;
    transition: all 0.2s ease;
}

.portfolio-admin-item:hover .delete-image-btn {
    opacity: 1;
}

.delete-image-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* --- GALERÍA VACÍA --- */
.portfolio-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #999;
    text-align: center;
}

.portfolio-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.portfolio-empty p {
    margin: 4px 0;
    font-size: 14px;
}

/* ============================================
   MODOS DE GALERÍA
   ============================================ */

/* --- GALERÍA PRINCIPAL (base) --- */
.portfolio-gallery {
    width: 100%;
    min-height: 300px;
    transition: all 0.3s ease;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
}

.preview-gallery {
    width: 100%;
    min-height: 250px;
    transition: all 0.3s ease;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
}

/* --- MODO GRID --- */
.portfolio-gallery.grid-mode {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(var(--cols, 3), 1fr);
}

.portfolio-gallery.grid-mode .portfolio-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.25s ease;
    cursor: pointer;
    background: #f0f0f0;
    aspect-ratio: 1;
}

.portfolio-gallery.grid-mode .portfolio-item:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.portfolio-gallery.grid-mode .portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.portfolio-gallery.grid-mode .portfolio-item:hover img {
    transform: scale(1.05);
}

/* --- MODO MASONRY --- */
.portfolio-gallery.masonry-mode {
    column-count: var(--cols, 3);
    column-gap: 16px;
}

.portfolio-gallery.masonry-mode .portfolio-item {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.25s ease;
    cursor: pointer;
    background: #f0f0f0;
}

.portfolio-gallery.masonry-mode .portfolio-item:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.portfolio-gallery.masonry-mode .portfolio-item img {
    width: 100%;
    display: block;
    height: auto;
    transition: transform 0.3s ease;
}

.portfolio-gallery.masonry-mode .portfolio-item:hover img {
    transform: scale(1.03);
}

/* --- MODO SLIDER --- */
.portfolio-gallery.slider-mode {
    width: 100%;
    position: relative;
    padding-bottom: 50px;
    display: block;
    overflow: hidden;
    background: transparent;
    border: none;
    padding: 0;
}

.portfolio-gallery.slider-mode .portfolio-item {
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.portfolio-gallery.slider-mode .portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================
   ESTILOS DE SWIPER
   ============================================ */

.swiper {
    width: 100%;
    overflow: hidden;
}

.swiper-wrapper {
    display: flex;
    transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.swiper-slide {
    flex-shrink: 0;
    width: 100%;
    height: auto;
}

/* Paginación */
.swiper-pagination {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    transition: opacity 0.3s;
}

.swiper-pagination-bullet {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    opacity: 0.7;
    margin: 0 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
    background: #6c63ff;
    opacity: 1;
}

/* Navegación */
.swiper-button-next,
.swiper-button-prev {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    transition: all 0.3s ease;
    z-index: 10;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(108, 99, 255, 0.8);
}

.swiper-button-prev {
    left: 10px;
}

.swiper-button-next {
    right: 10px;
}

.swiper-button-prev::after,
.swiper-button-next::after {
    content: '';
}

.swiper-button-prev::before {
    content: '‹';
    font-size: 24px;
}

.swiper-button-next::before {
    content: '›';
    font-size: 24px;
}

/* ============================================
   PHOTOSWIPE CUSTOMIZACIÓN
   ============================================ */

.pswp {
    z-index: 1000;
}

.pswp__bg {
    background: #000;
}

.pswp__scroll-wrap {
    overflow: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .galeria-dashboard {
        grid-template-columns: 1fr;
    }

    .galeria-sidebar {
        position: static;
    }

    .portfolio-gallery.grid-mode,
    .portfolio-gallery.masonry-mode {
        grid-template-columns: repeat(2, 1fr);
        --cols: 2 !important;
    }

    .portfolio-gallery.masonry-mode {
        column-count: 2;
    }
}

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

    .galeria-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .galeria-header h1 {
        font-size: 24px;
    }

    .portfolio-gallery.grid-mode,
    .portfolio-gallery.masonry-mode {
        grid-template-columns: repeat(1, 1fr);
        --cols: 1 !important;
        gap: 12px;
    }

    .portfolio-gallery.masonry-mode {
        column-count: 1;
    }

    .portfolio-admin-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .portfolio-gallery.grid-mode .portfolio-item,
    .portfolio-gallery.masonry-mode .portfolio-item {
        aspect-ratio: auto;
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .portfolio-gallery.slider-mode .portfolio-item {
        aspect-ratio: 1 / 1;
    }

    .swiper-button-next,
    .swiper-button-prev {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .swiper-pagination-bullet {
        width: 6px;
        height: 6px;
        margin: 0 3px;
    }
}
