/* 共用 FileUpload 元件樣式 */
.file-upload-component {
    display: block;
    margin-bottom: .5rem;
}

.file-upload-btn {
    margin-bottom: .5rem;
}

/* show-hint 上傳限制說明（格式、單檔上限、檔案數） */
.file-upload-hint {
    margin-top: -.25rem;
    margin-bottom: .5rem;
    font-size: .875em;
    color: var(--bs-secondary-color, #6c757d);
}

.file-upload-cards {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.file-upload-card {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .6rem;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    background: #f8f9fa;
    max-width: 100%;
}

.file-upload-card .file-upload-name {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 檔名為下載連結：平時不帶底線，hover 才顯示 */
.file-upload-card a.file-upload-name {
    text-decoration: none;
}

.file-upload-card a.file-upload-name:hover {
    text-decoration: underline;
}

/* 圖片檔卡片：縮圖直排版（縮圖在上、檔名在下、移除鈕浮於縮圖右上角） */
.file-upload-card-image {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    padding: .35rem;
}

.file-upload-card-image .file-upload-thumb {
    display: block;
}

.file-upload-card-image .file-upload-thumb img {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: .25rem;
    cursor: zoom-in;
}

/* 舊圖片格式預設縮圖：不載入原圖，以方框 + 圖片圖示 + 副檔名表示；點擊開新分頁（不走 PhotoSwipe） */
.file-upload-card-image .file-upload-thumb-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    width: 120px;
    height: 120px;
    border: 1px dashed #adb5bd;
    border-radius: .25rem;
    background: #e9ecef;
    color: #6c757d;
    text-decoration: none;
}

.file-upload-card-image .file-upload-thumb-placeholder::before {
    content: "";
    width: 40px;
    height: 32px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 32' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Crect x='1' y='1' width='38' height='30' rx='3'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3Cpath d='M1 26l11-10 8 7 6-5 13 10'/%3E%3C/svg%3E") no-repeat center / contain;
}

.file-upload-card-image .file-upload-thumb-placeholder:hover {
    border-color: #6c757d;
}

.file-upload-card-image .file-upload-thumb-placeholder-ext {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .05em;
}

.file-upload-card-image .file-upload-name {
    max-width: 120px;
    font-size: .8125rem;
}

.file-upload-card-image .file-upload-remove {
    position: absolute;
    top: .5rem;
    right: .5rem;
    padding: .25rem;
    background-color: rgba(255, 255, 255, .85);
    border-radius: 50%;
}

.file-upload-card.is-uploading {
    opacity: .6;
}

.file-upload-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid #ced4da;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: file-upload-spin .8s linear infinite;
}

@keyframes file-upload-spin {
    to { transform: rotate(360deg); }
}

.file-upload-error:empty {
    display: none;
}

.file-upload-error {
    margin-top: .25rem;
}

/* 裁切視窗：元件自帶，不依賴宿主 Bootstrap modal（z-index 高於 Bootstrap modal 1055） */
.file-upload-crop-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .5);
}

.file-upload-crop-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 2rem);
    background: #fff;
    border-radius: .5rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}

.file-upload-crop-header {
    padding: .75rem 1rem;
    font-size: 1.125rem;
    font-weight: 500;
    border-bottom: 1px solid #dee2e6;
}

.file-upload-crop-body {
    min-height: 0;
    padding: 1rem;
}

/* Cropper.js 以圖片父層尺寸作為畫布，父層須有明確高度 */
.file-upload-crop-stage {
    height: min(60vh, 540px);
}

.file-upload-crop-stage img {
    display: block;
    max-width: 100%;
}

.file-upload-crop-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .75rem 1rem;
    border-top: 1px solid #dee2e6;
}
