*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 基础和通用样式 */
:root {
    --primary-color: #007aff;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #6c757d;
    --gray-600: #5a6268;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-700);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 加载动画 */
#initialLoader {
    position: fixed;
    inset: 0;
    background-color: white;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease-out;
}
#initialLoader.fade-out {
    opacity: 0;
    pointer-events: none;
}
.loading-spinner {
    width: 50px;
    height: 50px;
}
.spinner-icon {
    width: 100%;
    height: 100%;
    animation: rotate 1.5s linear infinite;
}
.spinner-circle {
    stroke: var(--primary-color);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* 登录页面 */
#loginPage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(to bottom right, #f0f9ff 0%, #e0f2fe 50%, #dbeafe 100%);
}
.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 60px -5px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.login-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
.form-hint {
    display: block;
    margin-top: 0.5rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}
.auth-switch {
    margin-top: 1.5rem;
    color: var(--gray-600);
}
.auth-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.auth-link:hover {
    text-decoration: underline;
}
.success-message {
    padding: 2rem;
}
.success-icon {
    width: 64px;
    height: 64px;
    color: var(--success-color);
    margin-bottom: 1rem;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background-color: #0062cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}
.btn-outline {
    background-color: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-outline:hover:not(:disabled) {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
}
.btn-danger {
    background-color: var(--danger-color);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
}
.btn-success {
    background-color: var(--success-color);
    color: white;
}
.btn-success:hover:not(:disabled) {
    background-color: #218838;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}
.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--gray-600);
}
.btn-icon:hover {
    color: var(--gray-900);
    background-color: var(--gray-100);
    border-radius: 0.375rem;
}

/* 导航栏 */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.navbar-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-info {
    padding: 0.5rem 1rem;
    background-color: var(--gray-100);
    border-radius: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

/* 主容器 */
.container {
    max-width: 1280px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* 卡片样式 */
.quota-card,
.upload-card,
.files-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* 配额卡片 */
.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 1.5rem 0;
}
.quota-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.quota-progress {
    flex: 1;
}
.quota-bar {
    height: 8px;
    background-color: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.quota-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.quota-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--gray-600);
}
.quota-percent {
    color: var(--gray-500);
}
.quota-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}
.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: var(--gray-50);
    border-radius: 0.5rem;
}
.stat-label {
    color: var(--gray-500);
    font-size: 0.875rem;
}
.stat-value {
    font-weight: 600;
    color: var(--gray-900);
}

/* 上传区域 */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background-color: var(--gray-50);
}
.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 122, 255, 0.02);
}
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(0, 122, 255, 0.05);
    transform: scale(1.02);
}
.upload-icon {
    color: var(--gray-400);
    margin-bottom: 1rem;
}
.upload-text {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin: 0 0 0.5rem 0;
}
.upload-hint {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin: 0;
}

/* 上传选项 */
.upload-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}
.option-group {
    display: flex;
    flex-direction: column;
}
.option-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}
.form-select {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
    cursor: pointer;
}
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.form-checkbox {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 上传进度 */
.upload-progress {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    max-height: 300px;
    overflow-y: auto;
}
.progress-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 8px;
    animation: slideIn 0.3s ease;
}
.progress-item:last-child {
    margin-bottom: 0;
}
.progress-item.completed {
    background: rgba(16, 185, 129, 0.1);
}
.progress-item.error {
    background: rgba(239, 68, 68, 0.1);
}
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.progress-name {
    font-size: 0.875rem;
    color: var(--gray-700);
    min-width: 100px;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background-color: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-percent {
    font-size: 0.875rem;
    color: var(--gray-600);
    min-width: 40px;
    text-align: right;
}

/* 文件列表 */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.card-actions {
    display: flex;
    gap: 0.5rem;
}
.table-container {
    overflow-x: auto;
}
.file-table {
    width: 100%;
    border-collapse: collapse;
}
.file-table thead {
    background-color: var(--gray-50);
}
.file-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
    border-bottom: 2px solid var(--gray-200);
}
.file-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}
.file-table tbody tr:hover {
    background-color: var(--gray-50);
}
.empty-state {
    text-align: center;
}
.empty-message {
    padding: 3rem 2rem;
    color: var(--gray-400);
}
.empty-message svg {
    margin-bottom: 1rem;
}
.empty-message p {
    margin: 0;
    font-size: 0.875rem;
}

/* 文件操作 */
.file-actions {
    display: flex;
    gap: 0.25rem;
}
.file-name {
    font-weight: 500;
    color: var(--gray-900);
}
.file-size {
    color: var(--gray-600);
}
.file-date {
    color: var(--gray-500);
    font-size: 0.8125rem;
}
.download-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.download-badge {
    padding: 0.25rem 0.5rem;
    background-color: var(--gray-100);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}
.download-badge.limited {
    background-color: var(--warning-color);
    color: white;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}
.page-info {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* 模态框 */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px -5px rgba(0,0,0,0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}
.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 0.375rem;
}
.btn-close:hover {
    background-color: var(--gray-100);
    color: var(--gray-900);
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}
.api-section {
    margin-bottom: 2rem;
}
.api-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 1rem 0;
}
.code-block {
    background-color: var(--gray-900);
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}
.code-block pre {
    margin: 0;
    white-space: pre-wrap;
}

/* 通知样式 */
#notificationContainer {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.notification {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.notification.success {
    border-left: 4px solid var(--success-color);
}
.notification.error {
    border-left: 4px solid var(--danger-color);
}
.notification.warning {
    border-left: 4px solid var(--warning-color);
}
.notification.info {
    border-left: 4px solid var(--info-color);
}
.notification-icon {
    width: 20px;
    height: 20px;
}
.notification-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--gray-700);
}

/* 工具类 */
.hidden {
    display: none !important;
}
.text-center {
    text-align: center;
}
.text-primary {
    color: var(--primary-color);
}
.text-gray-500 {
    color: var(--gray-500);
}
.mt-8 {
    margin-top: 2rem;
}
.hover\:underline:hover {
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar-container {
        padding: 0 1rem;
    }
    .navbar-brand {
        font-size: 1.25rem;
    }
    .navbar-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .user-info {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    #toggleApiDocs {
        display: none;
    }
    .quota-stats {
        grid-template-columns: 1fr;
    }
    .upload-options {
        grid-template-columns: 1fr;
    }
    .file-table {
        font-size: 0.8125rem;
    }
    .file-table th,
    .file-table td {
        padding: 0.5rem;
    }
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
}