/**
 * AICamera 管理台统一样式表
 * 主题通过 html[data-admin-theme] 切换；默认暗黑。
 * 规范见 .cursor/rules/04-admin-web.mdc §4.10
 */

/* --- 暗黑（默认）--- */
:root,
[data-admin-theme="dark"] {
  --admin-bg: rgb(2 6 23);
  --admin-surface: rgb(30 41 59);
  --admin-surface-2: rgb(15 23 42);
  --admin-border: rgb(51 65 85);
  --admin-text: rgb(226 232 240);
  --admin-text-muted: rgb(148 163 184);
  --admin-text-dim: rgb(100 116 139);
  --admin-link: rgb(96 165 250);
  --admin-link-hover: rgb(147 197 253);
  --admin-danger: rgb(248 113 113);
  --admin-success: rgb(74 222 128);
  --admin-warning: rgb(251 191 36);
  --admin-overlay: rgba(15, 23, 42, 0.5);
  --admin-header-name: rgb(203 213 225);
  --admin-table-head-bg: rgb(15 23 42 / 0.85);
  --admin-table-row-hover: rgb(51 65 85 / 0.2);
  --admin-table-row-border: rgb(51 65 85 / 0.55);
  --admin-btn-primary-bg: rgb(51 65 85);
  --admin-btn-primary-hover: rgb(71 85 105);
  --admin-sidebar-link: rgb(203 213 225);
  --admin-sidebar-link-hover-bg: rgb(30 41 59 / 0.8);
  --admin-sidebar-section: rgb(100 116 139);
}

/* --- 浅色 --- */
[data-admin-theme="light"] {
  --admin-bg: rgb(241 245 249);
  --admin-surface: rgb(255 255 255);
  --admin-surface-2: rgb(248 250 252);
  --admin-border: rgb(226 232 240);
  --admin-text: rgb(15 23 42);
  --admin-text-muted: rgb(100 116 139);
  --admin-text-dim: rgb(148 163 184);
  --admin-link: rgb(37 99 235);
  --admin-link-hover: rgb(29 78 216);
  --admin-danger: rgb(220 38 38);
  --admin-success: rgb(22 163 74);
  --admin-warning: rgb(217 119 6);
  --admin-overlay: rgba(15, 23, 42, 0.25);
  --admin-header-name: rgb(51 65 85);
  --admin-table-head-bg: rgb(248 250 252);
  --admin-table-row-hover: rgb(241 245 249);
  --admin-table-row-border: rgb(226 232 240);
  --admin-btn-primary-bg: rgb(51 65 85);
  --admin-btn-primary-hover: rgb(71 85 105);
  --admin-sidebar-link: rgb(51 65 85);
  --admin-sidebar-link-hover-bg: rgb(226 232 240);
  --admin-sidebar-section: rgb(100 116 139);
}

/* --- 深蓝 --- */
[data-admin-theme="ocean"] {
  --admin-bg: rgb(8 15 30);
  --admin-surface: rgb(20 35 60);
  --admin-surface-2: rgb(12 24 45);
  --admin-border: rgb(40 60 95);
  --admin-text: rgb(224 231 245);
  --admin-text-muted: rgb(140 160 195);
  --admin-text-dim: rgb(90 115 155);
  --admin-link: rgb(56 189 248);
  --admin-link-hover: rgb(125 211 252);
  --admin-danger: rgb(251 113 133);
  --admin-success: rgb(52 211 153);
  --admin-warning: rgb(251 191 36);
  --admin-overlay: rgba(8, 15, 30, 0.55);
  --admin-header-name: rgb(186 210 240);
  --admin-table-head-bg: rgb(12 24 45 / 0.9);
  --admin-table-row-hover: rgb(40 60 95 / 0.35);
  --admin-table-row-border: rgb(40 60 95 / 0.55);
  --admin-btn-primary-bg: rgb(30 58 95);
  --admin-btn-primary-hover: rgb(40 75 120);
  --admin-sidebar-link: rgb(186 210 240);
  --admin-sidebar-link-hover-bg: rgb(20 35 60 / 0.85);
  --admin-sidebar-section: rgb(90 115 155);
}

/* --- 粉萌（柔和亲和）--- */
[data-admin-theme="pink"] {
  --admin-bg: rgb(255 241 246);
  --admin-surface: rgb(255 255 255);
  --admin-surface-2: rgb(253 242 248);
  --admin-border: rgb(251 207 232);
  --admin-text: rgb(80 30 55);
  --admin-text-muted: rgb(157 23 77);
  --admin-text-dim: rgb(190 120 145);
  --admin-link: rgb(219 39 119);
  --admin-link-hover: rgb(190 24 93);
  --admin-danger: rgb(225 29 72);
  --admin-success: rgb(16 185 129);
  --admin-warning: rgb(217 119 6);
  --admin-overlay: rgba(131, 24, 67, 0.18);
  --admin-header-name: rgb(131 24 67);
  --admin-table-head-bg: rgb(252 231 243);
  --admin-table-row-hover: rgb(253 242 248);
  --admin-table-row-border: rgb(251 207 232);
  --admin-btn-primary-bg: rgb(244 114 182);
  --admin-btn-primary-hover: rgb(236 72 153);
  --admin-sidebar-link: rgb(131 24 67);
  --admin-sidebar-link-hover-bg: rgb(252 231 243);
  --admin-sidebar-section: rgb(190 120 145);
}

/* --- 暗色主题下 Tailwind 浅色 utility 对比度修正 --- */
.text-slate-600 { color: var(--admin-text-muted); }
.text-blue-700,
.text-blue-600 { color: var(--admin-link); }

/* --- 语义文字 / 链接 --- */
.admin-text { color: var(--admin-text); }
.admin-text-muted { color: var(--admin-text-muted); }
.admin-text-dim { color: var(--admin-text-dim); }
.admin-link {
  color: var(--admin-link);
  text-decoration: none;
}
.admin-link:hover {
  color: var(--admin-link-hover);
  text-decoration: underline;
}
.admin-link-danger {
  color: var(--admin-danger);
  text-decoration: none;
}
.admin-link-danger:hover { text-decoration: underline; }

/* --- 布局壳层 --- */
.admin-layout-body {
  background-color: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
}
.admin-sidebar {
  background-color: var(--admin-bg);
  border-right: 1px solid var(--admin-border);
  color: var(--admin-text);
}
.admin-header {
  background-color: var(--admin-surface-2);
  border-bottom: 1px solid var(--admin-border);
}
.admin-header-sep { color: var(--admin-text-dim); }
.admin-header-user { color: var(--admin-text-muted); }
.admin-header-name { color: var(--admin-header-name); }
.admin-header-brand {
  color: var(--admin-text);
  font-weight: 600;
}
.admin-header-brand:hover { color: var(--admin-header-name); }
.admin-header-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--admin-border);
  background: transparent;
  color: var(--admin-text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.admin-header-settings:hover,
.admin-header-settings[aria-expanded="true"] {
  background: rgb(51 65 85 / 0.35);
  color: var(--admin-text);
  border-color: var(--admin-border);
}
.admin-settings-wrap { position: relative; }
.admin-settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  z-index: 70;
  min-width: 13rem;
}
.admin-settings-panel-inner {
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}
.admin-settings-panel select {
  width: 100%;
  border-radius: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  background-color: var(--admin-surface-2);
  border: 1px solid var(--admin-border);
  color: var(--admin-text);
}
.admin-settings-divider {
  border: none;
  border-top: 1px solid var(--admin-border);
  margin: 0.75rem 0;
}
.admin-settings-logout {
  display: block;
  text-align: center;
  font-size: 0.875rem;
  padding: 0.5rem;
  color: var(--admin-danger);
  text-decoration: none;
  border-radius: 0.5rem;
}
.admin-settings-logout:hover {
  background: rgb(127 29 29 / 0.15);
  text-decoration: none;
}

/* --- 卡片 / 面板 --- */
.admin-card {
  background-color: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  color: var(--admin-text);
}
.admin-card h2,
.admin-card h3,
.admin-section-title {
  color: var(--admin-text);
  font-weight: 500;
}
.admin-section-title { margin-bottom: 0.75rem; font-size: 0.875rem; }
.admin-section-title-lg { margin-bottom: 0.75rem; font-size: 1rem; }

/* --- 按钮 --- */
.admin-btn-primary {
  background-color: var(--admin-btn-primary-bg);
  color: white;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
}
.admin-btn-primary:hover { background-color: var(--admin-btn-primary-hover); }
.admin-btn-secondary {
  background-color: transparent;
  color: var(--admin-text);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.admin-btn-secondary:hover { background-color: rgb(51 65 85 / 0.5); }
.admin-btn-cancel {
  background-color: transparent;
  color: var(--admin-text-muted);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.admin-btn-cancel:hover {
  background-color: rgb(51 65 85 / 0.5);
  color: var(--admin-text);
}
main button[onclick="AdminModal.close()"],
#admin-modal button[onclick="AdminModal.close()"] {
  background-color: transparent;
  color: var(--admin-text-muted);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
}
main button[onclick="AdminModal.close()"]:hover,
#admin-modal button[onclick="AdminModal.close()"]:hover {
  background-color: rgb(51 65 85 / 0.5);
  color: var(--admin-text);
}

/* --- 表单控件（全站统一：main / modal / admin-card）--- */
.admin-input,
.admin-select,
.admin-textarea,
main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
main select,
main textarea,
#admin-modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
#admin-modal select,
#admin-modal textarea,
.admin-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
.admin-card select,
.admin-card textarea,
.admin-settings-panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
.admin-settings-panel select {
  background-color: var(--admin-surface-2);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  color: var(--admin-text);
  font-size: 0.875rem;
}
.admin-input,
.admin-select,
.admin-textarea,
main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
main select,
main textarea,
#admin-modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
#admin-modal select,
#admin-modal textarea,
.admin-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
.admin-card select,
.admin-card textarea {
  padding: 0.5rem 0.75rem;
}
.admin-input-sm,
.admin-card input.admin-input-sm,
.admin-card select.admin-input-sm {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}
.admin-input-readonly,
.admin-input:read-only,
.admin-textarea:read-only,
main input:read-only,
#admin-modal input:read-only,
.admin-card input:read-only {
  background-color: rgb(51 65 85 / 0.45);
  color: var(--admin-text-muted);
}
[data-admin-theme="light"] .admin-input-readonly,
[data-admin-theme="light"] main input:read-only,
[data-admin-theme="light"] #admin-modal input:read-only,
[data-admin-theme="light"] .admin-card input:read-only,
[data-admin-theme="pink"] .admin-input-readonly,
[data-admin-theme="pink"] main input:read-only,
[data-admin-theme="pink"] #admin-modal input:read-only,
[data-admin-theme="pink"] .admin-card input:read-only {
  background-color: rgb(226 232 240 / 0.65);
}
.admin-input-highlight {
  background-color: rgb(120 53 15 / 0.25);
  color: rgb(251 191 36);
}
[data-admin-theme="light"] .admin-input-highlight,
[data-admin-theme="pink"] .admin-input-highlight {
  background-color: rgb(254 243 199 / 0.55);
  color: rgb(146 64 14);
}
main select option,
#admin-modal select option,
.admin-card select option {
  background-color: var(--admin-surface-2);
  color: var(--admin-text);
}
main input::placeholder,
#admin-modal input::placeholder,
.admin-card input::placeholder { color: var(--admin-text-dim); }
main input:focus,
main select:focus,
main textarea:focus,
#admin-modal input:focus,
#admin-modal select:focus,
#admin-modal textarea:focus,
.admin-card input:focus,
.admin-card select:focus,
.admin-card textarea:focus,
.admin-input:focus,
.admin-select:focus,
.admin-textarea:focus {
  outline: none;
  border-color: var(--admin-link);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--admin-link) 25%, transparent);
}
/* 浏览器 autofill 白底覆盖 */
main input:-webkit-autofill,
main input:-webkit-autofill:hover,
main input:-webkit-autofill:focus,
#admin-modal input:-webkit-autofill,
#admin-modal input:-webkit-autofill:hover,
#admin-modal input:-webkit-autofill:focus,
.admin-card input:-webkit-autofill,
.admin-card input:-webkit-autofill:hover,
.admin-card input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--admin-surface-2) inset !important;
  box-shadow: 0 0 0 1000px var(--admin-surface-2) inset !important;
  -webkit-text-fill-color: var(--admin-text) !important;
  caret-color: var(--admin-text);
  border: 1px solid var(--admin-border) !important;
  transition: background-color 99999s ease-out 0s;
}
main label,
#admin-modal label,
.admin-card label { color: var(--admin-text-muted); }

/* --- 列表表格 --- */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.admin-table-wrap { width: 100%; }
.admin-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  color: var(--admin-text);
}
.admin-table thead th {
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--admin-text-muted);
  text-align: left;
  white-space: nowrap;
  background: var(--admin-table-head-bg);
  border-bottom: 1px solid var(--admin-border);
}
.admin-table tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
  border-top: 1px solid var(--admin-table-row-border);
  color: var(--admin-text);
}
.admin-table tbody tr:hover td { background: var(--admin-table-row-hover); }
.admin-table .col-actions { text-align: right; white-space: nowrap; }
.admin-table .col-mono {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  white-space: nowrap;
}
.admin-table .col-clip {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-th-sort {
  color: var(--admin-text-muted);
  text-decoration: none;
}
.admin-th-sort:hover {
  color: var(--admin-text);
  text-decoration: none;
}

/* 独立表格（详情页等非 admin-table 宏） */
.admin-standalone-table { width: 100%; color: var(--admin-text); }
.admin-standalone-table thead th {
  color: var(--admin-text-muted);
  border-bottom: 1px solid var(--admin-border);
}
.admin-standalone-table tbody td {
  border-top: 1px solid var(--admin-table-row-border);
  color: var(--admin-text);
}
.admin-standalone-table tbody tr:hover td { background: var(--admin-table-row-hover); }

/* admin-card 内嵌 table（详情页） */
.admin-card table { color: var(--admin-text); }
.admin-card table thead th { color: var(--admin-text-muted); }
.admin-card table tbody td { color: var(--admin-text); }

/* --- Tab / 徽章 --- */
.admin-tab-active {
  background: rgb(51 65 85);
  color: white;
  border-color: rgb(71 85 105);
}
.admin-tab-inactive {
  background: var(--admin-surface-2);
  color: rgb(203 213 225);
  border-color: var(--admin-border);
}
.admin-badge-on {
  background: rgb(6 78 59 / 0.45);
  color: rgb(110 231 183);
}
.admin-badge-off {
  background: rgb(51 65 85);
  color: var(--admin-text-muted);
}
.admin-badge-ok {
  background: rgb(6 78 59 / 0.45);
  color: rgb(134 239 172);
}
.admin-badge-err {
  background: rgb(127 29 29 / 0.45);
  color: rgb(252 165 165);
}

/* --- 顶栏标题（page_top_bar）--- */
.admin-page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--admin-text);
  line-height: 1.25;
}
.admin-page-subtitle {
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  line-height: 1.375;
}

/* --- 工具栏 --- */
.admin-list-toolbar { color: var(--admin-text); }

/* --- 空状态 --- */
.admin-empty {
  padding: 2.5rem 0;
  text-align: center;
  color: var(--admin-text-muted);
}

/* --- 侧栏导航（Tailwind class 主题适配）--- */
[data-admin-theme="light"] .admin-sidebar .text-slate-300,
[data-admin-theme="light"] .admin-sidebar .text-slate-500 {
  color: var(--admin-sidebar-section);
}
[data-admin-theme="light"] .admin-sidebar a.text-slate-300,
[data-admin-theme="light"] .admin-sidebar summary.text-slate-300 {
  color: var(--admin-sidebar-link);
}
[data-admin-theme="light"] .admin-sidebar a.bg-slate-800,
[data-admin-theme="light"] .admin-sidebar a[class*="bg-slate-800"] {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
  color: var(--admin-text) !important;
}
[data-admin-theme="light"] .admin-sidebar a:hover,
[data-admin-theme="light"] .admin-sidebar summary:hover {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
  color: var(--admin-text) !important;
}
[data-admin-theme="light"] .admin-sidebar .border-slate-700\/80 {
  border-color: var(--admin-border) !important;
}

[data-admin-theme="ocean"] .admin-sidebar a.bg-slate-800,
[data-admin-theme="ocean"] .admin-sidebar a[class*="bg-slate-800"] {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
}
[data-admin-theme="ocean"] .admin-sidebar a:hover,
[data-admin-theme="ocean"] .admin-sidebar summary:hover {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
}

[data-admin-theme="pink"] .admin-sidebar .text-slate-300,
[data-admin-theme="pink"] .admin-sidebar .text-slate-500 {
  color: var(--admin-sidebar-section);
}
[data-admin-theme="pink"] .admin-sidebar a.text-slate-300,
[data-admin-theme="pink"] .admin-sidebar summary.text-slate-300 {
  color: var(--admin-sidebar-link);
}
[data-admin-theme="pink"] .admin-sidebar a.bg-slate-800,
[data-admin-theme="pink"] .admin-sidebar a[class*="bg-slate-800"] {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
  color: var(--admin-text) !important;
}
[data-admin-theme="pink"] .admin-sidebar a:hover,
[data-admin-theme="pink"] .admin-sidebar summary:hover {
  background-color: var(--admin-sidebar-link-hover-bg) !important;
  color: var(--admin-text) !important;
}
[data-admin-theme="pink"] .admin-sidebar .border-slate-700\/80 {
  border-color: var(--admin-border) !important;
}
[data-admin-theme="pink"] .admin-header-settings:hover,
[data-admin-theme="pink"] .admin-header-settings[aria-expanded="true"] {
  background: rgb(251 207 232 / 0.55);
  color: var(--admin-text);
}
