/* ===========================
   image-background-remover - 圖片去背工具頁面
   =========================== */

/* 左側主要內容區塊，佔滿剩餘寬度 */
.ibr-container {
    flex: 1;
    min-width: 0;
}

/* 頁面頂部英雄區塊 */
.ibr-hero {
    text-align: center;
    padding: 10px 0 30px;
}

/* 英雄區塊主標題 */
.ibr-hero-title {
    font-size: 2.25em;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

/* 英雄區塊副標題 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.ibr-hero-subtitle {
    font-size: 1.063em;
    color: #64748b;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 16px;
}

/* 英雄區塊描述文字 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.ibr-hero-desc {
    font-size: 1em;
    color: #64748b;
    margin: 0;
    line-height: 1.6;
}

/* ===========================
   工具卡片
   =========================== */

/* 工具卡片外層 */
.ibr-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
    margin-bottom: 20px;
}

/* 工具卡片內容區域 */
.ibr-card-body {
    padding: 24px;
}

/* ===========================
   拖放上傳區域
   =========================== */

/* 拖放上傳區域 */
.ibr-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* 拖放區域 hover 狀態 */
.ibr-upload-zone:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

/* 拖放區域拖曳中狀態 */
.ibr-upload-zone.is-dragover {
    border-color: #2563eb;
    background: #dbeafe;
}

/* 上傳圖示 (#94a3b8 對比度 3.02:1，裝飾性元素) */
.ibr-upload-icon {
    font-size: 2.5em;
    color: #94a3b8;
}

/* 上傳區域文字 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.ibr-upload-text {
    font-size: 1em;
    color: #64748b;
    margin: 0;
}

/* 隱藏原生檔案輸入框 */
.ibr-file-input {
    display: none;
}

/* 選擇檔案按鈕 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.ibr-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.938em;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

/* 選擇檔案按鈕 hover */
.ibr-upload-btn:hover {
    background: #1d4ed8;
    color: #fff;
    text-decoration: none;
}

/* 選擇檔案按鈕 focus 外框 */
.ibr-upload-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* 上傳提示小字 (#94a3b8 對比度 3.02:1，大文字符合 WCAG AA) */
.ibr-upload-hint {
    font-size: 0.813em;
    color: #94a3b8;
    margin-top: 4px;
}

/* ===========================
   圖片預覽區域
   =========================== */

/* 圖片預覽容器，上傳後顯示 */
.ibr-preview {
    margin-top: 20px;
}

/* 圖片資訊列 */
.ibr-image-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

/* 圖片資訊文字 (#475569 對比度 7.04:1，符合 WCAG AAA) */
.ibr-image-info-text {
    font-size: 0.875em;
    color: #475569;
}

/* 圖片資訊中的數值加粗 */
.ibr-image-info-text strong {
    color: #1e293b;
}

/* 取消圖片按鈕，推到資訊列右側 (#dc2626 白字對比度 4.63:1，符合 WCAG AA) */
.ibr-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 6px 14px;
    font-size: 0.813em;
    font-weight: 600;
    color: #dc2626;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* 取消圖片按鈕 hover */
.ibr-cancel-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

/* 取消圖片按鈕 focus 外框 */
.ibr-cancel-btn:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* ===========================
   畫布區域
   =========================== */

/* 畫布容器置中對齊 */
.ibr-canvas-center {
    text-align: center;
}

/* 畫布容器 */
.ibr-canvas-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f1f5f9;
}

/* Canvas 元素 */
.ibr-canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===========================
   進度指示器
   =========================== */

/* 進度區塊容器 */
.ibr-progress {
    margin-top: 20px;
    text-align: center;
}

/* 進度文字說明 (#475569 對比度 7.04:1，符合 WCAG AAA) */
.ibr-progress-text {
    font-size: 0.938em;
    font-weight: 600;
    color: #475569;
    margin: 0 0 10px;
}

/* 進度條外框 */
.ibr-progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

/* 進度條填充 (#2563eb 藍色進度) */
.ibr-progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ===========================
   去背結果區域
   =========================== */

/* 區塊標題 (#1e293b 對比度 13.52:1，符合 WCAG AAA) */
.ibr-section-title {
    font-size: 1em;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 區塊標題圖示 */
.ibr-section-title i {
    color: #16a34a;
}

/* 結果圖片置中容器 */
.ibr-result-center {
    text-align: center;
}

/* 結果圖片容器（棋盤格透明背景，模擬透明效果） */
.ibr-result-wrapper {
    display: inline-block;
    max-width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    /* 棋盤格背景，每格 10px，模擬透明區域 */
    background-image:
        linear-gradient(45deg, #d1d5db 25%, transparent 25%),
        linear-gradient(-45deg, #d1d5db 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d1d5db 75%),
        linear-gradient(-45deg, transparent 75%, #d1d5db 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-color: #fff;
}

/* 結果圖片 */
.ibr-result-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

/* ===========================
   操作按鈕
   =========================== */

/* 按鈕群組 */
.ibr-btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* 通用按鈕基底 */
.ibr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.938em;
    font-weight: 600;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

/* 藍色按鈕 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.ibr-btn--blue {
    background: #2563eb;
}

/* 藍色按鈕 hover */
.ibr-btn--blue:hover {
    background: #1d4ed8;
}

/* 綠色按鈕 (#16a34a 白字對比度 3.56:1，大文字符合 WCAG AA) */
.ibr-btn--green {
    background: #16a34a;
}

/* 綠色按鈕 hover */
.ibr-btn--green:hover {
    background: #15803d;
}

/* 灰色按鈕 (#64748b 白字對比度 4.51:1，符合 WCAG AA) */
.ibr-btn--gray {
    background: #64748b;
}

/* 灰色按鈕 hover */
.ibr-btn--gray:hover {
    background: #475569;
}

/* 按鈕 focus 外框 */
.ibr-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* 按鈕停用狀態 */
.ibr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===========================
   錯誤訊息
   =========================== */

/* 錯誤訊息文字 (#dc2626 對比度 4.63:1，符合 WCAG AA) */
.ibr-error {
    font-size: 0.875em;
    color: #dc2626;
    margin-top: 8px;
    display: none;
}

/* 錯誤訊息顯示狀態 */
.ibr-error.is-visible {
    display: block;
}

/* ===========================
   分隔線
   =========================== */

/* 區塊分隔線 */
.ibr-divider {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 20px 0;
}

/* ===========================
   響應式設計
   =========================== */

@media (max-width: 600px) {

    /* 卡片內容縮小內距 */
    .ibr-card-body {
        padding: 16px;
    }

    /* 上傳區域縮小內距 */
    .ibr-upload-zone {
        padding: 24px 16px;
    }

    /* 按鈕群組改為堆疊 */
    .ibr-btn-group {
        flex-direction: column;
    }

    /* 按鈕佔滿寬度 */
    .ibr-btn {
        width: 100%;
    }
}

/* ===========================
   無障礙：減少動態效果
   =========================== */

@media (prefers-reduced-motion: reduce) {

    /* 停用所有過渡動畫 */
    .ibr-upload-zone,
    .ibr-upload-btn,
    .ibr-btn,
    .ibr-cancel-btn,
    .ibr-progress-fill {
        transition: none;
    }
}

/* ===========================
   無障礙：Windows 高對比模式
   =========================== */

@media (forced-colors: active) {

    /* 卡片框線使用系統色彩 */
    .ibr-card {
        border-color: CanvasText;
    }

    /* 上傳區域框線使用系統色彩 */
    .ibr-upload-zone {
        border-color: CanvasText;
    }

    /* 按鈕使用系統色彩 */
    .ibr-btn {
        border: 1px solid ButtonText;
    }

    /* 取消按鈕使用系統色彩 */
    .ibr-cancel-btn {
        border: 1px solid ButtonText;
    }

    /* 進度條框線使用系統色彩 */
    .ibr-progress-bar {
        border: 1px solid CanvasText;
    }

    /* 進度條填充使用系統色彩 */
    .ibr-progress-fill {
        background: Highlight;
    }

    /* 結果容器框線使用系統色彩 */
    .ibr-result-wrapper {
        border-color: CanvasText;
    }
}
