/* =============================================
   AI辅助背英文单词工具 - 样式
   ============================================= */

/* ---- 模式切换 Tabs ---- */
.avm-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e8e8e8;
}

.avm-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;
}

.avm-tab:hover {
    color: #1677ff;
    background: #f0f7ff;
}

.avm-tab.active {
    color: #1677ff;
    border-bottom-color: #1677ff;
    font-weight: 600;
}

.avm-count-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #1677ff;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    margin-left: 4px;
    vertical-align: middle;
}

/* ---- 面板通用 ---- */
.avm-panel {
    animation: avmFadeIn 0.25s ease;
}

.avm-panel-hidden {
    display: none;
}

@keyframes avmFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- 查询行 ---- */
.avm-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
}

.avm-word-input {
    flex: 1;
    padding: 8px 14px;
    font-size: 16px;
    font-family: 'Georgia', 'Times New Roman', serif;
    border: 2px solid #d9d9d9;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-sizing: border-box;
    letter-spacing: 0.5px;
}

.avm-word-input:focus {
    outline: none;
    border-color: #4096ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.12);
    transform: scale(1.01);
}

.avm-search-btn {
    flex-shrink: 0;
}

.avm-tips {
    font-size: 11px;
    color: #bbb;
    margin-bottom: 10px;
}

/* ---- 错误提示 ---- */
.avm-error {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 12px;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    border-left: 3px solid #f5222d;
    border-radius: 6px;
    color: #cf1322;
    font-size: 13px;
    margin-bottom: 10px;
}

.avm-error-close {
    flex-shrink: 0;
    padding: 0 4px;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: none;
    color: #cf1322;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s;
}

.avm-error-close:hover {
    opacity: 1;
}

@keyframes avmErrorFade {
    to { opacity: 0; transform: translateY(-4px); }
}

.avm-error-hide {
    animation: avmErrorFade 0.33s ease forwards;
}

/* ---- 单词结果卡片 ---- */
.avm-word-card {
    border: 1px solid #e0e8ff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(22, 119, 255, 0.08);
    animation: avmFadeIn 0.3s ease;
    margin-top: 8px;
}

.avm-card-header {
    background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
    padding: 14px 18px;
    color: #fff;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.avm-card-main {
    flex: 1;
    min-width: 0;
}

.avm-card-word {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Georgia', 'Times New Roman', serif;
    letter-spacing: 1px;
    line-height: 1.2;
    margin-bottom: 5px;
}

.avm-card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.avm-phonetic {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Consolas', monospace;
}

.avm-pos {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 9px;
    border-radius: 10px;
    color: #fff;
}

.avm-level {
    font-size: 11px;
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    padding: 2px 9px;
    border-radius: 10px;
    font-weight: 700;
}

.avm-card-actions {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    flex-shrink: 0;
    padding-top: 2px;
}

.avm-add-btn {
    padding: 5px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.avm-add-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.04);
}

.avm-add-btn.added {
    background: rgba(82, 196, 26, 0.75);
    border-color: rgba(82, 196, 26, 0.9);
}

.avm-speak-btn {
    padding: 5px 9px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}

.avm-speak-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

/* 卡片各节 */
.avm-section {
    padding: 10px 18px;
    border-bottom: 1px solid #f0f4ff;
}

.avm-section:last-child {
    border-bottom: none;
}

.avm-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #8c8c8c;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 7px;
}

/* 释义 */
.avm-definitions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.avm-definition-item {
    font-size: 14px;
    color: #1a1a2e;
    padding: 3px 0 3px 10px;
    border-left: 3px solid #4096ff;
    line-height: 1.6;
}

/* 例句 */
.avm-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.avm-example-item {
    background: #f6f9ff;
    border-radius: 7px;
    padding: 8px 12px;
    border-left: 3px solid #69b1ff;
}

.avm-example-en {
    font-size: 14px;
    color: #1a1a2e;
    font-style: italic;
    margin-bottom: 3px;
    line-height: 1.65;
}

.avm-example-zh {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

/* 记忆技巧 */
.avm-mnemonic {
    font-size: 13px;
    color: #5a3e00;
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-left: 3px solid #faad14;
    border-radius: 6px;
    padding: 8px 12px;
    line-height: 1.7;
}

/* 标签 */
.avm-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.avm-tag {
    font-size: 12px;
    padding: 3px 11px;
    border-radius: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    cursor: default;
    transition: transform 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.avm-tag:hover {
    transform: scale(1.06);
    opacity: 0.85;
}

.avm-tag--blue {
    background: #e6f4ff;
    color: #1677ff;
    border: 1px solid #91caff;
    cursor: pointer;
}

.avm-tag--green {
    background: #f6ffed;
    color: #389e0d;
    border: 1px solid #b7eb8f;
    cursor: pointer;
}

/* ============================================
   闪卡复习面板
   ============================================ */
.avm-flash-empty,
.avm-list-empty {
    text-align: center;
    padding: 38px 20px;
}

.avm-empty-icon {
    font-size: 44px;
    margin-bottom: 10px;
    line-height: 1;
}

.avm-empty-text {
    font-size: 14px;
    color: #999;
    margin-bottom: 14px;
}

/* 进度行 */
.avm-flash-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.avm-progress-text {
    font-size: 13px;
    color: #555;
    font-weight: 600;
    min-width: 48px;
    flex-shrink: 0;
}

.avm-progress-bar {
    flex: 1;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
    min-width: 80px;
}

.avm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1677ff, #36cfc9);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.avm-flash-ctrl-top {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* 闪卡 */
.avm-flashcard {
    width: 100%;
    max-width: 480px;
    height: 200px;
    margin: 0 auto 14px auto;
    perspective: 1000px;
    cursor: pointer;
}

.avm-flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.avm-flashcard-inner.flipped {
    transform: rotateY(180deg);
}

.avm-flashcard-front,
.avm-flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.avm-flashcard-front {
    background: linear-gradient(135deg, #e6f4ff 0%, #f0f5ff 100%);
    border: 2px solid #91caff;
}

.avm-flashcard-back {
    background: linear-gradient(135deg, #f6ffed 0%, #f0fff4 100%);
    border: 2px solid #b7eb8f;
    transform: rotateY(180deg);
    gap: 8px;
}

.avm-flash-word {
    font-size: 34px;
    font-weight: 700;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #1677ff;
    text-align: center;
    letter-spacing: 1px;
}

.avm-flash-hint {
    font-size: 11px;
    color: #aaa;
    margin-top: 8px;
}

.avm-flash-phonetic {
    font-size: 14px;
    color: #666;
    font-family: 'Consolas', monospace;
}

.avm-flash-def {
    font-size: 17px;
    color: #1a5c00;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
    padding: 0 10px;
}

.avm-flash-speak-btn {
    padding: 4px 9px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #b7eb8f;
    border-radius: 6px;
    color: #389e0d;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    line-height: 1;
}

.avm-flash-speak-btn:hover {
    background: #fff;
    transform: scale(1.08);
}

/* 操作按钮行 */
.avm-flash-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.avm-flash-result-btns {
    display: flex;
    gap: 8px;
}

.avm-wrong-btn,
.avm-right-btn {
    padding: 7px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.avm-wrong-btn {
    background: #fff2f0;
    border: 2px solid #ffccc7;
    color: #cf1322;
}

.avm-wrong-btn:hover {
    background: #ffccc7;
    transform: scale(1.04);
}

.avm-right-btn {
    background: #f6ffed;
    border: 2px solid #b7eb8f;
    color: #389e0d;
}

.avm-right-btn:hover {
    background: #b7eb8f;
    transform: scale(1.04);
}

/* 复习统计 */
.avm-flash-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
    font-size: 13px;
    max-width: 480px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.avm-stat {
    padding: 3px 13px;
    border-radius: 12px;
}

.avm-stat--right {
    background: #f6ffed;
    color: #389e0d;
}

.avm-stat--wrong {
    background: #fff2f0;
    color: #cf1322;
}

.avm-stat--neutral {
    background: #f0f0f0;
    color: #666;
}

.avm-stat strong {
    font-weight: 700;
}

/* ============================================
   词汇本面板
   ============================================ */
.avm-list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.avm-list-count {
    font-size: 13px;
    color: #666;
    flex-shrink: 0;
}

.avm-list-count strong {
    color: #1677ff;
    font-weight: 700;
}

.avm-list-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.avm-list-search {
    padding: 5px 10px;
    font-size: 13px;
    border: 1.5px solid #d9d9d9;
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-sizing: border-box;
    width: 160px;
}

.avm-list-search:focus {
    outline: none;
    border-color: #4096ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.12);
    transform: scale(1.01);
}

.avm-word-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.avm-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    transition: border-color 0.2s, background 0.15s;
}

.avm-list-item:hover {
    border-color: #91caff;
    background: #f0f7ff;
}

.avm-list-word {
    font-size: 15px;
    font-weight: 700;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #1677ff;
    min-width: 100px;
    flex-shrink: 0;
    cursor: pointer;
    transition: text-decoration 0.15s;
}

.avm-list-word:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.avm-list-phonetic {
    font-size: 12px;
    color: #999;
    font-family: 'Consolas', monospace;
    min-width: 80px;
    flex-shrink: 0;
}

.avm-list-def {
    font-size: 13px;
    color: #555;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avm-list-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.avm-list-speak-btn {
    padding: 2px 7px;
    font-size: 14px;
    background: transparent;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
}

.avm-list-speak-btn:hover {
    border-color: #4096ff;
    background: #e6f4ff;
    transform: scale(1.08);
}

.avm-list-remove-btn {
    padding: 2px 8px;
    font-size: 12px;
    background: transparent;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    color: #cf1322;
    cursor: pointer;
    transition: all 0.15s;
}

.avm-list-remove-btn:hover {
    background: #fff2f0;
    border-color: #ff4d4f;
    transform: scale(1.04);
}

.avm-search-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 按钮提交时 Spinner 动画 */
.avm-search-btn.loading::after {
    content: '';
    display: inline-block;
    width: 11px;
    height: 11px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: avmSpin 0.7s linear infinite;
    margin-left: 6px;
    vertical-align: -2px;
}

@keyframes avmSpin {
    to { transform: rotate(360deg); }
}

/* 欢迎区（首次加载无结果时） */
.avm-welcome {
    text-align: center;
    padding: 24px 20px 18px;
    animation: avmFadeIn 0.3s ease;
}

.avm-welcome-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 8px;
}

.avm-welcome-text {
    font-size: 13px;
    color: #999;
    margin-bottom: 14px;
    margin-top: 0;
}

.avm-welcome-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.avm-welcome-tag {
    padding: 4px 14px;
    background: #f0f5ff;
    border: 1px solid #adc6ff;
    border-radius: 14px;
    font-size: 13px;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #2f54eb;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
    letter-spacing: 0.4px;
}

.avm-welcome-tag:hover {
    background: #d6e4ff;
    border-color: #597ef7;
    transform: scale(1.06);
}

/* 无匹配结果样式 */
.avm-no-match {
    text-align: center;
    color: #aaa;
    padding: 20px;
    font-size: 13px;
}

/* 闪卡完成界面 */
.avm-flash-complete {
    text-align: center;
    padding: 28px 20px 24px;
    animation: avmFadeIn 0.35s ease;
}

.avm-complete-icon {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 10px;
}

.avm-complete-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 14px;
}

.avm-complete-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.avm-complete-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---- Toast 通知 ---- */
.avm-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 9px 18px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.avm-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.avm-toast--success { background: rgba(82, 196, 26, 0.92); }
.avm-toast--warning { background: rgba(250, 173, 20, 0.92); color: #333; }
.avm-toast--error   { background: rgba(255, 77, 79, 0.92); }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .avm-flashcard {
        height: 180px;
    }

    .avm-flash-word {
        font-size: 28px;
    }

    .avm-flash-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .avm-flash-result-btns {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .avm-list-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .avm-list-search {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .avm-tabs {
        overflow-x: auto;
    }

    .avm-tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    .avm-search-row {
        flex-wrap: wrap;
    }

    .avm-word-input {
        font-size: 15px;
    }

    .avm-card-header {
        flex-direction: column;
        padding: 12px 14px;
    }

    .avm-card-word {
        font-size: 24px;
    }

    .avm-card-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .avm-section {
        padding: 8px 14px;
    }

    .avm-list-phonetic {
        display: none;
    }

    .avm-flash-progress {
        flex-wrap: wrap;
    }
}
