/**
 * CodeDoctor AI - 全局样式
 */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --secondary: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --dark: #1F2937;
    --light: #F3F4F6;
    --white: #FFFFFF;
    --gray-100: #F7FAFC;
    --gray-200: #EDF2F7;
    --gray-300: #E2E8F0;
    --gray-400: #CBD5E0;
    --gray-500: #A0AEC0;
    --gray-600: #718096;
    --gray-700: #4A5568;
    --gray-800: #2D3748;
    --gray-900: #1A202C;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* 通用容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 卡片样式 */
.card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-100);
}

.card-body {
    padding: 24px;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

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

.btn-secondary:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-gray {
    background: var(--gray-300);
    color: var(--gray-700);
}

.btn-gray:hover {
    background: var(--gray-400);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
}

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

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

textarea.form-input {
    resize: vertical;
    min-height: 120px;
}

/* 导航栏 */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-link {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.credits-badge {
    background: linear-gradient(135deg, var(--warning), #F59E0B);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
}

/* 主内容区 */
.main-content {
    padding: 40px 0;
}

/* Hero区域 */
.hero {
    text-align: center;
    padding: 40px 20px;
    color: var(--white);
}

.hero h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.hero p {
    font-size: 16px;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto 20px;
}

/* 子项目网格 */
.subprojects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.subproject-card {
    background: var(--white);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.subproject-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.subproject-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.subproject-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.subproject-desc {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 16px;
    line-height: 1.5;
}

.subproject-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.mode-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.mode-badge.task {
    background: #EEF2FF;
    color: var(--primary);
}

.mode-badge.chat {
    background: #ECFDF5;
    color: var(--secondary);
}

.credits-cost {
    font-weight: 600;
    color: var(--warning);
}

/* 代码包列表 */
.code-packages {
    margin-top: 40px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 24px;
}

.package-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.package-item {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.package-info h3 {
    font-size: 16px;
    color: var(--dark);
    margin-bottom: 4px;
}

.package-info p {
    font-size: 13px;
    color: var(--gray-500);
}

.package-status {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.ready {
    background: #ECFDF5;
    color: var(--secondary);
}

.status-badge.pending {
    background: #FEF3C7;
    color: var(--warning);
}

.expiry-time {
    font-size: 12px;
    color: var(--gray-500);
}

/* 上传区域 */
.upload-zone {
    border: 3px dashed var(--gray-400);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--white);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #EEF2FF;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: #EEF2FF;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 18px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 13px;
    color: var(--gray-500);
}

/* 认证页面 */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.auth-title {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 32px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-600);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* 任务进度 */
.progress-container {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
}

.progress-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.progress-text {
    font-size: 18px;
    color: var(--gray-600);
    margin-bottom: 16px;
}

.progress-steps {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 24px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.step-icon.active {
    background: var(--primary);
    color: var(--white);
}

.step-icon.done {
    background: var(--secondary);
    color: var(--white);
}

.step-label {
    font-size: 12px;
    color: var(--gray-500);
}

/* 报告样式 */
.report-container {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    clear: both;
}

.report-header {
    background: linear-gradient(135deg, var(--primary), #764ba2);
    color: var(--white);
    padding: 24px;
}

.report-body {
    padding: 32px;
    clear: both;
}

.report-content {
    line-height: 1.8;
    font-size: 15px;
}

.report-content h1 {
    font-size: 28px;
    margin: 24px 0 16px;
    color: var(--dark);
}

.report-content h2 {
    font-size: 22px;
    margin: 20px 0 12px;
    color: var(--dark);
}

.report-content h3 {
    font-size: 18px;
    margin: 16px 0 8px;
    color: var(--gray-800);
}

.report-content p {
    margin: 12px 0;
}

.report-content pre {
    background: var(--gray-100);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 16px 0;
}

.report-content code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.report-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.report-content th,
.report-content td {
    border: 1px solid var(--gray-300);
    padding: 10px 12px;
    text-align: left;
}

.report-content th {
    background: var(--gray-100);
    font-weight: 600;
}

.report-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    clear: both;
}

.report-actions-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 16px 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 100;
}

/* 聊天界面 */
.chat-container {
    background: var(--white);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: var(--white);
}

.message.assistant .message-avatar {
    background: var(--secondary);
    color: var(--white);
}

.message-content {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: 16px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--gray-100);
    color: var(--dark);
    border-bottom-left-radius: 4px;
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--gray-300);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: var(--primary);
}

/* 管理后台 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--dark);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.admin-sidebar-title {
    padding: 0 24px 24px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid var(--gray-700);
    margin-bottom: 24px;
}

.admin-nav-item {
    padding: 14px 24px;
    color: var(--gray-400);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.admin-main {
    flex: 1;
    margin-left: 240px;
    background: var(--gray-100);
    min-height: 100vh;
}

.admin-header {
    background: var(--white);
    padding: 20px 32px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-content {
    padding: 32px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* 数据表格 */
.data-table {
    width: 100%;
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.data-table tr:hover {
    background: var(--gray-50);
}

/* 警告提示 */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
}

/* 手机端菜单按钮默认隐藏 */
.mobile-menu-btn {
    display: none;
}

/* 响应式 */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 32px;
    }

    .subprojects-grid {
        grid-template-columns: 1fr;
    }

    /* 手机端导航栏 */
    .navbar-content {
        flex-wrap: wrap;
    }

    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--gray-100);
        border: none;
        border-radius: 8px;
        font-size: 24px;
        cursor: pointer;
        color: var(--dark);
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 12px;
        padding: 16px 0;
        border-top: 1px solid var(--gray-200);
        margin-top: 12px;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-link {
        padding: 12px 0;
        text-align: center;
        border-bottom: 1px solid var(--gray-100);
    }

    .user-info {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--gray-200);
    }

    .admin-sidebar {
        display: none;
    }

    .admin-main {
        margin-left: 0;
    }

    .chat-messages {
        padding: 16px;
    }

    .message-content {
        max-width: 85%;
    }
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 18px;
}

/* 工具提示 */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--dark);
    color: var(--white);
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 通用底部 */
.site-footer {
    background: var(--gray-900);
    color: var(--gray-400);
    padding: 48px 0 24px;
    margin-top: 48px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    margin-bottom: 32px;
}

.footer-section h3 {
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.footer-section ul li a:hover {
    color: var(--white);
}

.footer-brand p {
    font-size: 14px;
    line-height: 1.7;
}

.footer-bottom {
    border-top: 1px solid var(--gray-800);
    padding-top: 24px;
    margin-top: 24px;
    text-align: center;
}

.footer-bottom p {
    font-size: 13px;
    margin-bottom: 8px;
}

.footer-bottom a {
    color: var(--gray-400);
    text-decoration: none;
    transition: color 0.3s;
}

.footer-bottom a:hover {
    color: var(--white);
}

.footer-links {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-800);
}

.footer-links span {
    font-size: 13px;
    margin-right: 8px;
}

.footer-links a {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--white);
}

.footer-links .separator {
    color: var(--gray-700);
    margin: 0 8px;
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr 2fr;
        gap: 24px;
    }
}
