/**
 * 主页面样式表 - 文章生成页面
 * 优化版本 - 支持IE11+兼容性和响应式设计
 */

/* 基础响应式设计 */
@media (max-width: 1199px) {
    /* 中等屏幕：平板横屏 */
    .container {
        max-width: 960px;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .article-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 991px) {
    /* 中等屏幕：平板竖屏 */
    .container {
        max-width: 720px;
    }
    
    .grid-cols-2 {
        -ms-grid-columns: 1fr !important;
        grid-template-columns: 1fr !important;
    }
    
    .controls-section {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        gap: 1rem;
    }
    
    .control-group {
        width: 100%;
    }
}

@media (max-width: 767px) {
    /* 小屏幕：手机横屏 */
    .container {
        max-width: 540px;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .header {
        padding: 1rem 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .controls-container {
        background: white;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .article-grid {
        -ms-grid-columns: 1fr !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .article-card {
        min-height: 200px;
    }
    
    .model-name {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

@media (max-width: 575px) {
    /* 小屏幕：手机竖屏 */
    .container {
        max-width: 100%;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .controls-container {
        padding: 0.75rem;
    }
    
    .btn {
        width: 100%;
        min-height: 44px; /* 触摸友好 */
        padding: 12px 16px;
        font-size: 16px; /* 防止iOS缩放 */
        margin-bottom: 0.5rem;
    }
    
    .form-select {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* 防止iOS缩放 */
        padding: 10px 14px;
    }
    
    .article-card {
        padding: 0.75rem;
        min-height: 180px;
    }
    
    .article-content {
        font-size: 0.875rem;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    /* 超小屏幕 */
    .container {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    
    .header {
        padding: 0.75rem 0;
    }
    
    .article-card {
        padding: 0.5rem;
        min-height: 160px;
    }
    
    .model-name {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* 兼容性优化 */
/* Flexbox 兼容性 */
.flex {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

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

.justify-center {
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.justify-between {
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
}

.items-center {
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

.flex-1 {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 0%;
    flex: 1 1 0%;
}

.flex-col {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
}

/* Grid 兼容性回退 */
.article-grid {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* IE Grid 回退 */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .article-grid {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    }
    
    .article-card {
        -webkit-box-flex: 1;
        -ms-flex: 1 1 calc(50% - 0.5rem);
        flex: 1 1 calc(50% - 0.5rem);
        margin: 0.25rem;
    }
    
    @media (max-width: 767px) {
        .article-card {
            -webkit-box-flex: 1;
            -ms-flex: 1 1 100%;
            flex: 1 1 100%;
        }
    }
}

/* 按钮交互优化 */
.btn {
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.btn:hover {
    -webkit-transform: translateY(-1px);
    transform: translateY(-1px);
}

.btn:active {
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    -webkit-transform: none;
    transform: none;
}

/* 表单控件优化 */
.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: white;
    color: #374151;
    -webkit-transition: border-color 0.2s ease;
    transition: border-color 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: #3b82f6;
    -webkit-box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 文章卡片优化 */
.article-card {
    background: white;
    border-radius: 8px;
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.article-card:hover {
    -webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.article-card.error {
    border-left: 4px solid #ef4444;
}

.article-card.success {
    border-left: 4px solid #10b981;
}

.article-card.loading {
    border-left: 4px solid #3b82f6;
}

/* 加载状态动画 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-radius: 50%;
    border-top-color: #3b82f6;
    -webkit-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
}

@-webkit-keyframes spin {
    to {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@keyframes spin {
    to {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

/* 模型标签 */
.model-name {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

/* 文章内容区域 */
.article-content {
    padding: 1rem;
    min-height: 150px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content.placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* 错误状态 */
.error-message {
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 0.875rem;
}

/* 成功状态 */
.success-message {
    color: #10b981;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 0.875rem;
}

/* 进度指示器 */
.progress-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e5e7eb;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: #3b82f6;
    -webkit-transition: width 0.3s ease;
    transition: width 0.3s ease;
}

/* 控制面板样式 */
.controls-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 1rem;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.control-group {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 0.5rem;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* 页面头部 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* IE 回退 */
    background: #667eea;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#667eea', endColorstr='#764ba2', GradientType=1);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header p {
    font-size: 1.125rem;
    opacity: 0.9;
    margin: 0.5rem 0 0 0;
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* 主内容区域 */
.main-content {
    padding: 2rem 0;
}

/* 触摸设备优化 */
@media (hover: none) {
    .btn:hover {
        -webkit-transform: none;
        transform: none;
    }
    
    .article-card:hover {
        -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .article-card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid #000;
    }
    
    .form-select {
        border: 2px solid #000;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;
        -webkit-transition-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .article-card {
        background: #374151;
        color: #f9fafb;
    }
    
    .controls-section {
        background: #374151;
        color: #f9fafb;
    }
    
    .form-select {
        background-color: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
}

/* 打印样式 */
@media print {
    .controls-section,
    .btn,
    .header {
        display: none !important;
    }
    
    .article-grid {
        display: block !important;
    }
    
    .article-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        -webkit-box-shadow: none !important;
        box-shadow: none !important;
        border: 1px solid #000;
    }
    
    .model-name {
        position: static !important;
        display: block;
        margin-bottom: 0.5rem;
        background: none !important;
        color: #000 !important;
        font-weight: bold;
    }
} 