/* ============================================================
   Multi-Theme System — 多主题系统
   通过 html[data-theme="xxx"] 切换主题
   基于 CSS Custom Properties，所有颜色通过变量引用
   ============================================================ */

/* ====== 设计令牌（Design Tokens）====== */
:root {
    --theme-primary: #00d4ff;
    --theme-primary-dim: rgba(0, 212, 255, 0.25);
    --theme-primary-rgb: 0, 212, 255;
    --theme-accent: #00ff88;
    --theme-accent-dim: rgba(0, 255, 136, 0.15);
    --theme-bg: #0a0e17;
    --theme-bg-end: #0f172a;
    --theme-surface: #111827;
    --theme-card: rgba(17, 24, 39, 0.85);
    --theme-card-header: rgba(0, 212, 255, 0.05);
    --theme-border: rgba(0, 212, 255, 0.12);
    --theme-text: #e2e8f0;
    --theme-text-dim: #94a3b8;
    --theme-blue: #0a84ff;
    --theme-input-bg: rgba(15, 23, 42, 0.8);
    --theme-input-bg-focus: rgba(15, 23, 42, 0.95);
    --theme-danger: #dc2626;
    --theme-warning: #f59e0b;
    --theme-success: #059669;
    --theme-overlay: #0a0e17;
}

/* ====== 暗夜科技 (default) ====== */
html[data-theme="dark-tech"] {
    --theme-primary: #00d4ff;
    --theme-primary-dim: rgba(0, 212, 255, 0.25);
    --theme-primary-rgb: 0, 212, 255;
    --theme-accent: #00ff88;
    --theme-accent-dim: rgba(0, 255, 136, 0.15);
    --theme-bg: #0a0e17;
    --theme-bg-end: #0f172a;
    --theme-surface: #111827;
    --theme-card: rgba(17, 24, 39, 0.85);
    --theme-card-header: rgba(0, 212, 255, 0.05);
    --theme-border: rgba(0, 212, 255, 0.12);
    --theme-text: #e2e8f0;
    --theme-text-dim: #94a3b8;
    --theme-blue: #0a84ff;
    --theme-input-bg: rgba(15, 23, 42, 0.8);
    --theme-input-bg-focus: rgba(15, 23, 42, 0.95);
    --theme-danger: #dc2626;
    --theme-warning: #f59e0b;
    --theme-success: #059669;
    --theme-overlay: #0a0e17;
}

/* ====== 简约白 ====== */
html[data-theme="light-clean"] {
    --theme-primary: #2563eb;
    --theme-primary-dim: rgba(37, 99, 235, 0.15);
    --theme-primary-rgb: 37, 99, 235;
    --theme-accent: #16a34a;
    --theme-accent-dim: rgba(22, 163, 74, 0.12);
    --theme-bg: #f8fafc;
    --theme-bg-end: #f1f5f9;
    --theme-surface: #ffffff;
    --theme-card: rgba(255, 255, 255, 0.95);
    --theme-card-header: rgba(37, 99, 235, 0.05);
    --theme-border: rgba(0, 0, 0, 0.08);
    --theme-text: #1e293b;
    --theme-text-dim: #64748b;
    --theme-blue: #2563eb;
    --theme-input-bg: rgba(241, 245, 249, 0.8);
    --theme-input-bg-focus: rgba(255, 255, 255, 0.95);
    --theme-danger: #dc2626;
    --theme-warning: #d97706;
    --theme-success: #16a34a;
    --theme-overlay: #f8fafc;
}

/* ====== 深海蓝 ====== */
html[data-theme="ocean"] {
    --theme-primary: #38bdf8;
    --theme-primary-dim: rgba(56, 189, 248, 0.2);
    --theme-primary-rgb: 56, 189, 248;
    --theme-accent: #06b6d4;
    --theme-accent-dim: rgba(6, 182, 212, 0.15);
    --theme-bg: #0c1929;
    --theme-bg-end: #0f2744;
    --theme-surface: #0f2744;
    --theme-card: rgba(15, 39, 68, 0.85);
    --theme-card-header: rgba(56, 189, 248, 0.06);
    --theme-border: rgba(56, 189, 248, 0.15);
    --theme-text: #e0f2fe;
    --theme-text-dim: #7dd3fc;
    --theme-blue: #0ea5e9;
    --theme-input-bg: rgba(12, 25, 41, 0.8);
    --theme-input-bg-focus: rgba(15, 39, 68, 0.95);
    --theme-danger: #ef4444;
    --theme-warning: #f59e0b;
    --theme-success: #06b6d4;
    --theme-overlay: #0c1929;
}

/* ====== 森林绿 ====== */
/* ====== 极光紫 ====== */
html[data-theme="aurora"] {
    --theme-primary: #a78bfa;
    --theme-primary-dim: rgba(167, 139, 250, 0.2);
    --theme-primary-rgb: 167, 139, 250;
    --theme-accent: #c4b5fd;
    --theme-accent-dim: rgba(196, 181, 253, 0.15);
    --theme-bg: #0f0b1e;
    --theme-bg-end: #1a1432;
    --theme-surface: #17122c;
    --theme-card: rgba(23, 18, 44, 0.85);
    --theme-card-header: rgba(167, 139, 250, 0.06);
    --theme-border: rgba(167, 139, 250, 0.12);
    --theme-text: #ede9fe;
    --theme-text-dim: #a78bfa;
    --theme-blue: #818cf8;
    --theme-input-bg: rgba(15, 11, 30, 0.8);
    --theme-input-bg-focus: rgba(23, 18, 44, 0.95);
    --theme-danger: #ef4444;
    --theme-warning: #f59e0b;
    --theme-success: #34d399;
    --theme-overlay: #0f0b1e;
}

/* ====== 黑曜石 ====== */
html[data-theme="obsidian"] {
    --theme-primary: #b8c0cc;
    --theme-primary-dim: rgba(184, 192, 204, 0.18);
    --theme-primary-rgb: 184, 192, 204;
    --theme-accent: #e2e8f0;
    --theme-accent-dim: rgba(226, 232, 240, 0.12);
    --theme-bg: #0f1115;
    --theme-bg-end: #181b22;
    --theme-surface: #1a1d25;
    --theme-card: rgba(26, 29, 37, 0.85);
    --theme-card-header: rgba(184, 192, 204, 0.04);
    --theme-border: rgba(184, 192, 204, 0.1);
    --theme-text: #e2e8f0;
    --theme-text-dim: #94a3b8;
    --theme-blue: #94a3b8;
    --theme-input-bg: rgba(15, 17, 21, 0.8);
    --theme-input-bg-focus: rgba(26, 29, 37, 0.95);
    --theme-danger: #ef4444;
    --theme-warning: #eab308;
    --theme-success: #22c55e;
    --theme-overlay: #0f1115;
}

/* ============================================================
   组件样式覆盖（使用 Design Tokens）
   ============================================================ */

/* ---------- 全局 ---------- */
body {
    background: linear-gradient(135deg, var(--theme-bg) 0%, var(--theme-bg-end) 100%) !important;
    color: var(--theme-text) !important;
}

/* ---------- 加载蒙层 ---------- */
#loading-overlay {
    background: var(--theme-overlay) !important;
}

#loading-overlay .spinner-border {
    --bs-spinner-width: 2.5rem;
    --bs-spinner-height: 2.5rem;
    color: var(--theme-primary) !important;
}

#loading-overlay p {
    color: var(--theme-primary) !important;
    letter-spacing: 2px;
    font-size: 0.85rem;
}

/* ---------- 头部 ---------- */
.header {
    border-bottom-color: var(--theme-border) !important;
}

.header h1 {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--theme-text-dim) !important;
}

/* ---------- 用户下拉菜单 ---------- */
.user-dropdown-btn {
    color: var(--theme-text) !important;
}

.user-dropdown-btn:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.08) !important;
    color: var(--theme-primary) !important;
}

.dropdown-menu {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

.dropdown-item {
    color: var(--theme-text) !important;
}

.dropdown-item:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.1) !important;
    color: var(--theme-primary) !important;
}

.dropdown-divider {
    border-color: var(--theme-border) !important;
}

/* ---------- 认证区域 ---------- */
.auth-container {
    background: var(--theme-card) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--theme-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}

/* ---------- 导航选项卡 ---------- */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--theme-border);
}

.nav-tabs .nav-link {
    color: var(--theme-text-dim) !important;
    border-color: transparent !important;
}

.nav-tabs .nav-link:hover {
    color: var(--theme-primary) !important;
    border-color: transparent !important;
}

.nav-tabs .nav-link.active {
    color: var(--theme-primary) !important;
    background: transparent !important;
    border-color: var(--theme-border) var(--theme-border) transparent !important;
}

/* ---------- 表单输入 ---------- */
.form-control,
.form-select {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--theme-primary) !important;
    box-shadow: 0 0 0 3px var(--theme-primary-dim), 0 0 12px var(--theme-primary-dim) !important;
    background-color: var(--theme-input-bg-focus) !important;
    color: var(--theme-text) !important;
}

.form-control::placeholder {
    color: var(--theme-text-dim) !important;
    opacity: 0.6;
}

.form-label {
    color: var(--theme-text-dim) !important;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.form-text {
    color: var(--theme-text-dim) !important;
}

.form-check-input {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border) !important;
}

.form-check-input:checked {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

/* ---------- 仪表盘面板 ---------- */
.dashboard {
    background: var(--theme-card) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--theme-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
}

.dashboard-header h2 {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--theme-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: var(--theme-border) !important;
}

.card-header {
    background: var(--theme-card-header) !important;
    border-bottom-color: var(--theme-border) !important;
    color: var(--theme-primary) !important;
}

.card-title {
    color: var(--theme-text) !important;
}

/* ---------- 表格 ---------- */
.table {
    --bs-table-color: var(--theme-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--theme-border);
    --bs-table-striped-bg: rgba(var(--theme-primary-rgb), 0.03);
    --bs-table-hover-bg: rgba(var(--theme-primary-rgb), 0.08);
    --bs-table-hover-color: #fff;
}

.table th {
    color: var(--theme-primary) !important;
    background-color: rgba(var(--theme-primary-rgb), 0.06) !important;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.table td {
    color: var(--theme-text) !important;
}

/* ---------- 按钮 ---------- */
.btn-primary {
    background-color: var(--theme-primary) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.btn-primary:hover {
    background-color: var(--theme-blue) !important;
    box-shadow: 0 0 16px var(--theme-primary-dim) !important;
    border-color: transparent !important;
}

.btn-secondary {
    background-color: rgba(100, 116, 139, 0.3) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.btn-secondary:hover {
    background-color: rgba(100, 116, 139, 0.5) !important;
}

.btn-success {
    background-color: var(--theme-success) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.btn-success:hover {
    box-shadow: 0 0 16px var(--theme-accent-dim) !important;
}

.btn-upload {
    background-color: var(--theme-success) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.btn-upload:hover {
    box-shadow: 0 0 20px var(--theme-accent-dim) !important;
    color: #fff !important;
}

.btn-outline-primary {
    color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.btn-outline-primary:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.15) !important;
    color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.btn-link {
    color: var(--theme-primary) !important;
}

.btn-link:hover {
    color: var(--theme-text) !important;
}

.btn-danger {
    background-color: rgba(220, 38, 38, 0.8) !important;
    border-color: transparent !important;
}

.btn-danger:hover {
    background-color: #dc2626 !important;
    box-shadow: 0 0 16px rgba(220, 38, 38, 0.4) !important;
}

.btn-warning {
    background-color: rgba(245, 158, 11, 0.8) !important;
    border-color: transparent !important;
    color: #000 !important;
}

.btn-sm {
    font-size: 0.75rem !important;
}

/* ---------- 模态框 ---------- */
.modal-content {
    background: var(--theme-surface) !important;
    border: 1px solid var(--theme-border) !important;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6) !important;
}

.modal-header {
    background: rgba(var(--theme-primary-rgb), 0.12) !important;
    border-bottom-color: var(--theme-border) !important;
}

.modal-title {
    color: #fff !important;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.modal-footer {
    border-top-color: var(--theme-border) !important;
}

/* ---------- 徽章 ---------- */
.badge {
    font-weight: 500;
    letter-spacing: 0.3px;
}

.bg-primary {
    background-color: rgba(var(--theme-primary-rgb), 0.2) !important;
    color: var(--theme-primary) !important;
}

.bg-success {
    background-color: rgba(var(--theme-accent), 0.15) !important;
    color: var(--theme-accent) !important;
}

.bg-warning {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #f59e0b !important;
}

.bg-danger {
    background-color: rgba(220, 38, 38, 0.2) !important;
    color: #f87171 !important;
}

.bg-info {
    background-color: rgba(var(--theme-primary-rgb), 0.15) !important;
    color: var(--theme-primary) !important;
}

.bg-secondary {
    background-color: rgba(100, 116, 139, 0.2) !important;
    color: var(--theme-text-dim) !important;
}

/* ---------- 警告提示 ---------- */
.alert {
    border-color: var(--theme-border) !important;
}

.alert-success {
    background-color: rgba(var(--theme-accent), 0.1) !important;
    color: var(--theme-accent) !important;
}

.alert-danger {
    background-color: rgba(220, 38, 38, 0.15) !important;
    color: #f87171 !important;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: #f59e0b !important;
}

.alert-info {
    background-color: rgba(var(--theme-primary-rgb), 0.1) !important;
    color: var(--theme-primary) !important;
}

/* ---------- 分页 ---------- */
.page-link {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-primary) !important;
}

.page-link:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.15) !important;
    color: #fff !important;
}

.page-item.active .page-link {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: #000 !important;
}

.page-item.disabled .page-link {
    background-color: rgba(var(--theme-input-bg), 0.4) !important;
    color: var(--theme-text-dim) !important;
}

/* ---------- 进度条 ---------- */
.progress {
    background-color: var(--theme-input-bg) !important;
}

.progress-bar {
    background-color: var(--theme-primary) !important;
}

/* ---------- 加载动画 ---------- */
.loading-spinner {
    border-color: rgba(var(--theme-primary-rgb), 0.2) !important;
    border-top-color: var(--theme-primary) !important;
}

.spinner-border {
    color: var(--theme-primary) !important;
}

/* ---------- 列表组 ---------- */
.list-group-item {
    background-color: transparent !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.list-group-item:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.06) !important;
}

.list-group-item.active {
    background-color: rgba(var(--theme-primary-rgb), 0.15) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-primary) !important;
}

/* ---------- 展开模型标签 ---------- */
.expanded-models {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border) !important;
}

.expandable-badge:hover {
    background-color: var(--theme-primary) !important;
    color: #000 !important;
}

/* ---------- 消息提示容器 ---------- */
.alert-container .alert {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

/* ---------- 文字颜色补丁 ---------- */
.text-muted {
    color: var(--theme-text-dim) !important;
}

.text-primary {
    color: var(--theme-primary) !important;
}

.text-success {
    color: var(--theme-accent) !important;
}

.text-danger {
    color: #f87171 !important;
}

.text-warning {
    color: #f59e0b !important;
}

/* ---------- 表格响应式滚动条 ---------- */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--theme-surface);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--theme-primary-dim);
    border-radius: 3px;
}

/* ---------- 滚动条全局 ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--theme-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--theme-primary-rgb), 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--theme-primary-rgb), 0.4);
}

/* ---------- 选择文本 ---------- */
::selection {
    background: var(--theme-primary-dim);
    color: #fff;
}

/* ---------- 主题选择器卡片 ---------- */
.theme-option {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--theme-border);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 6px;
}

.theme-option:hover,
.theme-option.active {
    border-color: var(--theme-primary);
    box-shadow: 0 0 8px var(--theme-primary-dim);
    transform: scale(1.1);
}

.theme-option[data-value="dark-tech"] { background: linear-gradient(135deg, #0a0e17, #00d4ff); }
.theme-option[data-value="light-clean"] { background: linear-gradient(135deg, #f8fafc, #2563eb); }
.theme-option[data-value="ocean"] { background: linear-gradient(135deg, #0c1929, #38bdf8); }
.theme-option[data-value="aurora"] { background: linear-gradient(135deg, #0f0b1e, #a78bfa); }
.theme-option[data-value="obsidian"] { background: linear-gradient(135deg, #0f1115, #b8c0cc); }

/* ====== 设备型号分配页面 — 内部列表自适应高度 ====== */
#device-assignment-content > .row {
    height: 100%;
}

#device-assignment-content > .row > .col-md-6 {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.assigned-users-list,
.available-users-list {
    flex: 1;
    min-height: 0;
}
