/* Khan Kiddo 英语学习助手 自定义样式 */

/* 全局变量 */
:root {
    --primary-color: #4a5568;
    --secondary-color: #4299e1;
    --accent-color: #f56565;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --purple-color: #9f7aea;
    --background-color: #f7fafc;
    --text-color: #2d3748;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    /* 背景渐变 - 提高20%饱和度的黄绿色 */
    --bg-gradient: linear-gradient(135deg, #ffeb3b 0%, #81c784 100%);
}

/* 通用样式 */
body {
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* 导航栏样式 */
.navbar-brand {
    font-weight: bold;
    color: var(--primary-color) !important;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
    color: var(--secondary-color) !important;
}

/* 按钮样式 */
.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #3182ce 100%);
    border-color: var(--secondary-color);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    border-color: #3182ce;
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

/* 卡片样式 */
.card {
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-body .d-grid {
    margin-top: auto;
    padding-top: 1rem;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2d3748 100%);
    color: white;
    border-radius: 0.75rem 0.75rem 0 0 !important;
    border: none;
}

.card-header.bg-success {
    background-color: var(--success-color) !important;
}

.card-header.bg-info {
    background-color: var(--info-color) !important;
}

.card-header.bg-warning {
    background-color: var(--warning-color) !important;
}

/* 表单样式 */
.form-control {
    border-radius: var(--border-radius);
    border: 1px solid #dee2e6;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-select {
    border-radius: var(--border-radius);
}

.form-label {
    font-weight: 600;
    color: var(--text-color);
}

/* 加载动画 */
.loading {
    display: none;
    text-align: center;
    padding: 2rem;
}

.loading.show {
    display: block;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 结果容器 */
.result-container {
    background-color: #fff;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 1rem;
    border: 1px solid #e9ecef;
}

/* 统计数字动画 */
.stat-number {
    font-size: 2rem;
    font-weight: bold;
    transition: color 0.3s ease;
}

/* 进度条样式 */
.progress {
    height: 1rem;
    border-radius: var(--border-radius);
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: var(--border-radius);
    transition: width 0.6s ease;
}

/* 徽章样式 */
.badge {
    border-radius: var(--border-radius);
    font-weight: 500;
}

/* 页脚样式 */
.footer {
    background-color: var(--primary-color);
    color: white;
    margin-top: 4rem;
}

.footer a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: white;
}

.footer .site-beian {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.site-beian-psb-icon {
    height: 20px;
    width: auto;
    vertical-align: middle;
    margin-right: 4px;
}

.footer .site-beian a {
    color: #bdc3c7;
}

.footer .site-beian a:hover {
    color: white;
}

.login-beian .site-beian {
    font-size: 0.6875rem;
    line-height: 1.4;
}

.login-beian .site-beian a {
    color: #6c757d;
    text-decoration: none;
}

.login-beian .site-beian a:hover {
    color: #495057;
    text-decoration: underline;
}

.login-beian .site-beian p + p {
    margin-top: 0.125rem;
}

.login-beian .site-beian-psb-icon {
    height: 14px;
    margin-right: 3px;
}

/* 消息项样式 */
.message-item {
    transition: all 0.2s ease;
}

.message-item:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* 功能图标样式 */
.feature-icon {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
}

.tech-item {
    transition: transform 0.2s ease;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.tech-item:hover {
    transform: translateY(-2px);
    background-color: #f8f9fa;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }

    .display-5 {
        font-size: 1.75rem;
    }

    .lead {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .card-header h5 {
        font-size: 1rem;
    }
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Toast样式 */
.toast-container {
    z-index: 1055;
}

.toast {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* 工具提示样式 */
.tooltip {
    font-size: 0.875rem;
}

.tooltip-inner {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
}

/* 无障碍访问 */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 打印样式 */
@media print {
    .navbar,
    .footer,
    .btn,
    .loading {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }

    .card-header {
        background-color: #f8f9fa !important;
        color: #000 !important;
    }
}

/* 划词选择提示框样式 */
.word-selection-tooltip {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 14px;
}

.word-selection-tooltip .btn {
    font-size: 12px;
    padding: 4px 8px;
}

.word-selection-tooltip .selected-text {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    max-width: 200px;
    word-break: break-word;
}

/* 目标词汇高亮样式 */
.vocabulary-highlight {
    background: linear-gradient(120deg, #cbaacb 0%, #dcc6e0 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #2c3e50;
    border: 1px solid rgba(155, 89, 182, 0.3);
}

/* 拓展词汇高亮样式 */
.extended-vocabulary-highlight {
    background: linear-gradient(120deg, #ff9a9e 0%, #fad0c4 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #2c3e50;
    border: 1px solid rgba(255, 105, 180, 0.3);
}

/* 单词查询模态框样式 */
.word-query-result .word-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.word-query-result .word-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.word-query-result .word-phonetics {
    margin-bottom: 1rem;
}

.word-query-result .phonetic-text {
    font-size: 1.1rem;
}

.word-query-result .meaning-item {
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
}

.word-query-result .definition-list {
    padding-left: 1.2rem;
}

.word-query-result .example-text {
    font-style: italic;
    font-size: 0.9rem;
}

.word-query-result .synonyms,
.word-query-result .antonyms {
    font-size: 0.9rem;
}

/* 查词面板样式 */
.word-panel-card {
    height: fit-content !important;
    align-self: flex-start !important;
    max-height: 80vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.word-panel-card .card-body {
    flex-grow: 1 !important;
    overflow-y: auto !important;
}

.word-panel-card .card-footer {
    flex-shrink: 0 !important;
    border-top: 1px solid rgba(0, 0, 0, .125) !important;
    background-color: rgba(0, 0, 0, .03) !important;
}

#wordPanelContent {
    min-height: 200px;
}

#wordPanelContent .word-query-result {
    animation: fadeIn 0.3s ease-in;
}

#wordPanelContent .definition-text {
    line-height: 1.8;
    font-size: 0.95rem;
}

#wordPanelContent .meaning-section h6 {
    font-weight: 600;
}

/* 查词面板详细信息样式 */
#wordPanelContent .phonetic-text code {
    font-size: 1.1rem;
    color: #e83e8c;
    background: none;
    padding: 0;
}

#wordPanelContent .pos-text .badge {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

#wordPanelContent .tags-text .badge {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

#wordPanelContent .importance-section {
    text-align: left !important;
}

#wordPanelContent .importance-text {
    font-size: 0.9rem;
    text-align: left !important;
}

#wordPanelContent .importance-item {
    padding: 0.25rem 0;
    min-height: 1.8rem;
    text-align: left !important;
}

#wordPanelContent .importance-item:last-child {
    margin-bottom: 0;
}

#wordPanelContent .importance-icon {
    width: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
}

#wordPanelContent .importance-icon i {
    font-size: 0.9rem;
}

#wordPanelContent .importance-label {
    flex: 1;
    min-width: 0;
    margin-left: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

#wordPanelContent .importance-info-icon {
    color: #6c757d;
    font-size: 0.85rem;
    cursor: help;
    font-weight: normal;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

#wordPanelContent .importance-info-icon:hover {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.1);
}

#wordPanelContent .importance-badge {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
}

#wordPanelContent .importance-item .badge {
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    white-space: nowrap;
}

#wordPanelContent .exchanges-text {
    font-size: 0.9rem;
}

#wordPanelContent .exchange-item {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

#wordPanelContent .exchange-item:last-child {
    margin-bottom: 0;
}

#wordPanelContent .detail-text {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* 确保查词面板内容靠左显示 */
#wordPanelContent .definition-text,
#wordPanelContent .phonetic-text,
#wordPanelContent .pos-text,
#wordPanelContent .importance-text,
#wordPanelContent .tags-text,
#wordPanelContent .exchanges-text,
#wordPanelContent .detail-text {
    text-align: left !important;
}

/* 确保查词面板标题也靠左显示 */
#wordPanelContent .phonetic-section h6,
#wordPanelContent .pos-section h6,
#wordPanelContent .importance-section h6,
#wordPanelContent .definition-section h6,
#wordPanelContent .meaning-section h6,
#wordPanelContent .tags-section h6,
#wordPanelContent .exchanges-section h6,
#wordPanelContent .detail-section h6 {
    text-align: left !important;
}

/* 查词面板响应式调整 */
@media (max-width: 768px) {
    #wordPanelContent .word-query-result {
        font-size: 0.9rem;
    }

    #wordPanelContent .word-title {
        font-size: 1.5rem;
    }
}

/* 查词面板动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 有道云API查询结果样式 */
.word-query-result .web-item {
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
}

.word-query-result .web-item .card-body {
    padding: 0.75rem;
}

.word-query-result .web-item strong {
    color: var(--primary-color);
}

/* 查词面板样式优化 */
.word-title-container {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.word-title {
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
    font-size: 0.9rem;
    margin: 0;
    padding: 0;
}

/* 句子专用样式 */
.word-title.sentence-text {
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 400;
}

/* 查词面板响应式优化 */
.word-query-result {
    max-width: 100%;
}

.word-header {
    min-height: auto;
}

/* 释义区域优化 */
.meaning-item {
    margin-bottom: 1rem;
}

.definition-text {
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.6;
}

/* 查词结果区域：压缩标题与发音按钮间距 */
.word-query-result .word-header {
    padding-bottom: .5rem !important;
    margin-bottom: .75rem !important;
}

.word-query-result .word-title {
    margin-bottom: .25rem !important;
}

.pronunciation-bar {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin: .25rem 0 .75rem;
}

.pronunciation-bar .btn {
    padding: .375rem .75rem;
    line-height: 1;
}

/* 悬浮查词面板 */
.floating-word-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 380px;
    padding: 0 !important; /* 消除容器自身内边距，避免标题两侧留白 */
    display: none; /* 隐藏，通过 JS 控制显示 */
    z-index: 1060; /* 高于页面内容与提示条 */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden; /* 去除标题两侧留白 */
    background: #fff;
    border: 0; /* 避免与 header 边角叠加产生缝隙 */
}

/* 覆盖全局 .card { height: 100% } 规则，避免悬浮窗被拉伸至全高 */
.floating-word-panel.card {
    height: auto;
    max-height: none;
}

.floating-word-panel .drag-handle {
    cursor: move;
    user-select: none;
}

.floating-word-panel .card-header {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 10px 14px;
    position: relative; /* 让伪元素定位 */
    overflow: hidden; /* 防止圆角与背景不贴边 */
    border: 0; /* 去掉自身边框，避免与容器边框叠加出现白边 */
    margin: 0; /* 避免标题外边距导致可视留白 */
}

/* 让标题背景真正填满圆角到两侧，兼容 bootstrap 的 bg-* 渐变/前景 */
.floating-word-panel .card-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit; /* 继承 .bg-info 背景（优先） */
    background-color: transparent; /* 透明兜底，避免 currentColor 与 bg 叠加出现边角色差 */
    z-index: 0;
}

.floating-word-panel .card-header > * {
    position: relative;
    z-index: 1;
}

.floating-word-panel .card-body {
    max-height: 60vh; /* 内容多时滚动，避免整体高度固定导致底部空白 */
    overflow-y: auto;
}

.floating-word-panel .card-footer {
    padding: 12px 14px;
}

/* Markdown 内容通用样式 */
.markdown-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.25;
    color: #2c3e50;
}

.markdown-content h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.markdown-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.3rem;
}

.markdown-content h3 {
    font-size: 1.3rem;
    color: #495057;
}

.markdown-content p {
    margin-bottom: 1rem;
    text-align: justify;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-content li {
    margin-bottom: 0.25rem;
}

.markdown-content ul li {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

.markdown-content blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    border-left: 4px solid #007bff;
    font-style: italic;
}

.markdown-content code {
    background-color: #f8f9fa;
    color: #e83e8c;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}