/* ================================================================
 * 邮件监测系统 - 全局主题样式（与设计稿视觉一致）
 * 使用 CSS 变量 + Tailwind 4 theme inline
 * ================================================================ */

:root {
  --mm-background: radial-gradient(circle at 10% 20%, #eef2ff 0%, #f8fafc 40%, #e0f2fe 100%);
  --mm-foreground: #0f172a;
  --mm-card: rgba(255, 255, 255, 0.72);
  --mm-card-foreground: #0f172a;
  --mm-popover: rgba(255, 255, 255, 0.85);
  --mm-popover-foreground: #0f172a;
  --mm-primary: #0d9488;
  --mm-primary-foreground: #ffffff;
  --mm-muted: rgba(241, 245, 249, 0.6);
  --mm-muted-foreground: #64748b;
  --mm-border: rgba(255, 255, 255, 0.5);
  --mm-input: rgba(226, 232, 240, 0.6);
  --mm-ring: #0d9488;
  --mm-radius-sm: 4px;
  --mm-radius-md: 12px;
  --mm-radius-lg: 20px;
  --mm-state-success: #10b981;
  --mm-state-success-bg: rgba(16, 185, 129, 0.12);
  --mm-state-warning: #f59e0b;
  --mm-state-warning-bg: rgba(245, 158, 11, 0.12);
  --mm-state-error: #ef4444;
  --mm-state-error-bg: rgba(239, 68, 68, 0.12);
  --mm-state-info: #3b82f6;
  --mm-state-info-bg: rgba(59, 130, 246, 0.12);
  --mm-state-critical: #9333ea;
  --mm-state-critical-bg: rgba(147, 51, 234, 0.12);
  --mm-font-sans: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mm-font-mono: "SF Mono", "SFMono-Regular", ui-monospace, "Cascadia Mono", monospace;

  /* Glass / 3D tokens */
  --mm-glass-highlight: rgba(255, 255, 255, 0.45);
  --mm-ambient-rgb: 15, 23, 42;
  --mm-glass-shadow: rgba(15, 23, 42, 0.08);
  --mm-glass-shadow-lg: rgba(15, 23, 42, 0.18);
  --mm-3d-perspective: 1200px;
}

html.dark {
  --mm-background: radial-gradient(circle at 10% 20%, #1e293b 0%, #0b0f19 40%, #111827 100%);
  --mm-foreground: #f1f5f9;
  --mm-card: rgba(17, 24, 39, 0.68);
  --mm-card-foreground: #f1f5f9;
  --mm-popover: rgba(17, 24, 39, 0.85);
  --mm-popover-foreground: #f1f5f9;
  --mm-muted: rgba(30, 41, 59, 0.6);
  --mm-muted-foreground: #94a3b8;
  --mm-border: rgba(255, 255, 255, 0.12);
  --mm-input: rgba(30, 41, 59, 0.6);
  --mm-glass-highlight: rgba(255, 255, 255, 0.08);
  --mm-ambient-rgb: 0, 0, 0;
  --mm-glass-shadow: rgba(0, 0, 0, 0.35);
  --mm-glass-shadow-lg: rgba(0, 0, 0, 0.55);
}

html, body { height: 100%; }

body {
  background: var(--mm-background);
  color: var(--mm-foreground);
  font-family: var(--mm-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Glass surfaces ---- */
.bg-card, .bg-popover {
  background: var(--mm-card);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--mm-border);
  box-shadow:
    0 8px 32px var(--mm-glass-shadow),
    inset 0 1px 0 var(--mm-glass-highlight);
}
aside.bg-card { box-shadow: 8px 0 32px var(--mm-glass-shadow); }
header.bg-card { box-shadow: 0 4px 24px var(--mm-glass-shadow); }

/* ---- 3D hover lift on rounded cards ---- */
section.bg-card,
.bg-card.rounded-lg:not(aside):not(header) {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
  transform-style: preserve-3d;
}
section.bg-card:hover,
.bg-card.rounded-lg:not(aside):not(header):hover {
  transform: perspective(var(--mm-3d-perspective)) rotateX(2deg) rotateY(-2deg) translateZ(12px);
  box-shadow:
    0 20px 48px var(--mm-glass-shadow-lg),
    inset 0 1px 0 var(--mm-glass-highlight);
}

/* ---- Primary button 3D lift ---- */
.bg-primary {
  background-color: var(--mm-primary) !important;
  color: var(--mm-primary-foreground) !important;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.bg-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.45);
}
.bg-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.text-primary { color: var(--mm-primary) !important; }
.border-primary { border-color: var(--mm-primary) !important; }
.ring-primary { --tw-ring-color: var(--mm-primary); }

/* ---- Muted / Input surfaces ---- */
.bg-muted {
  background-color: var(--mm-input);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.bg-input { background-color: var(--mm-input); }
.text-muted-foreground { color: var(--mm-muted-foreground) !important; }
.border-border { border-color: var(--mm-border) !important; }

/* ---- Status badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  line-height: 1.25rem;
  font-weight: 500;
}
.badge-success { background: var(--mm-state-success-bg); color: var(--mm-state-success); }
.badge-warning { background: var(--mm-state-warning-bg); color: var(--mm-state-warning); }
.badge-error   { background: var(--mm-state-error-bg);   color: var(--mm-state-error); }
.badge-info    { background: var(--mm-state-info-bg);    color: var(--mm-state-info); }
.badge-critical{ background: var(--mm-state-critical-bg);color: var(--mm-state-critical); }

/* ---- Forms ---- */
.mm-input, .mm-select, .mm-textarea {
  display: flex;
  width: 100%;
  background-color: var(--mm-input);
  color: var(--mm-foreground);
  border: 1px solid var(--mm-border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.mm-input:focus, .mm-select:focus, .mm-textarea:focus {
  outline: none;
  border-color: var(--mm-ring);
  box-shadow: 0 0 0 1px var(--mm-ring), 0 0 0 3px rgba(13,148,136,0.15);
}
.mm-input::placeholder, .mm-textarea::placeholder { color: var(--mm-muted-foreground); }

.mm-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--mm-foreground);
  margin-bottom: 0.375rem;
}

/* ---- Checkbox & Switch ---- */
.mm-switch {
  position: relative;
  width: 40px;
  height: 20px;
  cursor: pointer;
}
.mm-switch input { opacity: 0; width: 0; height: 0; }
.mm-switch .slider {
  position: absolute; inset: 0;
  background-color: var(--mm-input);
  border-radius: 9999px;
  transition: background-color 0.2s ease;
}
.mm-switch .slider::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background-color: var(--mm-card);
  border: 1px solid var(--mm-border);
  border-radius: 9999px;
  transition: transform 0.2s ease;
}
.mm-switch input:checked + .slider { background-color: var(--mm-primary); }
.mm-switch input:checked + .slider::before { transform: translateX(20px); }

.mm-checkbox {
  width: 1rem; height: 1rem;
  border-radius: 0.25rem;
  border: 1px solid var(--mm-border);
  background-color: var(--mm-input);
  color: var(--mm-primary);
  accent-color: var(--mm-primary);
}

/* ---- App layout shell ---- */
.app-shell { min-height: 100vh; display: flex; background: var(--mm-background); }
.app-aside {
  width: 15rem;
  height: 100vh;
  position: fixed; left: 0; top: 0;
  z-index: 30;
}
.app-main { flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 768px) { .app-main { margin-left: 15rem; } }
@media (max-width: 767px) {
  .app-aside {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app-aside.open { transform: translateX(0); }
  .app-aside-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 25;
  }
  .app-aside-backdrop.open { display: block; }
}

/* Nav link */
.nav-link {
  display: flex; align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--mm-muted-foreground);
  transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background-color: var(--mm-muted); color: var(--mm-foreground); }
.nav-link.active { background-color: var(--mm-primary); color: var(--mm-primary-foreground); }
.nav-link .icon { margin-right: 0.75rem; width: 20px; height: 20px; flex-shrink: 0; }

/* ---- Table ---- */
.mm-table { width: 100%; text-align: left; font-size: 0.875rem; }
.mm-table thead { background: var(--mm-muted); color: var(--mm-muted-foreground); }
.mm-table th { padding: 0.75rem 1rem 0.75rem; font-weight: 500; white-space: nowrap; }
.mm-table td { padding: 0.75rem 1rem; border-top: 1px solid var(--mm-border); color: var(--mm-foreground); word-break: break-word; }
.mm-table tbody tr { transition: background-color .15s ease; }
.mm-table tbody tr:hover { background: color-mix(in srgb, var(--mm-muted) 50%, transparent); }

/* ---- Button ---- */
.mm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .2s ease, box-shadow .2s ease, background-color .15s ease, opacity .15s ease, border-color .15s ease, color .15s ease;
}
.mm-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.mm-btn-primary { background: var(--mm-primary); color: var(--mm-primary-foreground); box-shadow: 0 6px 18px rgba(13,148,136,0.35); }
.mm-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(13,148,136,0.45); }
.mm-btn-outline { background: transparent; border-color: var(--mm-border); color: var(--mm-foreground); }
.mm-btn-outline:hover:not(:disabled) { background: var(--mm-muted); }
.mm-btn-ghost { background: transparent; color: var(--mm-foreground); }
.mm-btn-ghost:hover:not(:disabled) { background: var(--mm-muted); }
.mm-btn-danger { color: var(--mm-state-error); border-color: var(--mm-border); background: transparent; }
.mm-btn-danger:hover:not(:disabled) { background: var(--mm-state-error-bg); }
.mm-btn-sm { height: 1.875rem; padding: 0 0.75rem; font-size: 0.75rem; }
.mm-btn-lg { height: 2.75rem; padding: 0 1.25rem; font-size: 0.95rem; }

/* ---- Stat cards ---- */
.stat-card {
  padding: 1.25rem 1.5rem;
  border-radius: var(--mm-radius-lg);
  border: 1px solid var(--mm-border);
}
.stat-card .stat-icon {
  width: 2.25rem; height: 2.25rem;
  border-radius: 0.375rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-card .stat-value { font-size: 1.875rem; font-weight: 600; color: var(--mm-foreground); }
.stat-card .stat-label { font-size: 0.875rem; color: var(--mm-muted-foreground); }
.stat-card .stat-sub   { font-size: 0.8125rem; color: var(--mm-muted-foreground); margin-top: 0.25rem; }

/* ---- Toast ---- */
.toast-wrap {
  position: fixed;
  top: 1.25rem; right: 1.25rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100% - 2.5rem);
  pointer-events: none;
}
.toast {
  min-width: 240px;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--mm-popover);
  color: var(--mm-popover-foreground);
  border: 1px solid var(--mm-border);
  box-shadow: 0 12px 32px rgba(15,23,42,0.18);
  font-size: 0.875rem;
  display: flex; align-items: flex-start; gap: 0.5rem;
  animation: toastIn 0.25s ease both;
  pointer-events: auto;
}
.toast.success { border-left: 4px solid var(--mm-state-success); }
.toast.error   { border-left: 4px solid var(--mm-state-error); }
.toast.warning { border-left: 4px solid var(--mm-state-warning); }
.toast.info    { border-left: 4px solid var(--mm-state-info); }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Loading overlay ---- */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.35);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.loading-overlay.show { display: flex; }
.loading-spinner {
  width: 56px; height: 56px;
  border: 4px solid rgba(13,148,136,0.2);
  border-top-color: var(--mm-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Modal ---- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
  z-index: 1500;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: auto;
  background: var(--mm-card);
  border-radius: var(--mm-radius-md);
  border: 1px solid var(--mm-border);
  box-shadow: 0 20px 60px rgba(15,23,42,0.3);
  animation: modalIn 0.2s ease both;
}
@keyframes modalIn { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--mm-border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--mm-border); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ---- Scrollbar ---- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ---- Trend / mini chart bar ---- */
.bar-chart {
  display: flex; align-items: flex-end;
  height: 80px;
  gap: 8px;
  padding: 0 4px;
}
.bar-chart .bar {
  flex: 1;
  background: linear-gradient(180deg, rgba(13,148,136,0.8), rgba(13,148,136,0.25));
  border-radius: 4px 4px 2px 2px;
  min-height: 4px;
  position: relative;
  transition: all 0.3s ease;
}
.bar-chart .bar:hover { background: linear-gradient(180deg, rgba(13,148,136,1), rgba(13,148,136,0.5)); }
.bar-chart .bar .bar-label {
  position: absolute;
  bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 0.625rem; color: var(--mm-muted-foreground);
}
