/* ============================================================
   共享后台管理系统 - 主样式表
   配色: 深蓝侧边栏 #1e293b / 白色内容区
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: #f1f5f9;
    color: #334155;
    line-height: 1.6;
}
a { color: #3b82f6; text-decoration: none; }
a:hover { color: #2563eb; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* --- Layout --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: #1e293b;
    color: #94a3b8;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #334155;
}
.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-header h1 svg { flex-shrink: 0; }
.sidebar-header .subtitle {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}
.nav-section {
    padding: 0 16px;
    margin-bottom: 8px;
}
.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #475569;
    padding: 8px 8px 4px;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 13px;
    transition: all .15s;
    margin-bottom: 2px;
}
.nav-item:hover {
    background: #334155;
    color: #e2e8f0;
}
.nav-item.active {
    background: #3b82f6;
    color: #fff;
}
.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #334155;
    font-size: 12px;
}
.sidebar-footer .admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-footer .admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
}
.sidebar-footer .admin-name { color: #e2e8f0; font-weight: 500; }
.sidebar-footer .admin-role { color: #64748b; font-size: 11px; }

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Top Header --- */
.top-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
}
.top-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
}
.breadcrumb a { color: #64748b; }
.breadcrumb a:hover { color: #334155; }
.breadcrumb .separator { color: #cbd5e1; }
.breadcrumb .current { color: #334155; font-weight: 500; }

.top-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #64748b;
    border-radius: 4px;
}
.btn-sidebar-toggle:hover { background: #f1f5f9; }

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding: 24px;
}
.page-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 20px;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

/* --- Stat Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.stat-info h3 {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 6px;
}
.stat-info .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}
.stat-info .stat-change {
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-change.up { color: #16a34a; }
.stat-change.down { color: #dc2626; }
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.data-table {
    width: 100%;
    font-size: 13px;
}
.data-table thead {
    background: #f8fafc;
}
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: #f8fafc;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .text-muted { color: #94a3b8; }
.data-table .text-mono { font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* --- Status Badges --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}
.status-pending   { background: #fef3c7; color: #92400e; }
.status-paid      { background: #dbeafe; color: #1e40af; }
.status-shipped   { background: #e0e7ff; color: #3730a3; }
.status-completed { background: #dcfce7; color: #166534; }
.status-refunded  { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: #f1f5f9; color: #475569; }
.status-active    { background: #dcfce7; color: #166534; }
.status-disabled  { background: #fee2e2; color: #991b1b; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-secondary {
    background: #fff;
    color: #334155;
    border-color: #e2e8f0;
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-success {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-group {
    display: flex;
    gap: 6px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.form-control::placeholder { color: #9ca3af; }

select.form-control {
    appearance: none;
    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='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.form-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-inline .form-group { margin-bottom: 0; }

/* --- Filters / Toolbar --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    position: relative;
}
.search-box input {
    padding-left: 34px;
    min-width: 220px;
}
.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.page-btn:hover { background: #f1f5f9; color: #1e293b; border-color: #cbd5e1; }
.page-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.page-btn.disabled { opacity: .4; cursor: default; pointer-events: none; }
.page-dots { color: #94a3b8; padding: 0 4px; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: #1e293b; }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #94a3b8;
    border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; color: #475569; }
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
}

/* --- Alert / Notice --- */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* --- Chart Placeholder --- */
.chart-placeholder {
    background: #f8fafc;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 13px;
}

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 400px;
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo {
    width: 48px;
    height: 48px;
    background: #1e293b;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 16px;
}
.login-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
}
.login-header p { color: #64748b; font-size: 13px; }

.login-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.login-card .form-control {
    padding: 10px 12px;
    font-size: 14px;
}
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; }
.login-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}
.empty-state svg { margin-bottom: 12px; color: #cbd5e1; }
.empty-state p { font-size: 14px; }

/* --- Utility --- */
.text-sm { font-size: 12px; }
.text-muted { color: #94a3b8; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .btn-sidebar-toggle {
        display: flex;
    }
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .modal { margin: 10px; }
}

/* --- Scrollbar --- */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

/* --- Toast Animation --- */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- Sort Indicators --- */
.sort-asc::after { content: ' ▲'; font-size: 10px; color: #3b82f6; }
.sort-desc::after { content: ' ▼'; font-size: 10px; color: #3b82f6; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: #3b82f6; }

/* --- Profile Page --- */
.profile-card { background: #fff; border-radius: 12px; padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.profile-card h3 { font-size: 16px; font-weight: 600; color: #1e293b; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; }
.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.form-row .form-group { flex: 1; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

/* --- Chart Cards --- */
.chart-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.chart-card h3 { font-size: 14px; font-weight: 600; color: #1e293b; margin-bottom: 16px; }
.chart-container { height: 300px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
