/* ============================================================
   Jirafeau Clone - 主样式表
   ============================================================ */

/* === 重置 & 基础 === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4F6EF7;
    --primary-hover: #3D57D9;
    --primary-light: #EEF1FE;
    --success: #22C55E;
    --success-light: #F0FDF4;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --bg: #F8FAFC;
    --bg-white: #FFFFFF;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* === 头部 === */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* === 上传区域 === */
.upload-section {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    margin-bottom: 32px;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
    transition: color var(--transition);
}

.upload-area:hover .upload-icon,
.upload-area.drag-over .upload-icon {
    color: var(--primary);
}

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

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

/* === 有效期选择 === */
.expiry-section {
    margin-top: 24px;
}

.expiry-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.expiry-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.expiry-option {
    cursor: pointer;
    position: relative;
}

.expiry-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.expiry-option span {
    display: block;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all var(--transition);
    user-select: none;
}

.expiry-option:hover span {
    border-color: var(--primary);
    color: var(--primary);
}

.expiry-option input:checked + span {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* === 进度条 === */
.progress-section {
    margin-top: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.progress-info span:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.progress-info span:last-child {
    color: var(--primary);
    font-weight: 700;
}

.progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7C8CF8);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-detail {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-chunks {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: var(--radius-xs);
}

.progress-chunks span:last-child {
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.progress-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

/* === 结果展示 === */
.result-card {
    text-align: center;
    padding: 40px 24px;
}

.result-card.success { background: var(--success-light); border-radius: var(--radius); }
.result-card.error { background: var(--danger-light); border-radius: var(--radius); }
.result-card.warning { background: var(--warning-light); border-radius: var(--radius); }

.result-icon { margin-bottom: 16px; }
.result-card.success .result-icon { color: var(--success); }
.result-card.error .result-icon { color: var(--danger); }
.result-card.warning .result-icon { color: var(--warning); }

.result-card h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.result-card.success h3 { color: #166534; }
.result-card.error h3 { color: #991B1B; }
.result-card.warning h3 { color: #92400E; }

.result-card p { color: var(--text-secondary); font-size: 14px; }

.result-details {
    text-align: left;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin: 20px 0;
    display: inline-block;
    min-width: 300px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    gap: 16px;
}

.result-row span { color: var(--text-secondary); }
.result-row strong { color: var(--text); }

.share-link-box {
    margin-top: 16px;
}

.share-link-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-align: left;
}

.copy-row {
    display: flex;
    gap: 8px;
}

.copy-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    font-family: "SF Mono", "Fira Code", monospace;
}

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-copy {
    background: var(--success);
    color: white;
    flex-shrink: 0;
}
.btn-copy:hover { background: #16A34A; }

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

.btn-warning {
    background: var(--warning);
    color: white;
}
.btn-warning:hover { background: #D97706; }

.btn-download {
    background: var(--primary);
    color: white;
    padding: 14px 36px;
    font-size: 16px;
    border-radius: var(--radius);
    margin-top: 20px;
}
.btn-download:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.btn-block { width: 100%; }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-tiny { padding: 4px 10px; font-size: 12px; border-radius: 4px; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-light); }

/* === 信息卡片 === */
.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.info-card {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}

.info-card:hover { box-shadow: var(--shadow-lg); }

.info-icon {
    color: var(--primary);
    margin-bottom: 12px;
}

.info-card h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.info-card p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === 下载详情页 === */
.download-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    text-align: center;
    margin-top: 20px;
}

.file-icon {
    color: var(--primary);
    margin-bottom: 16px;
}

.download-card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    word-break: break-all;
}

.file-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.meta-item {
    text-align: center;
}

.meta-item span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.meta-item strong {
    font-size: 14px;
    color: var(--text);
}

.download-actions { margin: 8px 0 20px; }

.expired-notice {
    color: var(--danger);
    font-weight: 600;
    font-size: 15px;
}

.error-notice {
    color: var(--text-muted);
    font-size: 15px;
}

.back-link {
    margin-top: 16px;
    font-size: 14px;
}

/* === 登录页 === */
.login-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    margin: 80px auto;
}

.login-icon { color: var(--primary); margin-bottom: 16px; }

.login-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

.login-form { text-align: left; }

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 15px;
    color: var(--text);
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-hint {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.alert {
    padding: 10px 16px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #FECACA;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* === 管理后台 === */
.admin-container {
    max-width: 1100px;
}

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

.admin-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-title h2 {
    font-size: 22px;
    font-weight: 700;
}

.admin-badge {
    font-size: 12px;
    font-weight: 600;
    background: var(--success-light);
    color: var(--success);
    padding: 4px 10px;
    border-radius: 20px;
}

.admin-nav {
    display: flex;
    gap: 8px;
}

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

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card.warning { background: var(--warning-light); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-card.warning .stat-value { color: var(--warning); }

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-left { flex: 1; max-width: 340px; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }

.search-input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-white);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.file-table-wrapper {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.file-table thead {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.file-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.file-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: var(--bg); }

.row-expired { opacity: 0.4; }
.row-expired:hover { opacity: 0.6; }

.file-name {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    text-align: center !important;
    padding: 60px 20px !important;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
}

.badge-active { background: var(--success-light); color: var(--success); }
.badge-expired { background: var(--danger-light); color: var(--danger); }
.badge-missing { background: var(--warning-light); color: var(--warning); }

.action-cell {
    display: flex;
    gap: 6px;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 28px;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 600;
    color: white;
    z-index: 9999;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.toast-show { transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* === 页脚 === */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.admin-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* === 响应式 === */
@media (max-width: 768px) {
    .container { padding: 20px 12px 40px; }

    .header h1 { font-size: 24px; }

    .upload-section { padding: 20px; }

    .upload-area { padding: 32px 16px; }

    .info-cards { grid-template-columns: 1fr; }

    .file-meta { flex-direction: column; gap: 12px; }

    .download-card { padding: 24px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .admin-toolbar { flex-direction: column; align-items: stretch; }

    .toolbar-left { max-width: 100%; }

    .file-table-wrapper { overflow-x: auto; }

    .file-table { min-width: 700px; }

    .copy-row { flex-direction: column; }
}
