/* ==================================================
   横向图片展示库前端样式 - 微博风格
   ================================================== */

/* ---------- 基本容器 ---------- */
.horizontal-image-gallery {
    display: flex;
    flex-wrap: wrap;
    margin: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

/* ---------- 瀑布流模式 ---------- */
.horizontal-image-gallery.waterfall {
    display: block;
    column-count: 3;
    column-gap: 15px;
    width: 100%;
}
.horizontal-image-gallery.waterfall .hig-item {
    break-inside: avoid;
    margin-bottom: 15px;
    display: block;
}
.horizontal-image-gallery.waterfall .hig-image-container {
    height: auto !important;
    padding-bottom: 0 !important;
}
.horizontal-image-gallery.waterfall .hig-image-container img {
    position: static;
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* ---------- 默认模式 - 长宽比 ---------- */
.horizontal-image-gallery.default[data-aspect-ratio="1-1"] .hig-image-container {
    padding-bottom: 100%;
}
.horizontal-image-gallery.default[data-aspect-ratio="2-3"] .hig-image-container {
    padding-bottom: 150%;
}
.horizontal-image-gallery.default[data-aspect-ratio="3-2"] .hig-image-container {
    padding-bottom: 66.666%;
}
.horizontal-image-gallery.default[data-aspect-ratio="19.6-9"] .hig-image-container {
    padding-bottom: 217.777%;
}

/* ---------- PC端列数布局 ---------- */
.horizontal-image-gallery.default[data-columns="1"] .hig-item {
    width: 100%;
    margin: 0 0 15px;
}
.horizontal-image-gallery.default[data-columns="2"] .hig-item {
    width: calc(50% - 7.5px);
    margin: 0 15px 15px 0;
}
.horizontal-image-gallery.default[data-columns="3"] .hig-item {
    width: calc(33.333% - 10px);
    margin: 0 15px 15px 0;
}
.horizontal-image-gallery.default[data-columns="4"] .hig-item {
    width: calc(25% - 11.25px);
    margin: 0 15px 15px 0;
}
.horizontal-image-gallery.default[data-columns="5"] .hig-item {
    width: calc(20% - 12px);
    margin: 0 15px 15px 0;
}

/* 清除每行最后一个的右边距 */
.horizontal-image-gallery.default[data-columns="1"] .hig-item:nth-child(1n),
.horizontal-image-gallery.default[data-columns="2"] .hig-item:nth-child(2n),
.horizontal-image-gallery.default[data-columns="3"] .hig-item:nth-child(3n),
.horizontal-image-gallery.default[data-columns="4"] .hig-item:nth-child(4n),
.horizontal-image-gallery.default[data-columns="5"] .hig-item:nth-child(5n) {
    margin-right: 0;
}

/* ---------- 竖图/横图模式（兼容旧版） ---------- */
.horizontal-image-gallery.portrait .hig-image-container {
    padding-bottom: 150%;
}
.horizontal-image-gallery.landscape .hig-image-container {
    padding-bottom: 66.666%;
}

/* ---------- 单个图片项 ---------- */
.hig-item {
    display: block;
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: #fff;
    box-shadow: none;
    position: relative;
}
.hig-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.hig-image-container {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    width: 100%;
}
.hig-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- 控制栏 ---------- */
.hig-controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

/* 列数切换 */
.hig-columns-switcher {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0;
}
.hig-columns-btn {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    text-align: center;
}
.hig-columns-btn:hover {
    background: #e9758340;
    border-color: #e9758340;
}
.hig-columns-btn.active {
    background: #e97583;
    color: white;
    border-color: #e97583;
}
.hig-columns-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #6c757d;
    border-color: #dee2e6;
}
.hig-columns-btn:disabled:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: none;
}
.hig-columns-btn.active:disabled {
    background: #b3d7ff;
    color: #495057;
    border-color: #86b7fe;
}

/* 显示模式切换 */
.hig-display-switcher {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0;
}
.hig-display-btn {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
    text-align: center;
}
.hig-display-btn:hover {
    background: #e9758340;
    border-color: #e9758340;
}
.hig-display-btn.active {
    background: #e97583;
    color: white;
    border-color: #e97583;
}
.hig-display-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #6c757d;
    border-color: #dee2e6;
}
.hig-display-btn:disabled:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: none;
}
.hig-display-btn.active:disabled {
    background: #b3d7ff;
    color: #495057;
    border-color: #86b7fe;
}

/* ---------- 批量下载按钮 ---------- */
.hig-bulk-download-container {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
}
.hig-bulk-download-btn {
    background: #ff8745;
    color: #fff;
    border: none;
    padding: 6px 16px ;
    border-radius: 4px ;
    cursor: pointer ;
    font-size: 13px ;
    font-weight: 500 ;
    transition: background 0.2s, opacity 0.2s ;
    white-space: nowrap;
}
.hig-bulk-download-btn:hover {
    background: #ff6b35 ;
}
.hig-bulk-download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed ;
}

/* ---------- 折叠/展开 ---------- */
.hig-show-more-wrap {
    text-align: center;
    padding-bottom: 20px;
    width: 100%;
}
.hig-show-more-btn {
    display: inline-block;
    padding: 8px 24px;
    background: #fff;
    border: 1px solid #e97583;
    border-radius: 30px;
    font-size: 14px;
    color: #e97583;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(86, 185, 203, 0.1);
}
.hig-show-more-btn:hover {
    background: #e97583;
    color: #fff;
    border-color: #e97583;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(86, 185, 203, 0.2);
}
.hig-item.hig-hidden {
    display: none !important;
}

/* ---------- 预览图下载按钮（文字版） ---------- */
a.hig-download-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    background: #ff8745;
    border: 1px solid #ff8745;
    border-radius: 30px;
    color: #333;
    font-size: 12px;
    line-height: 1.4;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}
a.hig-download-btn:hover {
    background: #ff6b35;
    border-color: #ff6b35;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(86, 185, 203, 0.3);
}
a.hig-download-btn .hig-download-text {
    display: inline-block;
    line-height: 1;
    letter-spacing: 0.3px;
    color:#ffffff;
}

/* ---------- 灯箱样式 ---------- */
.hig-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}
.hig-lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* 灯箱头部（下载按钮在右，关闭按钮左侧） */
.hig-lightbox .hig-lightbox-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 15px 20px;
    z-index: 10;
    box-sizing: border-box;
    width: 100%;
}

.hig-lightbox .hig-lightbox-download {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px 22px;
    margin-right: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    cursor: pointer;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hig-lightbox .hig-lightbox-download:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: #fff;
    transform: scale(1.05);
}
.hig-lightbox .hig-lightbox-download .hig-lightbox-download-text {
    display: inline-block;
    line-height: 1;
}
/* 由 JS 控制显示 */
.hig-lightbox .hig-lightbox-download.show {
    display: inline-flex;
}

.hig-lightbox .hig-lightbox-close {
    flex-shrink: 0;
    margin-left: 0;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 300;
    backdrop-filter: blur(10px);
}
.hig-lightbox .hig-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* 灯箱内容区 */
.hig-lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 100px;
}
.hig-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 6px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}
.hig-lightbox.active .hig-lightbox-image {
    opacity: 1;
    transform: scale(1);
}

/* 计数器 */
.hig-lightbox-counter {
    position: absolute;
    top: 25px;
    left: 25px;
    text-align: left;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    z-index: 10;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease 0.1s;
}
.hig-lightbox.active .hig-lightbox-counter {
    opacity: 1;
    transform: translateY(0);
}

/* 导航按钮 */
.hig-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    font-size: 26px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
    font-weight: 300;
    opacity: 0.8;
    backdrop-filter: blur(10px);
}
.hig-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.08);
    opacity: 1;
}
.hig-lightbox-prev {
    left: 25px;
}
.hig-lightbox-next {
    right: 25px;
}

/* 缩略图列表 */
.hig-lightbox-thumbnails {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    overflow-x: auto;
    max-width: 100%;
}
.hig-thumbnail-item {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    flex-shrink: 0;
}
.hig-thumbnail-item:hover {
    opacity: 0.8;
    transform: scale(1.05);
}
.hig-thumbnail-item.active {
    opacity: 1;
    border-color: #56b9cb;
    transform: scale(1.05);
}
.hig-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 加载动画 */
.hig-lightbox-loading .hig-lightbox-image {
    opacity: 0;
}
.hig-lightbox-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: hig-spin 1s linear infinite;
}
@keyframes hig-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 禁止页面滚动 */
.hig-no-scroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* ---------- 移动端响应式 ---------- */
@media (max-width: 768px) {
    /* 列数强制 */
    .horizontal-image-gallery.default[data-columns="1"] .hig-item {
        width: 100% !important;
        margin: 0 0 15px !important;
    }
    .horizontal-image-gallery.default[data-columns="2"] .hig-item {
        width: calc(50% - 7.5px) !important;
        margin: 0 15px 15px 0 !important;
    }
    .horizontal-image-gallery.default[data-columns="2"] .hig-item:nth-child(2n) {
        margin-right: 0 !important;
    }
    .horizontal-image-gallery.default[data-columns="3"] .hig-item,
    .horizontal-image-gallery.default:not([data-columns]) .hig-item,
    .horizontal-image-gallery.default[data-columns=""] .hig-item,
    .horizontal-image-gallery.default[data-columns="4"] .hig-item,
    .horizontal-image-gallery.default[data-columns="5"] .hig-item {
        width: calc(33.333% - 10px) !important;
        margin: 0 15px 15px 0 !important;
    }
    .horizontal-image-gallery.default[data-columns="3"] .hig-item:nth-child(3n),
    .horizontal-image-gallery.default:not([data-columns]) .hig-item:nth-child(3n),
    .horizontal-image-gallery.default[data-columns=""] .hig-item:nth-child(3n),
    .horizontal-image-gallery.default[data-columns="4"] .hig-item:nth-child(3n),
    .horizontal-image-gallery.default[data-columns="5"] .hig-item:nth-child(3n) {
        margin-right: 0 !important;
    }
    .horizontal-image-gallery.waterfall {
        column-count: 1;
    }

    /* 按钮尺寸 */
    .hig-columns-btn,
    .hig-display-btn {
        padding: 5px 8px;
        font-size: 12px;
        min-width: 40px;
    }
    .hig-bulk-download-container {
        margin-left: 5px;
    }
    .hig-bulk-download-btn {
        padding: 4px 12px !important;
        font-size: 12px !important;
    }
    .hig-show-more-btn {
        padding: 6px 20px;
        font-size: 13px;
    }

    /* 灯箱 */
    .hig-lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    .hig-lightbox-prev {
        left: 15px;
    }
    .hig-lightbox-next {
        right: 15px;
    }
    .hig-lightbox-thumbnails {
        bottom: 15px;
        padding: 0 15px;
    }
    .hig-thumbnail-item {
        width: 65px;
        height: 65px;
    }
    .hig-lightbox-image {
        transform: scale(0.92);
    }
    .hig-lightbox-content {
        margin-bottom: 80px;
        max-width: 98%;
        max-height: 85vh;
    }
    .hig-lightbox .hig-lightbox-header {
        padding: 10px 15px;
    }
    .hig-lightbox .hig-lightbox-download {
        padding: 6px 16px;
        font-size: 13px;
    }
    .hig-lightbox .hig-lightbox-close {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }
    .hig-lightbox-counter {
        top: 15px;
        left: 15px;
        font-size: 14px;
        padding: 8px 14px;
        height: auto;
    }
}
@media (max-width: 768px) {
    /* 原缩略图样式 */
    .hig-thumbnail-item {
        width: 100px;   /* 从 80px 增大 */
        height: 100px;
        margin: 0 8px;  /* 增加间距 */
    }
    /* 触摸目标增大 */
    .hig-lightbox-nav {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    .hig-lightbox-prev { left: 10px; }
    .hig-lightbox-next { right: 10px; }
    /* 调整缩略图容器 */
    .hig-lightbox-thumbnails {
        gap: 15px;
        padding: 0 10px;
    }
}
/* ========== 自定义弹窗 ========== */
.hig-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.hig-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.hig-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 420px;
    width: 92%;
    padding: 30px 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hig-modal-overlay.active .hig-modal {
    transform: scale(1) translateY(0);
}

.hig-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px 0;
    line-height: 1.3;
}
.hig-modal-message {
    font-size: 15px;
    color: #4a4a6a;
    margin: 12px 0 24px 0;
    line-height: 1.6;
    white-space: pre-line;
}
.hig-modal-message .highlight {
    font-weight: 600;
    color: #e97583;
}

.hig-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.hig-modal-btn {
    padding: 10px 28px;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    background: #f0f0f5;
    color: #333;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.hig-modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.hig-modal-btn.primary {
    background: #56b9cb;
    color: #fff;
}
.hig-modal-btn.primary:hover {
    background: #3d9cae;
}
.hig-modal-btn.success {
    background: #e97583;
    color: #fff;
}
.hig-modal-btn.success:hover {
    background: #d45a6a;
}
.hig-modal-btn.cancel {
    background: transparent;
    color: #888;
}
.hig-modal-btn.cancel:hover {
    background: #f5f5f5;
}
/* 移动端强制列数：横图1列，竖图2列 */
@media (max-width: 768px) {
    /* 横图（aspect-ratio="3-2"）每行1张 */
    .horizontal-image-gallery.default[data-aspect-ratio="3-2"] .hig-item {
        width: 100% !important;
        margin: 0 0 15px !important;
    }
    /* 竖图（aspect-ratio="2-3" 及其他）每行2张 */
    .horizontal-image-gallery.default[data-aspect-ratio="2-3"] .hig-item,
    .horizontal-image-gallery.default[data-aspect-ratio="1-1"] .hig-item,
    .horizontal-image-gallery.default[data-aspect-ratio="19.6-9"] .hig-item,
    .horizontal-image-gallery.default:not([data-aspect-ratio]) .hig-item {
        width: calc(50% - 7.5px) !important;
        margin: 0 15px 15px 0 !important;
    }
    .horizontal-image-gallery.default[data-aspect-ratio="2-3"] .hig-item:nth-child(2n),
    .horizontal-image-gallery.default[data-aspect-ratio="1-1"] .hig-item:nth-child(2n),
    .horizontal-image-gallery.default[data-aspect-ratio="19.6-9"] .hig-item:nth-child(2n),
    .horizontal-image-gallery.default:not([data-aspect-ratio]) .hig-item:nth-child(2n) {
        margin-right: 0 !important;
    }
    /* 隐藏列数切换按钮（由JS控制不生成，但以防万一） */
    .hig-columns-switcher {
        display: none !important;
    }
}