/* ============================================
   钉钉T+对接系统 - 桌面端管理后台样式
   ============================================ */

:root {
    --sidebar-width: 250px;
    --header-height: 56px;
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #4361ee;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: #334155;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

/* ========== Layout ========== */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.top-row {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.top-row .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
}

.top-row .user-info .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.top-row .user-info a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.top-row .user-info a:hover {
    color: var(--danger);
}

.content {
    padding: 24px 28px !important;
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.content.no-scroll {
    overflow: hidden;
}

/* ========== Nav Menu ========== */
.nav-menu {
    padding: 0;
}

.nav-menu .nav-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
}

.nav-menu .nav-header h5 {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.nav-menu .nav-header .nav-subtitle {
    color: #64748b;
    font-size: 11px;
    margin-top: 2px;
}

.nav-menu .nav-group {
    padding: 16px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.nav-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 450;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    margin: 1px 0;
}

.nav-menu .nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-menu .nav-link.active {
    background: rgba(67, 97, 238, 0.15);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active);
    font-weight: 550;
}

.nav-menu .nav-link .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* ========== Page Header ========== */
.page-header {
    margin-bottom: 24px;
}

.page-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.page-header .page-desc {
    color: #94a3b8;
    font-size: 13px;
    margin: 0;
}

/* ========== Stat Cards ========== */
.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}

.stat-card .stat-icon.bg-primary-soft {
    background: #eef2ff;
    color: var(--primary);
}

.stat-card .stat-icon.bg-warning-soft {
    background: #fef3c7;
    color: #d97706;
}

.stat-card .stat-icon.bg-success-soft {
    background: #d1fae5;
    color: #059669;
}

.stat-card .stat-icon.bg-danger-soft {
    background: #fee2e2;
    color: #dc2626;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

/* ========== Cards ========== */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    background: #ffffff;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
    color: #1e293b;
    border-radius: 12px 12px 0 0 !important;
}

.card-body {
    padding: 20px;
}

/* ========== Tables ========== */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: #e2e8f0;
}

.table thead th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: #334155;
    font-size: 13.5px;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== Badges ========== */
.badge {
    font-weight: 500;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.01em;
}

.badge.bg-success {
    background: #d1fae5 !important;
    color: #065f46 !important;
}

.badge.bg-danger {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.badge.bg-warning {
    background: #fef3c7 !important;
    color: #92400e !important;
}

.badge.bg-secondary {
    background: #f1f5f9 !important;
    color: #475569 !important;
}

.badge.bg-primary {
    background: #eef2ff !important;
    color: #3730a3 !important;
}

.badge.bg-info {
    background: #cffafe !important;
    color: #155e75 !important;
}

/* ========== Buttons ========== */
.btn {
    font-weight: 500;
    font-size: 13.5px;
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm {
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: 6px;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: #c7d2fe;
}

.btn-outline-primary:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #fecaca;
}

.btn-outline-danger:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: var(--danger);
}

/* ========== Forms ========== */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    font-size: 13.5px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-label {
    font-size: 13px;
    font-weight: 550;
    color: #374151;
    margin-bottom: 4px;
}

/* ========== Toolbar ========== */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========== Edit Form Card ========== */
.edit-form-card {
    background: #ffffff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.08);
}

.edit-form-card h6 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

/* ========== Alert ========== */
.alert {
    border-radius: 10px;
    font-size: 13.5px;
    border: none;
    padding: 12px 16px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-info {
    background: #cffafe;
    color: #155e75;
}

/* ========== Login Page ========== */
.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-card .login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #4361ee, #7c3aed);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: white;
    margin-bottom: 12px;
}

.login-card .login-logo h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.login-card .login-logo p {
    color: #94a3b8;
    font-size: 13px;
    margin: 4px 0 0;
}

.login-card .form-control {
    padding: 10px 14px;
    font-size: 14px;
}

.login-card .btn-primary {
    padding: 10px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
}

.login-card .login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    margin: 0;
}

/* ========== Status Dot ========== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: #d1d5db;
}

.status-dot.error {
    background: var(--danger);
}

/* ========== Scrollbar ========== */
.content::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ========== Table Scroll ========== */
.table-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--card-shadow);
}

.table-scroll .table {
    margin-bottom: 0;
}

.table-scroll .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-scroll .table thead th {
    box-shadow: 0 2px 0 #e2e8f0;
}

.table-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* ========== Search Row ========== */
.search-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-row .search-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-row .search-field label {
    font-size: 11px;
    font-weight: 550;
    color: #94a3b8;
    margin: 0;
}

.search-row .search-field .form-control,
.search-row .search-field .form-select {
    font-size: 12.5px;
    padding: 5px 10px;
    min-width: 130px;
    height: 32px;
}

/* Table header search row override */
thead tr.search-row {
    display: table-row;
}

thead tr.search-row th {
    padding: 4px 8px;
    vertical-align: middle;
}

thead tr.search-row .form-control,
thead tr.search-row .form-select {
    font-size: 12px;
    padding: 4px 8px;
    height: 30px;
}

/* ========== Blazor Error ========== */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ========== Searchable Select ========== */
.searchable-select {
    position: relative;
}

.searchable-select .form-control {
    cursor: text;
}

.searchable-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 300;
}

.searchable-option {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-option:hover {
    background: var(--primary-light);
}

.searchable-option.active {
    background: #e0e7ff;
    font-weight: 600;
}

/* ========== Extra Fields (展开行) ========== */
.extra-fields {
    padding: 12px 20px;
    background: #f8fafc;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 24px;
    max-height: 200px;
    overflow-y: auto;
}

.extra-field-item {
    font-size: 12.5px;
    line-height: 1.8;
}

.extra-field-key {
    color: #64748b;
    font-weight: 500;
    margin-right: 4px;
}

.extra-field-value {
    color: #1e293b;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    background: #e2e8f0;
    padding: 1px 6px;
    border-radius: 4px;
}

/* ========== Sync Overlay ========== */
.sync-overlay {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(241, 245, 249, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.sync-overlay .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
}

.sync-overlay p {
    font-size: 15px;
    font-weight: 500;
    color: #475569;
}

/* ========== Misc ========== */
.text-muted {
    color: #94a3b8 !important;
}

.fw-semibold {
    font-weight: 600;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
    font-size: 12px;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 8px;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* ========== Dept Tree ========== */
.col-filter {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.col-filter span {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.col-filter input {
    font-size: 12px;
    padding: 2px 6px;
    height: 26px;
    border-radius: 4px;
}

.col-filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
}

/* ========== Dept Tree ========== */
.dept-tree {
    font-size: 14px;
    user-select: none;
}

.tree-node {
    line-height: 1.8;
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: default;
}

.tree-node-content:hover {
    background: #f1f5f9;
}

.tree-toggle {
    cursor: pointer;
    width: 16px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
}

.tree-icon {
    color: #f59e0b;
    font-size: 14px;
}

.tree-label {
    color: #1e293b;
    font-weight: 500;
}

.tree-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-left: auto;
    font-family: monospace;
}

.tree-count {
    font-size: 11px;
    font-weight: 500;
    margin-left: auto;
    padding: 2px 7px;
    background: #e2e8f0 !important;
    color: #64748b !important;
}

/* ========== Sticky Table Header in Card ========== */
.card-body.overflow-y-auto .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    box-shadow: 0 2px 0 #e2e8f0;
}