/* =============================================
   AI辅助英文学习工具 - 样式
   ============================================= */

/* ---- 模式切换 Tabs ---- */
.ael-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e8e8e8;
    scrollbar-width: thin;
    scrollbar-color: #d9d9d9 transparent;
}
.ael-tabs::-webkit-scrollbar { height: 3px; }
.ael-tabs::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 2px; }

.ael-tab {
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 4px 4px 0 0;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    white-space: nowrap;
}

.ael-tab:hover {
    color: #1677ff;
    background: #f0f7ff;
}

.ael-tab.active {
    color: #1677ff;
    border-bottom-color: #1677ff;
    font-weight: 600;
}

/* ---- 面板通用 ---- */
.ael-panel-hidden {
    display: none;
}

.ael-panel-in {
    animation: aelFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes aelFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- 表单区域 ---- */
.ael-form-row {
    position: relative;
    margin-bottom: 6px;
}

.ael-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    font-size: 14px;
    line-height: 1.6;
    border: 2px solid #d9d9d9;
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    font-family: inherit;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.ael-textarea::-webkit-scrollbar { width: 4px; }
.ael-textarea::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.ael-textarea:focus {
    outline: none;
    border-color: #4096ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
    transform: scale(1.01);
}

.ael-char-count {
    text-align: right;
    font-size: 11px;
    color: #bbb;
    margin-top: 2px;
    transition: color 0.2s;
}

.ael-char-count.ael-warn { color: #fa8c16; }
.ael-char-count.ael-over { color: #f5222d; font-weight: 600; }

/* ---- 操作行 ---- */
.ael-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.ael-examples {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

.ael-example-label {
    font-size: 11px;
    color: #bbb;
    white-space: nowrap;
    flex-shrink: 0;
}

.ael-example-tag {
    font-size: 12px;
    padding: 3px 10px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    color: #555;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.13s;
    white-space: nowrap;
}

.ael-example-tag:hover {
    background: #e6f4ff;
    border-color: #91caff;
    color: #1677ff;
    transform: scale(1.04);
}

.ael-example-tag.ael-active {
    background: #bae0ff;
    border-color: #4096ff;
    color: #0958d9;
    transform: scale(0.97);
}

.ael-btn-group {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

/* ---- 快捷键提示 ---- */
.ael-tips {
    font-size: 11px;
    color: #c0c0c0;
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}

@keyframes aelErrorHide {
    to { opacity: 0; transform: translateY(-4px); }
}
.ael-error-hiding {
    animation: aelErrorHide 0.3s ease forwards;
}

/* ---- 全局错误提示 ---- */
.ael-error {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 7px 10px 7px 12px;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    border-left: 3px solid #f5222d;
    border-radius: 6px;
    color: #cf1322;
    font-size: 13px;
    margin-bottom: 10px;
}

.ael-error-close {
    flex-shrink: 0;
    padding: 0 4px;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: none;
    color: #cf1322;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.ael-error-close:hover {
    opacity: 1;
}

/* ---- 结果块 ---- */
.ael-result-block {
    margin-top: 10px;
    border: 1px solid #dce8ff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 14px rgba(22, 119, 255, 0.09);
    animation: aelFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- 评分条 ---- */
.ael-score-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    background: linear-gradient(to right, #f5f8ff, #fafbff);
    border-bottom: 1px solid #e4edff;
    flex-wrap: wrap;
}

.ael-score-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    flex-shrink: 0;
    white-space: nowrap;
}

.ael-score-track {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.ael-score-fill {
    height: 100%;
    border-radius: 4px;
    width: 0;
    background: #1677ff;
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.ael-score-fill.ael-score-good  { background: linear-gradient(90deg, #52c41a, #73d13d); }
.ael-score-fill.ael-score-mid   { background: linear-gradient(90deg, #faad14, #ffc53d); }
.ael-score-fill.ael-score-low   { background: linear-gradient(90deg, #ff4d4f, #ff7875); }

.ael-score-num {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    flex-shrink: 0;
    min-width: 56px;
    text-align: right;
}

.ael-score-num.ael-score-good { color: #389e0d; }
.ael-score-num.ael-score-mid  { color: #d46b08; }
.ael-score-num.ael-score-low  { color: #cf1322; }

.ael-level-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    background: #1677ff;
    color: #fff;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ---- 总评 ---- */
.ael-summary {
    padding: 9px 14px 9px 16px;
    font-size: 13px;
    color: #444;
    background: #f9fafb;
    border-bottom: 1px solid #eef2ff;
    border-left: 3px solid #1677ff;
    line-height: 1.65;
}

/* ---- 通用 section ---- */
.ael-section {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f4ff;
}

.ael-section:last-child {
    border-bottom: none;
}

.ael-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- 语法错误列表 ---- */
.ael-error-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ael-grammar-error-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 7px 9px;
    border-radius: 7px;
    background: #fafafa;
    border: 1px solid #f0f0f0;
    transition: border-color 0.15s, background 0.15s;
}

.ael-grammar-error-item:hover {
    border-color: #ffccc7;
    background: #fff8f7;
}

.ael-error-index {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.ael-error-detail {
    flex: 1;
    min-width: 0;
}

.ael-error-comparison {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.ael-original {
    font-size: 13px;
    color: #cf1322;
    text-decoration: line-through;
    font-family: 'Georgia', 'Times New Roman', serif;
    background: #fff2f0;
    padding: 1px 6px;
    border-radius: 4px;
}

.ael-arrow {
    font-size: 14px;
    color: #aaa;
    flex-shrink: 0;
}

.ael-fix {
    font-size: 13px;
    color: #389e0d;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-weight: 600;
    background: #f6ffed;
    padding: 1px 6px;
    border-radius: 4px;
}

.ael-explanation {
    font-size: 12px;
    color: #666;
    line-height: 1.55;
}

/* ---- 无错误提示 ---- */
.ael-no-error {
    padding: 10px 16px;
    font-size: 13px;
    color: #389e0d;
    background: #f6ffed;
    border-bottom: 1px solid #d9f7be;
    border-left: 3px solid #52c41a;
    font-weight: 500;
}

.ael-no-error:last-child { border-bottom: none; }

/* ---- 修正/翻译文本框 ---- */
.ael-corrected-text,
.ael-translation-text {
    font-size: 13.5px;
    color: #1a1a2e;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f6f9ff;
    border-radius: 6px;
    padding: 10px 14px;
    border-left: 3px solid #69b1ff;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    max-height: 280px;
    overflow-y: auto;
}

.ael-corrected-text::-webkit-scrollbar,
.ael-translation-text::-webkit-scrollbar { width: 4px; }
.ael-corrected-text::-webkit-scrollbar-thumb,
.ael-translation-text::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.ael-translation-text {
    border-left-color: #36cfc9;
    background: #f0fffe;
}

/* ---- 复制按钮 ---- */
.ael-copy-btn {
    font-size: 11px;
    padding: 2px 8px;
    background: #f0f0f0;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    color: #555;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.ael-copy-btn:hover {
    background: #e6f4ff;
    border-color: #91caff;
    color: #1677ff;
}

.ael-copy-btn.copied {
    background: #f6ffed;
    border-color: #b7eb8f;
    color: #389e0d;
}

/* ---- 列表 ---- */
.ael-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ael-list li {
    font-size: 13px;
    line-height: 1.6;
    padding: 5px 10px 5px 12px;
    border-radius: 5px;
    position: relative;
}

.ael-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    border-radius: 2px;
    min-height: 14px;
}

.ael-list--green li { background: #f6ffed; color: #1a5c00; }
.ael-list--green li::before { background: #52c41a; }
.ael-list--orange li { background: #fff7e6; color: #873800; }
.ael-list--orange li::before { background: #fa8c16; }
.ael-list--blue li { background: #e6f4ff; color: #0050b3; }
.ael-list--blue li::before { background: #1677ff; }

/* ---- 翻译方向 ---- */
.ael-translate-direction {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: linear-gradient(to right, #f5f8ff, #fafbff);
    border-bottom: 1px solid #e4edff;
}

.ael-lang-tag {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    background: #e6f4ff;
    color: #1677ff;
    border-radius: 10px;
    border: 1px solid #91caff;
}

.ael-lang-arrow {
    font-size: 14px;
    color: #1677ff;
    font-weight: 700;
}

/* ---- 备选翻译 ---- */
.ael-alt-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ael-alt-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 10px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 6px;
    transition: border-color 0.15s;
}

.ael-alt-item:hover {
    border-color: #91caff;
}

.ael-alt-text {
    flex: 1;
    font-size: 13px;
    color: #444;
    line-height: 1.6;
    word-break: break-word;
}

.ael-copy-inline {
    margin-top: 1px;
}

/* ---- 提交按钮 loading 态 ---- */
.ael-submit-btn {
    transition: opacity 0.2s, transform 0.1s;
}

.ael-submit-btn:active {
    transform: scale(0.97);
}

.ael-submit-btn.loading {
    opacity: 0.75;
    cursor: not-allowed;
}

.ael-submit-btn.loading::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aelSpin 0.7s linear infinite;
    margin-left: 5px;
    vertical-align: -2px;
}

@keyframes aelSpin {
    to { transform: rotate(360deg); }
}

/* ---- Toast ---- */
.ael-toast {
    position: fixed;
    bottom: 26px;
    right: 26px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    border-radius: 7px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(7px);
    transition: opacity 0.28s, transform 0.28s;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
}

.ael-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ael-toast--success { background: rgba(82, 196, 26, 0.92); }
.ael-toast--warning { background: rgba(250, 173, 20, 0.92); color: #333; }
.ael-toast--error   { background: rgba(255, 77, 79, 0.92); }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .ael-action-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .ael-btn-group {
        width: 100%;
        justify-content: flex-end;
    }
    .ael-score-bar {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .ael-tabs {
        overflow-x: auto;
    }
    .ael-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    .ael-error-comparison {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .ael-grammar-error-item {
        flex-direction: column;
        gap: 4px;
    }
    .ael-error-index {
        align-self: flex-start;
    }
}
