/* Tắt các style mặc định gây vỡ khung của Soledad Style 10 */
.penci-single-style-10 .penci-post-image-wrapper {
    margin-bottom: 20px !important;
}

/* Khung Gallery: Thêm padding để thumbnail không sát lề trái, giảm max-width */
.ttpg {
    --ttpg-thumb: 88px;
    --ttpg-gap: 10px;
    width: 100%;
    max-width: 960px; /* Thu nhỏ khung tổng thể */
    margin: 20px auto;
    padding: 0 24px; /* Tạo lề trống 24px hai bên trái/phải */
    box-sizing: border-box;

    display: grid;
    grid-template-columns: var(--ttpg-thumb) 1fr;
    grid-template-rows: auto auto;
    grid-template-areas: 
        "thumbs main"
        "thumbs caption";
    gap: 20px;
}
.ttpg * { box-sizing: border-box; }

.penci-single-style-10 .ttpg:not(.ttpg-ready) { visibility: hidden; }
.penci-single-style-10 .ttpg-style10 { margin: 0 auto; max-width: 960px; }
.penci-single-style-10 .ttpg-style10-host { overflow: visible; }

/* Khung ảnh chính nhỏ gọn */
.ttpg-main {
    grid-area: main;
    position: relative;
    width: 100%;
    background: #f8f8f8;
    overflow: hidden;
    border-radius: 8px;
    text-align: center;
    padding: 12px;
}
.ttpg-main-link { display: block; line-height: 0; cursor: zoom-in; }
.ttpg-main-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 480px; /* Khóa chiều cao ảnh chính ở mức 480px */
    object-fit: contain;
    margin: 0 auto;
}

/* Nút chuyển ảnh chính */
.ttpg-arrow {
    appearance: none;
    border: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    color: #222222;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    font-size: 22px;
    line-height: 36px;
    cursor: pointer;
    z-index: 2;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ttpg-arrow:hover { 
    background: #ffffff; 
    transform: translateY(-50%) scale(1.08); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}
.ttpg-prev { left: 16px; }
.ttpg-next { right: 16px; }

/* Caption */
.ttpg-caption {
    grid-area: caption;
    min-height: 24px;
    padding: 8px 4px 0;
    text-align: center;
    font-size: 20px;
    line-height: 1.4;
    color: #ffffff;
    font-weight: 500;
}

/* Ẩn hoàn toàn các nút điều hướng cuộn Thumbnail */
.ttpg-thumb-arrow,
.ttpg-thumb-prev,
.ttpg-thumb-next {
    display: none !important;
}

/* Dải Thumbnail bên trái */
.ttpg-thumbs-wrap {
    grid-area: thumbs;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0;
    max-height: 480px; /* Đồng bộ chiều cao với ảnh chính */
    height: 100%;
}

/* Danh sách Thumbnail tự cuộn mượt bằng chuột/touchpad */
.ttpg-thumbs {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: var(--ttpg-gap);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0;
    scroll-behavior: smooth;

    /* Hide Scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ttpg-thumbs::-webkit-scrollbar {
    display: none;
}

/* Ô Thumbnail */
.ttpg-thumb {
    flex: 0 0 var(--ttpg-thumb);
    width: var(--ttpg-thumb);
    height: var(--ttpg-thumb);
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    cursor: pointer;
    opacity: .75;
    transition: all .2s ease;
}
.ttpg-thumb:hover { opacity: 1; }
.ttpg-thumb.is-active { 
    opacity: 1; 
    border-color: #222222; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.ttpg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Khóa chiều cao tối đa cho Style 10 của Soledad */
.penci-single-style-10 .penci-post-image-wrapper .ttpg-main-image { 
    max-height: 480px; 
}
.penci-single-style-10 .penci-post-image-wrapper .ttpg-caption:empty { 
    display: none; 
}

/* Responsive Mobile (<767px) */
@media (max-width: 767px) {
    .ttpg { 
        display: block; 
        margin: 16px auto; 
        padding: 0 12px;
        --ttpg-thumb: 72px; 
    }
    .ttpg-main { padding: 8px; }
    .ttpg-main-image,
    .penci-single-style-10 .penci-post-image-wrapper .ttpg-main-image { 
        max-height: 380px; 
    }
    
    .ttpg-thumbs-wrap {
        flex-direction: row;
        margin-top: 10px;
        max-height: none;
        height: auto;
    }
    .ttpg-thumbs {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .ttpg-thumb {
        border-radius: 6px;
    }
    
    .penci-single-style-10 .penci-post-image-wrapper .ttpg { margin: 0; }
}