* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    min-height: 90vh;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 32px;
    margin-bottom: 10px;
    font-weight: 700;
}

.header-title.clickable {
    cursor: pointer;
    transition: opacity 0.2s;
}

.header-title.clickable:hover {
    opacity: 0.8;
}

.subtitle {
    font-size: 16px;
    opacity: 0.9;
}

/* 步骤容器 */
.step {
    padding: 30px;
    animation: fadeIn 0.3s ease-in;
}

.step.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-size: 24px;
    color: #333;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 600;
}

/* 分类网格 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.category-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    text-align: center;
}

.category-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.category-name {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.category-desc {
    font-size: 14px;
    color: #666;
}

/* 文书网格 */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.document-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.document-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border-color: #4facfe;
}

.document-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.document-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* 步骤进度 */
.step-progress {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    transition: width 0.3s;
}

.step-indicator {
    text-align: center;
    color: #666;
    font-size: 14px;
    font-weight: 600;
}

/* 步骤导航 */
.step-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.step-nav-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 20px;
    background: #f8f9fa;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid #e9ecef;
}

.step-nav-item:hover {
    background: #e9ecef;
}

.step-nav-item.active {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-color: #4facfe;
}

.step-nav-item.completed {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.step-nav-item .step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    font-weight: 600;
}

.step-nav-item.active .step-number {
    background: rgba(255,255,255,0.4);
}

/* 表单步骤 */
.form-steps-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.form-step {
    animation: fadeIn 0.3s ease-in;
}

.form-step-title {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #4facfe;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-step-title .step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group label.required::after {
    content: " *";
    color: #ff4444;
}

.template-selector {
    margin-bottom: 10px;
}

.template-selector select {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #4facfe;
    color: #1976d2;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.form-control::placeholder {
    color: #999;
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

textarea.form-control {
    min-height: 200px;
    resize: vertical;
}

/* 表单验证错误样式 */
.form-control.error {
    border-color: #ff4757;
    background-color: #fff5f5;
}

.form-control.error:focus {
    border-color: #ff4757;
    box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.1);
}

.field-error {
    color: #ff4757;
    font-size: 13px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.field-error::before {
    content: '⚠️';
}

/* 操作按钮 */
.step-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none !important;
}

/* 预览区域 */
.preview-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.preview-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.preview-content {
    background: white;
    border-radius: 8px;
    padding: 40px;
    min-height: 600px;
    border: 1px solid #e9ecef;
    font-family: 'SimSun', '宋体', serif;
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
    overflow-y: auto;
    max-height: 700px;
}

/* 文书标题样式 */
.preview-content .document-title {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 30px;
}

/* 文书段落样式 */
.preview-content p {
    margin: 10px 0;
    line-height: 1.8;
    text-indent: 2em;
    text-align: justify;
}

/* 文本区域工具栏样式 */
.textarea-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-ai:active {
    transform: translateY(0);
}

.template-select {
    flex: 1;
    max-width: 300px;
}

.preview-content:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.1);
}

/* 文书内容样式 */
.document-content h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 22px;
}

.document-content .doc-title {
    text-align: center;
    font-weight: bold;
    font-size: 24px;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
}

.document-content .parties {
    margin: 20px 0;
    text-indent: 2em;
}

.document-content .content {
    text-indent: 2em;
    line-height: 2;
    margin-bottom: 15px;
}

.document-content .signature {
    margin-top: 40px;
    text-align: right;
}

.document-content .date {
    margin-top: 20px;
    text-align: right;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 分类网格：移动端一行显示2个 */
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* 文书网格：移动端一行显示2个 */
    .document-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* 更小的屏幕（手机竖屏）：一行2个，但间距更小 */
    @media (max-width: 480px) {
        .category-grid,
        .document-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
        }

        /* 分类卡片移动端优化 */
        .category-card {
            padding: 20px 12px;
        }

        .category-icon {
            font-size: 36px;
            margin-bottom: 10px;
        }

        .category-name {
            font-size: 16px;
            margin-bottom: 5px;
        }

        .category-desc {
            font-size: 12px;
            line-height: 1.4;
        }

        /* 文书卡片移动端优化 */
        .document-card {
            padding: 18px 12px;
        }

        .document-name {
            font-size: 15px;
            margin-bottom: 8px;
        }

        .document-desc {
            font-size: 12px;
            line-height: 1.4;
        }
    }

    /* 普通移动端（480-768px）优化 */
    .category-card {
        padding: 24px 15px;
    }

    .category-icon {
        font-size: 42px;
        margin-bottom: 12px;
    }

    .category-name {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .category-desc {
        font-size: 13px;
        line-height: 1.4;
    }

    .document-card {
        padding: 20px 15px;
    }

    .document-name {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .document-desc {
        font-size: 13px;
        line-height: 1.4;
    }

    /* 头部移动端优化 */
    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 13px;
    }

    .step-title {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .step {
        padding: 20px 15px;
    }

    .step-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .preview-toolbar {
        flex-direction: column;
    }

    .preview-toolbar .btn {
        width: 100%;
    }

    /* 案由选择器移动端优化 */
    .cause-input-group {
        flex-direction: column;
        gap: 8px;
    }

    .cause-input {
        width: 100%;
        min-width: auto;
    }

    .cause-toggle-btn {
        width: 100%;
        text-align: center;
    }

    .cause-selector {
        padding: 10px;
        margin-top: 8px;
    }

    .cause-categories {
        max-height: 250px;
    }

    .cause-items {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 5px;
    }

    .cause-checkbox {
        padding: 4px 6px;
    }

    .cause-checkbox span {
        font-size: 12px;
    }

    .cause-actions {
        flex-direction: column;
    }

    .cause-actions .btn {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* 案由选择器样式 */
.cause-select-container {
    margin-bottom: 10px;
}

.cause-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.cause-input {
    flex: 1;
    min-width: 0;
}

.cause-toggle-btn {
    white-space: nowrap;
    padding: 12px 20px;
    flex-shrink: 0;
}

.cause-selector {
    border: 2px solid #4facfe;
    border-radius: 8px;
    padding: 15px;
    background: #f8f9fa;
    margin-top: 10px;
    animation: fadeIn 0.3s ease-in;
    position: relative;
}

.cause-selector.hidden {
    display: none;
}

.cause-categories {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

.cause-category {
    margin-bottom: 10px;
}

.cause-category-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
}

.cause-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    padding: 4px 0;
}

.cause-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e9ecef;
}

.cause-checkbox:hover {
    background: #e3f2fd;
    border-color: #4facfe;
}

.cause-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.cause-checkbox span {
    font-size: 13px;
    color: #555;
    user-select: none;
    word-break: break-all;
}

.cause-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* AI代写对话框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 25px;
}

.modal-body .form-group {
    margin-bottom: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.modal-body .form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.modal-body .form-control:focus {
    outline: none;
    border-color: #4facfe;
}

.modal-body .form-control:read-only {
    background: #f8f9fa;
}

.modal-body textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* AI加载动画 */
.ai-loading {
    text-align: center;
    padding: 30px;
}

.ai-loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.cause-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 页脚样式 */
.footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 30px 20px;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.footer-section {
    text-align: center;
}

.footer-copyright {
    font-size: 14px;
    color: #666;
    margin: 8px 0;
}

.footer-version {
    font-size: 13px;
    color: #999;
    margin: 8px 0;
}

.footer-contact {
    font-size: 14px;
    color: #666;
    margin: 8px 0;
}

.footer-contact a {
    color: #4facfe;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-contact a:hover {
    color: #00f2fe;
    text-decoration: underline;
}

.footer-icp {
    font-size: 13px;
    color: #999;
    margin: 8px 0;
}

.footer-icp a {
    color: #999;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-icp a:hover {
    color: #666;
}

.footer-disclaimer {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px 20px;
    border-radius: 4px;
}

.disclaimer-text {
    font-size: 13px;
    color: #856404;
    line-height: 1.6;
    margin: 0;
}

/* 移动端页脚优化 */
@media (max-width: 768px) {
    .footer {
        padding: 20px 15px;
        margin-top: 30px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .footer-section {
        text-align: center;
    }

    .footer-disclaimer {
        padding: 12px 15px;
    }

    .disclaimer-text {
        font-size: 12px;
    }
}

