/* ==========================================
   PPMART Admin — Dark Mode Design System
   Inspired by: Douyin × Feishu × Notion
   ========================================== */

/* ── Design Tokens ── */
:root {
  /* Backgrounds */
  --bg-body: #0a0a0f;
  --bg-surface: #12121a;
  --bg-elevated: #1a1a26;
  --bg-hover: #22222f;
  --bg-active: #2a2a3a;

  /* Borders */
  --border: #2a2a3a;
  --border-light: #1e1e2e;
  --border-focus: #5e5ce6;

  /* Text */
  --text: #e8e8ed;
  --text-secondary: #9d9daf;
  --text-tertiary: #6b6b80;
  --text-inverse: #0a0a0f;

  /* Primary — 抖音风格青紫渐变 */
  --primary: #5e5ce6;
  --primary-hover: #7b79f0;
  --primary-light: rgba(94, 92, 230, 0.12);
  --primary-glow: rgba(94, 92, 230, 0.3);

  /* Semantic */
  --success: #34d399;
  --success-hover: #6ee7b7;
  --success-light: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-hover: #fcd34d;
  --warning-light: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-light: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-light: rgba(96, 165, 250, 0.12);
  --pink: #ec4899;
  --cyan: #22d3ee;

  /* Layout */
  --sidebar-width: 228px;
  --header-height: 56px;

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--primary-hover); }

::selection {
  background: var(--primary);
  color: white;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ==========================================
   HEADER — 飞书式简洁顶栏
   ========================================== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: var(--sidebar-width);
  padding-left: 18px;
  flex-shrink: 0;
}

.header-brand h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.header-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* ── Sidebar Toggle ── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  line-height: 1;
}
.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ── Live Badge ── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid rgba(248, 113, 113, 0.15);
}
.live-badge:hover {
  background: rgba(248, 113, 113, 0.18);
  color: var(--danger-hover);
}
.live-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

/* ==========================================
   SIDEBAR — Notion式深色侧栏
   ========================================== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 99;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 20px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .nav-item {
  font-size: 13px;
  color: var(--text-tertiary);
}
.sidebar-footer .nav-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ── Sidebar States ── */
body.sidebar-hidden .sidebar {
  transform: translateX(-100%);
}
body.sidebar-hidden .container {
  margin-left: 0;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.container {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  padding: 28px 32px 48px;
  max-width: 1480px;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Page Title ── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.page-header p {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ==========================================
   CARDS — 飞书式卡片
   ========================================== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================
   BUTTONS — 抖音风格
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 15px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: white;
}
.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 15px rgba(52, 211, 153, 0.3);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, var(--danger));
  color: white;
}
.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 15px rgba(248, 113, 113, 0.3);
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, var(--warning));
  color: #0a0a0f;
}
.btn-warning:hover:not(:disabled) {
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--text-tertiary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-secondary);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-tertiary);
}

.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ==========================================
   FORM ELEMENTS
   ========================================== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-body);
  transition: all 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input::placeholder { color: var(--text-tertiary); }

select.form-input option {
  background: var(--bg-elevated);
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

textarea.form-input {
  resize: vertical;
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-bar input,
.search-bar select,
.search-bar .form-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-body);
  color: var(--text);
  outline: none;
  transition: all 0.15s;
}
.search-bar input:focus,
.search-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.search-bar input[type="text"] { flex: 1; min-width: 200px; }

/* ==========================================
   TABLES
   ========================================== */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}

tr:hover td {
  background: rgba(255,255,255,0.02);
}

code {
  font-family: var(--font-mono);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
}

/* ==========================================
   BADGES
   ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

/* ── Condition Badges ── */
.condition-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.condition-sealed { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.condition-opened { background: var(--success-light); color: var(--success); }
.condition-boxless { background: var(--warning-light); color: var(--warning); }
.condition-flawed { background: var(--danger-light); color: var(--danger); }

/* ==========================================
   TEXT UTILITIES
   ========================================== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-tertiary); }

/* ==========================================
   ALERTS
   ========================================== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.2); }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.2); }

/* ==========================================
   MODALS — 毛玻璃风格
   ========================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: modal-fadein 0.15s ease;
}
.modal.show { display: flex; }

.modal-content {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: modal-slidein 0.2s ease;
}
.modal-content.modal-wide {
  max-width: 800px;
}
.modal-content.modal-full {
  max-width: 90vw;
}
.modal-content::-webkit-scrollbar { width: 4px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-tertiary);
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}
.modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ==========================================
   PAGINATION
   ========================================== */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
}
.pagination button {
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.pagination button:hover { background: var(--bg-hover); border-color: var(--bg-active); }
.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ==========================================
   STOCK STATES
   ========================================== */
.stock-low { color: var(--danger); font-weight: 700; }
.stock-out { color: var(--text-tertiary); text-decoration: line-through; }
   KEYFRAMES
   ========================================== */
@keyframes modal-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-slidein {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar-toggle { display: block; }
  .container {
    margin-left: 0;
    padding: 20px 14px;
  }
  body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }
  .header-brand {
    width: auto;
    padding-left: 12px;
  }
  .header-brand h1 {
    font-size: 14px;
  }
  .live-badge span { display: none; }
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  body.sidebar-hidden .sidebar-toggle,
  body:not(.sidebar-hidden):not(.sidebar-open) .sidebar-toggle {
    display: block;
  }
}
