/* ========================================
   发票管理平台 - 样式表
   简洁商务风格
   ======================================== */

/* CSS变量 - 浅色商务风格配色 */
:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --success: #059669;
    --success-dark: #047857;
    --warning: #d97706;
    --warning-dark: #b45309;
    --danger: #dc2626;
    --danger-dark: #b91c1c;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --transition: all 0.2s ease;
}


/* 重置样式 */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* 应用容器 */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== 头部导航 ========== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
}

.nav-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-tab:hover {
    background: var(--glass);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--primary);
    color: white;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
}

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header {
    margin-bottom: 2rem;
}

.panel-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
}

/* ========== 上传区域 ========== */
.upload-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-muted);
}

/* 上传者输入 */
.uploader-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.uploader-input-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.uploader-input-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 180px;
}

.uploader-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.1);
}

/* 上传进度 */
.upload-progress {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* 最近上传 */
.recent-uploads {
    margin-top: 3rem;
}

.recent-uploads h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.uploads-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.upload-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.upload-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.upload-item-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: var(--bg-tertiary);
}

.upload-item-info {
    flex: 1;
    min-width: 0;
}

.upload-item-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-item-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ========== 发票管理 ========== */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 120px;
}

.filter-group input {
    min-width: 200px;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.1);
}

/* 统计信息卡片 */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card.highlight .stat-value {
    color: var(--primary);
}

.stat-card.success .stat-value {
    color: var(--success);
}

.stat-card.warning .stat-value {
    color: var(--warning);
}

/* 批量操作栏 */
.batch-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.selected-count {
    color: var(--text-secondary);
    font-weight: 500;
}

.selected-count span {
    color: var(--primary);
    font-weight: 700;
}

/* 发票表格 */
.invoice-table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-table th,
.invoice-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.invoice-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.invoice-table tr:last-child td {
    border-bottom: none;
}

.invoice-table tr:hover td {
    background: var(--bg-primary);
}

.invoice-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* 发票链接样式 */
.invoice-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.invoice-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* 状态标签 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background: #fef3c7;
    color: #b45309;
}

.status-badge.reimbursed {
    background: #d1fae5;
    color: #047857;
}

/* 分类标签 */
.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.category-badge.category-travel {
    background: #e0f2fe;
    color: #0369a1;
}

.category-badge.category-food {
    background: #fef3c7;
    color: #b45309;
}

.category-badge.category-hotel {
    background: #fce7f3;
    color: #be185d;
}

.category-badge.category-office {
    background: #e0e7ff;
    color: #4338ca;
}

.category-badge.category-telecom {
    background: #d1fae5;
    color: #047857;
}

.category-badge.category-other {
    background: #f1f5f9;
    color: #64748b;
}

/* 发票类型标签 */
.invoice-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    background: #ede9fe;
    color: #6d28d9;
    white-space: nowrap;
}

/* 操作按钮 */
.action-btns {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

.action-btn.delete:hover {
    background: var(--danger);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* 分页控件 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.pagination-info span {
    color: var(--text-primary);
    font-weight: 600;
}

.page-size-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

/* ========== 智能组合 ========== */
.combine-form {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.form-group input {
    font-size: 1.25rem;
    font-weight: 600;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* 组合结果 */
.combine-result {
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.result-card.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.result-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.result-card.success .result-value {
    color: var(--success);
}

.combine-result h3 {
    margin-bottom: 1rem;
}

.combine-invoices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.combine-invoice-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.combine-invoice-card:hover {
    border-color: var(--success);
    transform: translateY(-2px);
}

.combine-invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.combine-invoice-number {
    font-weight: 600;
    color: var(--primary-light);
}

.combine-invoice-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

.combine-invoice-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.combine-actions {
    text-align: center;
}

/* ========== 按钮样式 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-primary);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-icon {
    font-size: 1.1em;
}

/* ========== 模态框 ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* 发票详情 */
.invoice-detail {
    display: grid;
    gap: 1rem;
}

.invoice-detail-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.invoice-detail-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.invoice-detail-value {
    font-weight: 500;
}

/* 分类编辑 */
.category-edit-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.invoice-detail-section {
    margin-top: 1.5rem;
}

.invoice-detail-section h4 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.invoice-items-table {
    width: 100%;
    font-size: 0.875rem;
}

.invoice-items-table th,
.invoice-items-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
}

.invoice-items-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.invoice-preview {
    margin-top: 1.5rem;
    text-align: center;
}

.invoice-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

/* ========== Toast ========== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .nav-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .nav-tab {
        padding: 0.625rem 1rem;
        white-space: nowrap;
    }

    .main-content {
        padding: 1rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group input {
        min-width: auto;
        width: 100%;
    }

    .batch-actions {
        flex-direction: column;
        text-align: center;
    }

    .invoice-table-wrapper {
        overflow-x: auto;
    }

    .invoice-table {
        min-width: 700px;
    }

    .combine-form {
        flex-direction: column;
    }

    .btn-large {
        width: 100%;
        justify-content: center;
    }
}

/* ========== 滚动条样式 ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}