/**
 * image-uploader.css
 * 独立图片上传插件样式（融入 Bootstrap form-horizontal 表单）
 */

/* ========== 容器（在 .col-sm-9 内） ========== */
.iu-container {
    font-size: 14px;
    color: #555;
}

/* ========== 触发按钮 — 已弃用，保留样式以免外部引用报错 ========== */
.iu-trigger {
    display: none;
}

/* ========== 拖拽/点击上传区域（始终显示） ========== */
.iu-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 20px 12px;
    text-align: center;
    background: #f9f9f9;
    transition: all 0.25s ease;
    cursor: pointer;
}

.iu-dropzone.iu-visible {
    display: block;
}

.iu-dropzone.iu-drag-over {
    border-color: #337ab7;
    background: #e8f2fc;
}

.iu-dropzone-icon {
    width: 36px;
    height: 36px;
    margin: 0 auto 6px;
    fill: #bbb;
    transition: fill 0.2s;
}

.iu-dropzone.iu-drag-over .iu-dropzone-icon {
    fill: #337ab7;
}

.iu-dropzone-text {
    color: #999;
    font-size: 13px;
    line-height: 1.5;
}

.iu-dropzone-text strong {
    color: #337ab7;
}

/* ========== 缩略图预览区 — 表单内紧凑排列 ========== */
.iu-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

/* 单个缩略图卡片 */
.iu-item {
    position: relative;
    width: 88px;
    height: 88px;
    border: 1px solid #ddd;
    border-radius: 3px;
    overflow: hidden;
    background: #f5f5f5;
    flex-shrink: 0;
    animation: iuFadeIn 0.25s ease;
}

@keyframes iuFadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.iu-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.iu-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

/* 删除按钮 */
.iu-btn-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.iu-item:hover .iu-btn-remove {
    opacity: 1;
}

.iu-btn-remove:hover {
    background: #d9534f !important;
}

/* 编辑模式：原始已有图片 — 删除按钮始终可见 */
.iu-btn-visible {
    opacity: 1 !important;
}

/* 编辑模式：原始图片卡片蓝色边框提示 */
.iu-existing {
    border-color: #5bc0de;
}

/* 上传中隐藏删除按钮 */
.iu-item.iu-uploading .iu-btn-remove {
    display: none;
}

/* 缩略图可点击预览 */
.iu-item:not(.iu-uploading):not(.iu-error) .iu-thumb {
    cursor: pointer;
}

.iu-item:not(.iu-uploading):not(.iu-error):hover {
    border-color: #337ab7;
}

/* loading 遮罩 */
.iu-loading-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.iu-item:not(.iu-uploading) .iu-loading-mask {
    display: none;
}

/* spinner */
.iu-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: #337ab7;
    border-radius: 50%;
    animation: iuSpin 0.55s linear infinite;
}

@keyframes iuSpin {
    to { transform: rotate(360deg); }
}

/* 错误状态 */
.iu-error-msg {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(217, 83, 79, 0.88);
    color: #fff;
    font-size: 11px;
    text-align: center;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    z-index: 1;
}

.iu-item.iu-error .iu-error-msg {
    display: block;
}

.iu-item.iu-error {
    border-color: #d9534f;
}

/* ========== Lightbox 原图预览 ========== */
.iu-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.iu-lightbox-in {
    opacity: 1;
}

.iu-lightbox-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.78);
}

.iu-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iu-lightbox-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-drag: none;
}

.iu-lightbox-close {
    position: absolute;
    top: -36px;
    right: -4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
    z-index: 2;
}

.iu-lightbox-close:hover {
    background: #fff;
    color: #d9534f;
}
.iu-footer {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.6;
}

.iu-counter {
    color: #aaa;
}

.iu-tip {
    color: #bbb;
}
