/* ===== 九医云后台通用样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --orange: #EA580C;
  --yellow: #EAB308;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --white: #FFFFFF;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Admin Layout ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 240px;
  background: var(--gray-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}
.sidebar-header svg { width: 32px; height: 32px; }
.sidebar-merchant {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--gray-400);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--gray-300);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-nav a.active { background: var(--primary); color: var(--white); }
.sidebar-nav a svg { width: 20px; height: 20px; }
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.sidebar-footer a:hover { color: var(--white); }

/* Main Content */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-topbar {
  background: var(--white);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-200);
}
.admin-topbar h1 { font-size: 20px; font-weight: 600; }
.admin-topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--gray-600);
}
.admin-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-title { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.success .stat-value { color: var(--green); }
.stat-card.warning .stat-value { color: var(--orange); }
.stat-card.danger .stat-value { color: var(--red); }

/* ===== Table ===== */
.table-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-200);
}
.table-header h2 { font-size: 17px; font-weight: 600; }
.table-tools {
  display: flex;
  gap: 12px;
  align-items: center;
}
.table-tools input, .table-tools select {
  padding: 8px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.table-tools input:focus, .table-tools select:focus { border-color: var(--primary); }
.table-tools input { width: 240px; }

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--green-light); color: var(--green); }
.badge-danger { background: var(--red-light); color: var(--red); }
.badge-warning { background: #FEF3C7; color: #D97706; }

/* Action Buttons */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803D; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn-danger-text { color: var(--red); background: none; border: none; padding: 4px 8px; font-size: 13px; cursor: pointer; }
.btn-danger-text:hover { text-decoration: underline; }
.btn-edit-text { color: var(--primary); background: none; border: none; padding: 4px 8px; font-size: 13px; cursor: pointer; }
.btn-edit-text:hover { text-decoration: underline; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--gray-400);
  padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.show { display: flex; }
.confirm-dialog {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  text-align: center;
}
.confirm-dialog h4 { margin-bottom: 8px; font-size: 16px; }
.confirm-dialog p { color: var(--gray-500); margin-bottom: 20px; font-size: 14px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E40AF 0%, #2563EB 50%, #3B82F6 100%);
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.login-box .logo span { font-size: 24px; font-weight: 700; color: var(--primary); }
.login-box .subtitle {
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 28px;
}
.login-box .error-msg {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-box .error-msg.show { display: block; }
.login-box .form-group { margin-bottom: 20px; }
.login-box .btn-primary { width: 100%; padding: 12px; font-size: 15px; justify-content: center; }

/* Empty state for table */
.empty-table {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--green);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
}
.toast.error { background: var(--red); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .admin-sidebar { width: 60px; }
  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .sidebar-header span { display: none; }
  .sidebar-merchant { display: none; }
  .sidebar-nav a span { display: none; }
  .sidebar-nav a { justify-content: center; }
  .sidebar-footer a span { display: none; }
  .table-tools { flex-wrap: wrap; }
  .table-tools input { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
