/* 基础样式文件 - 小学生英语演讲稿生成器 */
/* 通用样式规则 */

/* 基础重置和排版 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器样式 */
.speech-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 24px;
    margin-bottom: 24px;
}

.max-w-4xl {
    max-width: 56rem;
    margin-left: auto;
    margin-right: auto;
}

/* 标题样式 */
h1, h2, h3 {
    color: #2d3748;
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.875rem;
    margin-bottom: 1rem;
}

/* 文本样式 */
.text-center {
    text-align: center;
}

.text-gray-600 {
    color: #718096;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-4xl {
    font-size: 2.25rem;
}

.text-5xl {
    font-size: 3rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-medium {
    font-weight: 500;
}

/* 间距样式 */
.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

/* 布局样式 */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1 1 0%;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-4 {
    gap: 1rem;
}

/* 输入框样式 */
input[type="text"] {
    width: 100%;
    padding: 16px 24px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 56px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* 按钮基础样式 */
button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 主按钮样式 */
.btn-primary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* 次要按钮样式 */
.btn-secondary {
    background: #f1c40f;
    color: #2c3e50;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(241, 196, 15, 0.3);
}

/* 速度按钮样式 */
.speed-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #4a5568;
    min-height: 40px;
    min-width: 60px;
}

.speed-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.speed-btn:hover:not(.active) {
    border-color: #3498db;
    color: #3498db;
}

/* 打印按钮样式 */
.print-btn {
    background: linear-gradient(45deg, #e67e22, #f39c12);
    color: white;
    margin-left: 10px;
}

.print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
}

/* 隐藏/显示控制 */
.hidden {
    display: none !important;
}

/* 历史记录面板样式 */
.history-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 320px;
    max-height: 60vh;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-overflow-scrolling: touch;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    border-radius: 12px 12px 0 0;
}

.history-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.history-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: #718096;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: auto;
    padding: 0;
}

.history-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2d3748;
}

.history-content {
    padding: 8px;
    max-height: calc(60vh - 60px);
    overflow-y: auto;
}

.history-item {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: #f8f9fa;
}

.history-item:hover {
    background: linear-gradient(45deg, #e3f2fd, #bbdefb);
    border-color: #2196f3;
    transform: translateX(2px);
}

.history-item-topic {
    font-weight: 600;
    color: #2d3748;
    font-size: 14px;
    margin-bottom: 4px;
}

.history-item-time {
    font-size: 12px;
    color: #718096;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-size: 14px;
}

.history-btn {
    background: linear-gradient(45deg, #8e24aa, #ab47bc);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 16px;
    min-height: 48px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.history-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142, 36, 170, 0.3);
}

/* 通用浏览器兼容性修复 */
@supports (-webkit-touch-callout: none) {
    /* 通用触摸设备优化 */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    .speech-container {
        transform: translate3d(0, 0, 0);
    }
    
    input[type="text"] {
        -webkit-appearance: none;
        border-radius: 12px;
    }
    
    button {
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Android Chrome 专用修复 */
@supports (display: -webkit-flex) {
    .speech-container {
        will-change: transform;
        contain: layout style paint;
    }
    
    .floating-control-panel {
        will-change: transform, opacity;
    }
}

/* 错误处理样式 */
.error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #d32f2f, #f44336);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(211, 47, 47, 0.4);
    font-size: 16px;
    font-weight: 600;
    z-index: 10002;
    max-width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

.success-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #388e3c, #4caf50);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(56, 142, 60, 0.4);
    font-size: 16px;
    font-weight: 600;
    z-index: 10002;
    max-width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { 
        bottom: -100px;
        opacity: 0;
    }
    to { 
        bottom: 20px;
        opacity: 1;
    }
}

@keyframes slideDown {
    from { 
        bottom: 20px;
        opacity: 1;
    }
    to { 
        bottom: -100px;
        opacity: 0;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 手机端字体放大 */
    body {
        font-size: 18px !important;
        line-height: 1.8 !important;
        -webkit-overflow-scrolling: touch !important;
        -webkit-text-size-adjust: 100% !important;
    }
    
    /* 历史记录面板移动端适配 */
    .history-panel {
        position: fixed;
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 50vh;
        border-radius: 16px 16px 0 0;
    }
    
    .history-content {
        max-height: calc(50vh - 60px);
    }
    
    .history-item {
        padding: 16px;
        font-size: 16px;
    }
    
    .history-item-topic {
        font-size: 16px;
    }
    
    .history-item-time {
        font-size: 14px;
    }
    
    .history-btn {
        font-size: 15px !important;
        padding: 14px 20px;
        min-height: 50px;
    }
    
    .speech-container {
        padding: 20px;
        margin: 0 10px 20px 10px;
    }
    
    /* 朗读控制栏置顶固定 */
    #controlContainer {
        position: sticky !important;
        top: 0 !important;
        background: white !important;
        z-index: 200 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
        border-radius: 0 0 16px 16px !important;
        margin-bottom: 20px !important;
    }
    
    .english-line {
        font-size: 20px !important;
        line-height: 1.7 !important;
        padding: 16px 14px !important;
    }
    
    .chinese-line {
        font-size: 19px !important;
        line-height: 1.8 !important;
        padding: 14px 12px !important;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    input[type="text"] {
        font-size: 18px !important;
        padding: 16px 20px;
    }
    
    button {
        font-size: 16px !important;
        padding: 12px 20px;
        min-height: 48px;
    }
    
    .text-4xl {
        font-size: 1.875rem;
    }
    
    .text-5xl {
        font-size: 2.25rem;
    }
    
    /* 手机端单词高亮增强 */
    .current-word {
        padding: 3px 6px !important;
        font-size: 21px !important;
        border-radius: 6px !important;
        animation: mobile-word-glow 0.7s infinite alternate !important;
    }
    
    @keyframes mobile-word-glow {
        0% { 
            background: linear-gradient(45deg, #FF5722, #E91E63);
            box-shadow: 0 3px 10px rgba(255, 87, 34, 0.7);
        }
        100% { 
            background: linear-gradient(45deg, #E91E63, #9C27B0);
            box-shadow: 0 5px 15px rgba(233, 30, 99, 0.8);
        }
    }
}

@media (max-width: 480px) {
    .speech-container {
        padding: 16px;
        border-radius: 12px;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* 小屏幕历史记录面板优化 */
    .history-panel {
        bottom: 60px;
        right: 5px;
        left: 5px;
        max-height: 45vh;
        border-radius: 12px 12px 0 0;
    }
    
    .history-header {
        padding: 12px 16px 8px;
    }
    
    .history-header h3 {
        font-size: 14px;
    }
    
    .history-content {
        padding: 6px;
        max-height: calc(45vh - 50px);
    }
    
    .history-item {
        padding: 14px 12px;
        margin: 3px 0;
        font-size: 15px;
    }
    
    .history-item-topic {
        font-size: 15px;
        line-height: 1.3;
    }
    
    .history-item-time {
        font-size: 13px;
        margin-top: 2px;
    }
    
    .history-btn {
        font-size: 14px !important;
        padding: 12px 18px;
        min-height: 48px;
    }
    
    /* 错误提示优化 */
    .error-toast,
    .success-toast {
        font-size: 14px;
        padding: 12px 20px;
        max-width: 95%;
        border-radius: 8px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    input[type="text"] {
        font-size: 17px !important;
        padding: 14px 16px;
    }
    
    button {
        font-size: 15px !important;
        padding: 12px 16px;
        min-height: 48px !important;
        touch-action: manipulation;
    }
    
    .gap-4 {
        gap: 0.75rem;
    }
    
    /* 小屏幕单词高亮优化 */
    .current-word {
        padding: 4px 8px !important;
        font-size: 19px !important;
        border: 2px solid #fff !important;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 焦点指示器 */
button:focus-visible,
input:focus-visible {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    body {
        background: white;
    }
    
    .speech-container {
        border: 2px solid #000;
    }
    
    input[type="text"] {
        border: 2px solid #000;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        color: #e2e8f0;
    }
    
    .speech-container {
        background: #2d3748;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
    
    h1, h2, h3 {
        color: #e2e8f0;
    }
    
    .text-gray-600 {
        color: #a0aec0;
    }
    
    input[type="text"] {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    input[type="text"]:focus {
        border-color: #63b3ed;
    }
    
    .speed-btn {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .speed-btn.active {
        background: #4299e1;
        border-color: #4299e1;
    }
    
    ::-webkit-scrollbar-track {
        background: #2d3748;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #4a5568;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #718096;
    }
}

/* 单词级高亮特效 - 醒目显示 */
.current-word {
    background: linear-gradient(45deg, #FF5722, #E91E63) !important;
    color: white !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    font-weight: 900 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
    box-shadow: 0 2px 8px rgba(255, 87, 34, 0.6), 
                inset 0 1px 0 rgba(255,255,255,0.3) !important;
    animation: word-pulse 0.6s infinite alternate !important;
    transform: scale(1.05) !important;
    z-index: 1001 !important;
    position: relative !important;
}

@keyframes word-pulse {
    0% { 
        opacity: 0.9;
        box-shadow: 0 2px 8px rgba(255, 87, 34, 0.6);
    }
    100% { 
        opacity: 1;
        box-shadow: 0 4px 12px rgba(255, 87, 34, 0.9);
    }
}

/* 打印样式优化 */
@media print {
    /* 基础打印样式重置 */
    body {
        font-family: "Times New Roman", "SimSun", serif !important;
        font-size: 16pt !important;
        line-height: 1.5 !important;
        margin: 0.5cm !important;
        color: #000 !important;
        background: white !important;
    }
    
    /* 中英文合并打印优化 */
    .speech-text.english {
        font-size: 18pt !important;
        line-height: 1.6 !important;
        margin-bottom: 16pt !important;
        text-align: justify !important;
        font-family: "Times New Roman", serif !important;
        font-weight: 500 !important;
    }
    
    .speech-text.chinese {
        font-size: 16pt !important;
        line-height: 1.7 !important;
        margin-bottom: 14pt !important;
        text-align: justify !important;
        font-family: "SimSun", "宋体", serif !important;
        font-weight: 500 !important;
    }
    
    /* 中英文对照打印优化 */
    .sentence-pair {
        margin-bottom: 6pt !important;
        padding: 4pt !important;
        border: 0.5pt solid #ddd !important;
        page-break-inside: avoid !important;
        background: #fafafa !important;
    }
    
    .english-sentence {
        font-size: 15pt !important;
        font-weight: 600 !important;
        margin-bottom: 2pt !important;
        color: #1565C0 !important;
        line-height: 1.4 !important;
        font-family: "Times New Roman", serif !important;
    }
    
    .chinese-sentence {
        font-size: 14pt !important;
        color: #2E7D32 !important;
        line-height: 1.5 !important;
        font-family: "SimSun", "宋体", serif !important;
        font-weight: 500 !important;
    }
    
    /* 打印标题优化 */
    .print-title {
        font-size: 20pt !important;
        font-weight: bold !important;
        margin-bottom: 10pt !important;
        text-align: center !important;
    }
    
    .print-date {
        font-size: 12pt !important;
        margin-bottom: 8pt !important;
        text-align: center !important;
    }
    
    /* 段落间距优化 */
    .english-section, .chinese-section {
        margin-bottom: 12pt !important;
        page-break-inside: avoid !important;
    }
    
    .section-title {
        font-size: 16pt !important;
        font-weight: bold !important;
        margin-bottom: 6pt !important;
        border-bottom: 1pt solid #666 !important;
        padding-bottom: 2pt !important;
    }
    
    /* 隐藏非打印元素 */
    .no-print, .speech-controls, button, .api-dialog, #controlContainer {
        display: none !important;
    }
    
    /* A4页面优化 */
    @page {
        size: A4 !important;
        margin: 1cm !important;
    }
}