/* ===========================
   aes-encryption - AES 加解密工具頁面
   =========================== */

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

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

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

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

/* ===========================
   設定卡片
   =========================== */

/* 設定區域卡片 */
.aes-settings-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;
}

/* 設定區域內容 */
.aes-settings-body {
    padding: 20px 24px;
}

/* 設定列，使用 Flexbox 多欄並排 */
.aes-settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 16px;
    align-items: flex-start;
}

/* 設定列最後一列取消底部間距 */
.aes-settings-row:last-child {
    margin-bottom: 0;
}

/* 單一設定群組 */
.aes-setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 設定群組標籤文字 */
.aes-setting-label {
    font-size: 0.938em;
    font-weight: 600;
    color: #475569;
}

/* ===========================
   選項按鈕群組（模式、Key 長度、格式、Padding、輸出格式共用）
   =========================== */

/* 選項按鈕外層容器 */
.aes-option-buttons {
    display: flex;
    gap: 0;
}

/* 隱藏原生 radio 按鈕，僅保留視覺樣式 */
.aes-option-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* 選項按鈕外觀 (邊框 #8b95a5 對比度 3.05:1，符合 UI 元件門檻) */
.aes-option-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 0.875em;
    font-weight: 500;
    color: #475569;
    background: #fff;
    border: 1px solid #8b95a5;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 36px;
}

/* 第一個選項左側圓角 */
.aes-option-item:first-child .aes-option-btn {
    border-radius: 8px 0 0 8px;
}

/* 最後一個選項右側圓角 */
.aes-option-item:last-child .aes-option-btn {
    border-radius: 0 8px 8px 0;
}

/* 僅一個選項時四角皆圓角 */
.aes-option-item:only-child .aes-option-btn {
    border-radius: 8px;
}

/* 中間選項不重複左邊框 */
.aes-option-item:not(:first-child) .aes-option-btn {
    border-left: none;
}

/* 選項懸停效果 */
.aes-option-btn:hover {
    background: #f1f5f9;
}

/* 選中狀態 (#2563eb 白字對比度 5.18:1，符合 WCAG AA) */
.aes-option-item input[type="radio"]:checked + .aes-option-btn {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* 選項鍵盤聚焦指示 */
.aes-option-item input[type="radio"]:focus-visible + .aes-option-btn {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
    z-index: 1;
    position: relative;
}

/* ===========================
   Key / IV 輸入區域
   =========================== */

/* 輸入欄位與格式選擇的複合群組 */
.aes-input-group {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 輸入群組佔滿整行寬度（Key、IV 各獨立一行） */
.aes-input-group--full {
    flex-basis: 100%;
    min-width: 100%;
}

/* 輸入欄位標籤 */
.aes-label {
    display: block;
    font-size: 0.938em;
    font-weight: 600;
    color: #475569;
    margin-bottom: 2px;
}

/* 文字輸入框 (邊框 #8b95a5 對比度 3.05:1，符合 UI 元件門檻) */
.aes-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #8b95a5;
    border-radius: 8px;
    font-size: 1em;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    box-sizing: border-box;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* 輸入框聚焦時的藍色邊框 */
.aes-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* 輸入框下方提示文字 (#64748b 對比度 4.51:1，符合 WCAG AA) */
.aes-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.813em;
    color: #64748b;
}

/* 輸入框與格式選項的橫向排列 */
.aes-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 輸入框在橫向排列時自動填滿空間 */
.aes-input-row .aes-input {
    flex: 1;
}

/* ===========================
   雙欄操作區域
   =========================== */

/* 雙欄格線容器 */
.aes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===========================
   操作卡片
   =========================== */

/* 操作卡片外觀 */
.aes-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);
    transition: box-shadow 0.2s ease;
}

/* 卡片滑鼠懸停時加深陰影 */
.aes-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.06), 0 10px 24px rgba(0, 0, 0, 0.06);
}

/* 卡片標題列 */
.aes-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

/* 卡片標題文字 */
.aes-card-title {
    font-size: 1.188em;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.3;
}

/* 卡片描述文字 */
.aes-card-desc {
    font-size: 0.938em;
    color: #64748b;
    margin: 2px 0 0;
}

/* 卡片內容區域 */
.aes-card-body {
    padding: 20px 24px 24px;
}

/* 表單欄位群組 */
.aes-form-group {
    margin-bottom: 16px;
}

/* ===========================
   文字輸入框
   =========================== */

/* 多行文字輸入框 */
.aes-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #8b95a5;
    border-radius: 8px;
    font-size: 1em;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.6;
}

/* 多行輸入框聚焦時的藍色邊框 */
.aes-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

/* 按鈕基礎樣式 */
.aes-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    width: 100%;
    justify-content: center;
}

/* 按鈕點擊時的按壓效果 */
.aes-btn:active {
    transform: scale(0.98);
}

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

/* 綠色按鈕 - 解密 (#15803d 白字對比度 5.09:1，符合 WCAG AA) */
.aes-btn--green {
    background: #15803d;
}
.aes-btn--green:hover {
    background: #166534;
}

/* ===========================
   結果區域
   =========================== */

/* 結果容器 */
.aes-result {
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

/* 結果區標題列 */
.aes-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f1f5f9;
}

/* 結果標籤 */
.aes-result-label {
    font-size: 0.813em;
    font-weight: 600;
    color: #64748b;
}

/* 結果操作按鈕群組 */
.aes-result-actions {
    display: flex;
    gap: 6px;
}

/* 小型操作按鈕（複製、清除）(邊框 #8b95a5 對比度 3.05:1，符合 UI 元件門檻) */
.aes-action-btn {
    background: #fff;
    border: 1px solid #8b95a5;
    border-radius: 6px;
    padding: 6px 12px;
    color: #475569;
    cursor: pointer;
    font-size: 0.813em;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 操作按鈕懸停效果 */
.aes-action-btn:hover {
    background: #f1f5f9;
    border-color: #64748b;
    color: #1e293b;
}

/* 危險操作按鈕（清除）懸停效果 */
.aes-action-btn--danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}

/* 結果內容區域 */
.aes-result-body {
    padding: 12px 16px;
}

/* 結果文字（等寬字型，支援換行） */
.aes-result-text {
    margin: 0;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.938em;
    color: #1e293b;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 結果錯誤訊息 */
.aes-result-error {
    color: #dc2626;
    font-family: inherit;
    font-size: 1em;
}

/* ===========================
   GCM Authentication Tag 區域
   =========================== */

/* GCM Tag 輸出區（黃色背景以區別一般結果） */
.aes-gcm-tag-box {
    margin-top: 12px;
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

/* GCM Tag 標籤文字 */
.aes-gcm-tag-label {
    display: block;
    font-size: 0.813em;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 6px;
}

/* GCM Tag 內容文字 */
.aes-gcm-tag-text {
    margin: 0;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875em;
    color: #92400e;
    line-height: 1.6;
    word-break: break-all;
}

/* GCM Tag 操作列（複製按鈕） */
.aes-gcm-tag-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

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

/* 中螢幕以下雙欄改為單欄 */
@media (max-width: 768px) {
    .aes-grid {
        grid-template-columns: 1fr;
    }
}

/* 小螢幕時設定列垂直排列 */
@media (max-width: 576px) {
    /* 設定列改為垂直排列 */
    .aes-settings-row {
        flex-direction: column;
        gap: 12px;
    }

    /* 輸入群組佔滿寬度 */
    .aes-input-group {
        min-width: 100%;
    }

    /* 輸入框與格式選項改為垂直排列 */
    .aes-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    /* 模式按鈕群組允許換行 */
    .aes-option-buttons {
        flex-wrap: wrap;
    }

    /* 換行後每個按鈕需要獨立圓角 */
    .aes-option-buttons.aes-option-buttons--wrap .aes-option-item .aes-option-btn {
        border-radius: 8px;
        border-left: 1px solid #8b95a5;
    }

    .aes-option-buttons.aes-option-buttons--wrap .aes-option-item input[type="radio"]:checked + .aes-option-btn {
        border-color: #2563eb;
    }
}

/* ===========================
   無障礙支援
   =========================== */

/* 按鈕鍵盤聚焦指示 (WCAG 2.4.7 Focus Visible) */
.aes-btn:focus-visible {
    outline: 2px solid #1e293b;
    outline-offset: 2px;
}

/* 小型操作按鈕鍵盤聚焦指示 */
.aes-action-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* 多行輸入框鍵盤聚焦指示（已透過 box-shadow 處理，不需要額外 outline） */
.aes-textarea:focus-visible {
    outline: none;
}

/* 單行輸入框鍵盤聚焦指示（已透過 box-shadow 處理，不需要額外 outline） */
.aes-input:focus-visible {
    outline: none;
}

/* 尊重使用者減少動態效果的偏好設定 (WCAG 2.3.3 Animation from Interactions) */
@media (prefers-reduced-motion: reduce) {
    .aes-card,
    .aes-btn,
    .aes-textarea,
    .aes-input,
    .aes-action-btn,
    .aes-option-btn {
        transition: none;
    }
}

/* Windows 高對比模式支援，確保邊框與聚焦指示在強制色彩下仍可見 */
@media (forced-colors: active) {
    /* 輸入框邊框改用系統邊框色 */
    .aes-textarea,
    .aes-input {
        border-color: ButtonText;
    }

    /* 聚焦時使用系統高亮色 */
    .aes-textarea:focus,
    .aes-input:focus {
        border-color: Highlight;
        box-shadow: none;
    }

    /* 按鈕在高對比模式下保持可見邊框 */
    .aes-btn {
        border: 2px solid ButtonText;
    }

    /* 按鈕聚焦指示使用系統高亮色 */
    .aes-btn:focus-visible,
    .aes-action-btn:focus-visible {
        outline-color: Highlight;
    }

    /* 卡片邊框確保在高對比模式下可見 */
    .aes-card,
    .aes-settings-card {
        border-color: CanvasText;
    }

    /* 結果區域邊框在高對比模式下可見 */
    .aes-result {
        border-color: CanvasText;
    }

    /* 選項按鈕在高對比模式下保持可見邊框 */
    .aes-option-btn {
        border-color: ButtonText;
    }

    /* 選項選中狀態在高對比模式下使用系統高亮色 */
    .aes-option-item input[type="radio"]:checked + .aes-option-btn {
        background: Highlight;
        color: HighlightText;
        border-color: Highlight;
    }

    /* GCM Tag 區域邊框在高對比模式下可見 */
    .aes-gcm-tag-box {
        border-color: CanvasText;
    }
}
