/* 全局样式 */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --bg-color: #f9f9f9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-radius: 8px;
    --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden; /* 防止在移动设备上水平滚动 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%; /* 确保容器占满可用宽度 */
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 30px;
    flex-wrap: nowrap; /* 防止换行 */
    gap: 15px;
}

h1, h2 {
    color: var(--secondary-color);
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@media (min-width: 768px) {
    .main-content {
        flex-direction: row;
    }
    
    .input-section, .preview-section {
        flex: 1;
    }
}

/* 输入区域 */
.input-section {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.instruction-text {
    margin: 20px 0;
    line-height: 1.8;
}

.ai-highlight {
    color: var(--primary-color);
    font-weight: bold;
}

.text-input-container {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    resize: vertical;
    font-family: inherit;
    transition: var(--transition);
    font-size: 16px; /* 移动设备上更好的可读性 */
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 生成按钮 */
.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    z-index: 1;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 6px 12px rgba(41, 128, 185, 0.3), 0 0 0 2px rgba(255, 255, 255, 0.1) inset;
    -webkit-tap-highlight-color: transparent; /* 移除移动设备上点击高亮 */
    touch-action: manipulation; /* 改善触摸体验 */
}

.btn-icon {
    font-size: 20px;
    animation: pulse 2s infinite;
}

.btn-text {
    position: relative;
    z-index: 2;
}

.generate-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    z-index: -1;
    animation: shimmer 1.5s infinite linear;
}

.generate-btn:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #fff, transparent);
    animation: glow 2s infinite;
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(41, 128, 185, 0.4), 0 0 0 2px rgba(255, 255, 255, 0.2) inset;
    background: linear-gradient(135deg, #3498db, #1c6ea4);
}

.generate-btn:hover:before {
    animation: shimmer 1s infinite linear;
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: translateY(0);
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes glow {
    0%, 100% {
        opacity: 0.2;
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    }
}

/* 预览区域 */
.preview-section {
    background-color: var(--card-bg);
    padding: 0;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-section h2 {
    text-align: center;
    margin-bottom: 20px;
}

.card-preview {
    min-height: 300px;
    height: 100%;
    position: relative;
    border: 1px dashed #ddd;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    transition: var(--transition);
    overflow: visible;
    padding: 20px;
    background-color: #fff;
    width: 100%;
    margin: 0;
}

.card-preview.loading:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(52, 152, 219, 0.03);
    z-index: 0;
}

.loading-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background-color: rgba(52, 152, 219, 0.5);
    border-radius: 50%;
    animation: float 3s infinite ease-in-out;
}

@keyframes float {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(30px);
        opacity: 0;
    }
}

.empty-preview {
    color: #999;
    text-align: center;
    font-size: 16px;
    padding: 40px 20px;
}

/* 加载动画 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    height: 100%;
    padding: 30px;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    position: relative;
    animation: rotation 1.5s infinite linear;
}

.loading-spinner:before,
.loading-spinner:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 6px solid transparent;
}

.loading-spinner:before {
    border-top-color: var(--primary-color);
    border-bottom-color: rgba(52, 152, 219, 0.3);
    animation: pulse 1.5s infinite ease-in-out;
}

.loading-spinner:after {
    border-left-color: var(--primary-color);
    border-right-color: rgba(52, 152, 219, 0.3);
    animation: pulse 1.5s infinite ease-in-out alternate;
}

.loading-container p {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 18px;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, var(--primary-color), #2980b9, var(--primary-color));
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: gradientText 3s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

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

@keyframes gradientText {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* 隐藏元素 */
.hidden {
    display: none !important;
}

/* 设置按钮 */
.settings-btn {
    background-color: transparent;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.settings-btn:hover {
    background-color: var(--secondary-color);
    color: white;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 500px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background-color: var(--secondary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: white;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    transform: scale(1.1);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.save-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.save-btn:hover {
    background-color: #2980b9;
}

/* 卡片内容样式 */
.card-content {
    width: 100%;
    height: 100%;
    max-width: 100%;
    padding: 0;
    font-family: 'Arial', sans-serif;
    display: block;
    background-color: #fff;
    box-sizing: border-box;
}

/* 下载按钮样式 */
.download-btn {
    margin-top: 20px !important;
    margin-bottom: 10px !important;
    padding: 12px 24px !important;
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    transition: background-color 0.3s ease, transform 0.3s ease !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1) !important;
    text-transform: none !important;
    max-width: 200px !important;
    display: block !important;
    width: auto !important;
    align-self: center !important;
}

.download-btn:hover {
    background-color: #2980b9 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15) !important;
}

.download-btn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    transform: translateY(0) !important;
}

/* 响应式调整 */
@media (max-width: 768px) {
    header {
        flex-direction: row; /* 改为水平排列 */
        align-items: center;
        justify-content: space-between;
        padding: 15px 0;
        margin-bottom: 20px;
        gap: 10px;
    }
    
    h1 {
        margin: 0; /* 移除底部间距 */
        font-size: 22px; /* 稍微调小字体 */
        flex: 1; /* 让标题占据剩余空间 */
    }
    
    .settings-btn {
        padding: 6px 12px;
        font-size: 14px;
        border-width: 1.5px;
        white-space: nowrap; /* 防止文字换行 */
        min-width: 60px; /* 确保按钮有最小宽度 */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .card-preview {
        min-height: 200px;
        margin-bottom: 20px;
        padding: 0px 0;
    }
    
    .card-content {
        max-width: 100%;
        overflow-x: auto;
    }
    
    .instruction-text {
        font-size: 14px;
    }
    
    .modal-content {
        width: 90%;
        max-width: 350px;
        padding: 15px;
    }
    
    .form-group input,
    .form-group select {
        font-size: 16px; /* 防止iOS上自动缩放 */
    }
    
    .generate-btn {
        padding: 14px;
    }
    
    /* 改善移动设备上的触摸目标大小 */
    .close-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
}

/* 针对更小的设备的优化 */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .input-section {
        padding: 15px;
        align-content: center;
    }

    .preview-section {
        padding: 0px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    textarea {
        min-height: 120px;
    }
    
    .btn-text {
        font-size: 14px;
    }
    
    header {
        padding: 12px 0;
        margin-bottom: 15px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .settings-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
}

/* 添加对浮动键盘的支持 */
@media screen and (max-height: 450px) and (orientation: landscape) {
    .container {
        padding: 10px;
    }
    
    .input-section, 
    .preview-section {
        padding: 10px;
    }
    
    textarea {
        min-height: 80px;
    }
    
    .instruction-text {
        margin: 10px 0;
    }
    
    .text-input-container {
        margin-bottom: 15px;
    }
}

/* 确保安全区域和可访问性 */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .modal-content {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
} 