/* ===========================
   image-watermark - 圖片加上浮水印工具頁面
   =========================== */

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

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

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

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

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

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

/* 工具卡片外層 */
.iw-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;
}

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

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

/* 拖放上傳區域 */
.iw-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 狀態 */
.iw-upload-zone:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

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

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

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

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

/* 選擇檔案按鈕 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.iw-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 */
.iw-upload-btn:hover {
    background: #1d4ed8;
    color: #fff;
    text-decoration: none;
}

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

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

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

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

/* 圖片資訊列 */
.iw-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) */
.iw-image-info-text {
    font-size: 0.875em;
    color: #475569;
}

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

/* 取消圖片按鈕，推到資訊列右側 (#dc2626 白字對比度 4.63:1，符合 WCAG AA) */
.iw-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 */
.iw-cancel-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

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

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

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

/* 畫布容器，設定相對定位 */
.iw-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 元素 */
.iw-canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===========================
   區塊標題與分隔線
   =========================== */

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

/* 區塊標題圖示 */
.iw-section-title i {
    color: #2563eb;
}

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

/* ===========================
   浮水印類型切換
   =========================== */

/* 類型切換按鈕群組 */
.iw-type-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

/* 類型切換按鈕 (#475569 對比度 7.04:1，符合 WCAG AAA) */
.iw-type-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.875em;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    text-align: center;
}

/* 類型切換按鈕之間的分隔線 */
.iw-type-tab + .iw-type-tab {
    border-left: 1px solid #e2e8f0;
}

/* 類型切換按鈕 hover */
.iw-type-tab:hover {
    background: #eff6ff;
    color: #2563eb;
}

/* 類型切換按鈕啟用狀態 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.iw-type-tab.is-active {
    background: #2563eb;
    color: #fff;
}

/* 類型切換按鈕 focus 外框 */
.iw-type-tab:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* ===========================
   浮水印設定面板
   =========================== */

/* 設定面板 */
.iw-settings-panel {
    display: none;
}

/* 設定面板顯示狀態 */
.iw-settings-panel.is-visible {
    display: block;
}

/* 設定行（水平排列） */
.iw-settings-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* 設定群組 */
.iw-settings-group {
    flex: 1;
    min-width: 120px;
}

/* 寬度佔半群組 */
.iw-settings-group--half {
    flex: 0 0 calc(50% - 6px);
    min-width: 100px;
}

/* 寬度佔全群組 */
.iw-settings-group--full {
    flex: 0 0 100%;
}

/* 表單標籤文字 (#475569 對比度 7.04:1，符合 WCAG AAA) */
.iw-label {
    display: block;
    font-size: 0.813em;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

/* 文字輸入框 */
.iw-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.875em;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

/* 輸入框 focus 狀態 */
.iw-input:focus {
    border-color: #2563eb;
    outline: none;
    background: #fff;
}

/* 輸入框 focus-visible 外框 */
.iw-input:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* 下拉選單 */
.iw-select {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.875em;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
    cursor: pointer;
}

/* 下拉選單 focus 狀態 */
.iw-select:focus {
    border-color: #2563eb;
    outline: none;
    background: #fff;
}

/* 下拉選單 focus-visible 外框 */
.iw-select:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* 色彩選取器容器 */
.iw-color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 色彩選取器 */
.iw-color-picker {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    background: #f8fafc;
}

/* 色彩選取器 focus 外框 */
.iw-color-picker:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* 色彩值文字輸入框 */
.iw-color-text {
    flex: 1;
}

/* 範圍滑桿容器 */
.iw-range-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 範圍滑桿 */
.iw-range {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    outline: none;
}

/* 範圍滑桿滑塊（WebKit） */
.iw-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 範圍滑桿滑塊（Firefox） */
.iw-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 範圍滑桿 focus 外框 */
.iw-range:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* 範圍數值顯示 (#1e293b 對比度 13.52:1，符合 WCAG AAA) */
.iw-range-value {
    font-size: 0.813em;
    font-weight: 600;
    color: #1e293b;
    min-width: 36px;
    text-align: right;
}

/* ===========================
   圖片浮水印上傳區域
   =========================== */

/* 圖片浮水印上傳區域 */
.iw-wm-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* 圖片浮水印上傳區域 hover */
.iw-wm-upload-zone:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

/* 圖片浮水印上傳圖示 (#94a3b8，裝飾性元素) */
.iw-wm-upload-icon {
    font-size: 1.5em;
    color: #94a3b8;
}

/* 圖片浮水印上傳文字 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.iw-wm-upload-text {
    font-size: 0.813em;
    color: #64748b;
    margin: 0;
}

/* 圖片浮水印預覽 */
.iw-wm-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

/* 圖片浮水印預覽縮圖 */
.iw-wm-preview-img {
    max-width: 80px;
    max-height: 60px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

/* 圖片浮水印預覽檔名 (#475569 對比度 7.04:1，符合 WCAG AAA) */
.iw-wm-preview-name {
    font-size: 0.813em;
    color: #475569;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 移除浮水印圖片按鈕 */
.iw-wm-remove-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75em;
    font-weight: 600;
    color: #dc2626;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

/* 移除浮水印圖片按鈕 hover */
.iw-wm-remove-btn:hover {
    background: #fef2f2;
}

/* 移除浮水印圖片按鈕 focus 外框 */
.iw-wm-remove-btn:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

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

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

/* 通用按鈕基底 */
.iw-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) */
.iw-btn--blue {
    background: #2563eb;
}

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

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

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

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

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

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

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

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

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

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

/* ===========================
   位置選擇格線
   =========================== */

/* 位置選擇九宮格容器 */
.iw-position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 120px;
}

/* 位置選擇格子按鈕 (#e2e8f0 背景，裝飾性元素) */
.iw-position-cell {
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f8fafc;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625em;
    color: #94a3b8;
}

/* 位置選擇格子 hover */
.iw-position-cell:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

/* 位置選擇格子啟用狀態 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.iw-position-cell.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* 位置選擇格子 focus 外框 */
.iw-position-cell:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* ===========================
   平鋪模式提示
   =========================== */

/* 平鋪模式說明文字 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.iw-tile-hint {
    font-size: 0.813em;
    color: #64748b;
    margin-top: 4px;
    font-style: italic;
}

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

@media (max-width: 600px) {

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

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

    /* 設定行改為堆疊 */
    .iw-settings-row {
        flex-direction: column;
        gap: 8px;
    }

    /* 設定群組佔滿寬度 */
    .iw-settings-group,
    .iw-settings-group--half {
        flex: none;
        width: 100%;
    }

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

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

    /* 類型切換按鈕縮小內距 */
    .iw-type-tab {
        padding: 8px 12px;
        font-size: 0.813em;
    }
}

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

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

    /* 停用所有過渡動畫 */
    .iw-upload-zone,
    .iw-upload-btn,
    .iw-input,
    .iw-select,
    .iw-btn,
    .iw-cancel-btn,
    .iw-type-tab,
    .iw-position-cell,
    .iw-wm-upload-zone,
    .iw-wm-remove-btn {
        transition: none;
    }
}

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

@media (forced-colors: active) {

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

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

    /* 輸入框框線使用系統色彩 */
    .iw-input,
    .iw-select {
        border-color: CanvasText;
    }

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

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

    /* 類型切換按鈕使用系統色彩 */
    .iw-type-tab {
        border: 1px solid ButtonText;
    }

    /* 位置選擇格子使用系統色彩 */
    .iw-position-cell {
        border-color: CanvasText;
    }

    /* 範圍滑桿使用系統色彩 */
    .iw-range {
        background: CanvasText;
    }
}
