/* ============================================================
   信息化台账管理系统 - 全局样式
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-100);
    line-height: 1.6;
}

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .2s;
    overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-700);
}
.sidebar-logo {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .5px;
}

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    transition: all .15s;
}
.nav-item:hover { background: var(--gray-800); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.nav-group { margin-top: 8px; }
.nav-group-title {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 1px;
}

.main-area {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin .2s;
}
.sidebar.collapsed + .main-area { margin-left: 0; }

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
    background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-600);
}
.user-info { font-size: 14px; color: var(--gray-600); }
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 12px;
    margin-left: 4px;
}

.content { padding: 24px; flex: 1; }

/* ---- Flash Messages ---- */
.flash {
    padding: 12px 20px;
    margin: 16px 24px 0;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-close {
    background: none; border: none; font-size: 20px; cursor: pointer; opacity: .6;
}
.flash-close:hover { opacity: 1; }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-actions { display: flex; gap: 8px; }

/* ---- Cards ---- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }
.card.full-width { grid-column: 1 / -1; }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}
.stat-number {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ---- Dashboard Grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* ---- Tables ---- */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    color: var(--gray-600);
    font-weight: 600;
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.table tr:hover td { background: var(--gray-50); }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }

.text-center { text-align: center; }
.empty-text { color: var(--gray-400); text-align: center; padding: 30px 0 !important; }
.table-info { text-align: right; color: var(--gray-500); font-size: 13px; margin-top: 8px; }

.actions { white-space: nowrap; }
.actions form { display: inline; }

/* ---- 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;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.btn:hover { opacity: .9; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; }
.required { color: var(--danger); }

.form-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 900px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0 24px;
}
.form-section { margin-bottom: 28px; }
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--primary-light);
}
.form-actions {
    padding-top: 20px;
    display: flex;
    gap: 12px;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-form .form-input,
.filter-form .form-select {
    width: auto;
    min-width: 140px;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: var(--gray-100);
    color: var(--gray-600);
}
.badge-role { background: var(--primary-light); color: var(--primary); }
.badge-system { background: #fef3c7; color: #92400e; }
.badge-login { background: #dbeafe; color: #1e40af; }
.badge-logout { background: #f3f4f6; color: #4b5563; }
.badge-create { background: #dcfce7; color: #166534; }
.badge-update { background: #fef3c7; color: #92400e; }
.badge-delete { background: #fee2e2; color: #991b1b; }
.badge-export { background: #e0e7ff; color: #3730a3; }
.badge-enable { background: #dcfce7; color: #166534; }
.badge-disable { background: #fee2e2; color: #991b1b; }

/* ---- Status ---- */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--gray-400); }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 13px;
    transition: all .15s;
}
.page-link:hover { background: var(--gray-100); }
.page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--gray-400);
}

/* ---- Detail View ---- */
.detail-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.detail-item {
    padding: 8px 0;
}
.detail-label {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}
.detail-value {
    font-size: 14px;
    color: var(--gray-800);
    font-weight: 500;
}

/* ---- Profile Grid ---- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

/* ---- Bar Chart ---- */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-item { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 80px; font-size: 13px; color: var(--gray-600); text-align: right; flex-shrink: 0; }
.bar-track {
    flex: 1;
    height: 24px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .3s;
    min-width: 2px;
}
.bar-value { width: 30px; font-size: 13px; color: var(--gray-600); text-align: center; }

/* ---- Alerts ---- */
.alert {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.collapsed { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-form .form-input, .filter-form .form-select { width: 100%; }
}
