/* 斯达文具后台管理样式 */
:root {
  --primary: #1a3a5c;
  --primary-dark: #122a45;
  --accent: #f4a261;
  --accent-hover: #e89554;
  --success: #2a9d8f;
  --danger: #e76f51;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --border: #dfe6e9;
  --shadow: 0 2px 12px rgba(26, 58, 92, 0.06);
  --shadow-hover: 0 8px 28px rgba(26, 58, 92, 0.12);
  --radius: 12px;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef4f7 0%, #f8f6f1 100%);
  padding: 24px;
}

.login-card {
  background: white;
  padding: 48px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-card .logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
}

.login-card p {
  color: var(--text-light);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.15);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 6px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 12px;
  min-height: 1.4em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: #f8fbfd;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #d45a3d;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #248a7e;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.15rem;
}

.sidebar-header .logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  opacity: 0.85;
  transition: all 0.2s;
  cursor: pointer;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.85rem;
  opacity: 0.7;
}

.sidebar-footer button {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  font-size: 0.85rem;
}

.sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h1 {
  font-size: 1.6rem;
  color: var(--primary);
}

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-card .label {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

/* Tables */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h2 {
  font-size: 1.15rem;
  color: var(--primary);
}

.card-body {
  padding: 0;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  text-align: left;
  padding: 14px 20px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}

tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafbfc;
}

.product-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  background: #f0f0f0;
}

.product-name {
  font-weight: 600;
  color: var(--primary);
}

.product-desc {
  color: var(--text-light);
  font-size: 0.85rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price {
  font-weight: 700;
  color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #eef4f7;
  color: var(--primary);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.empty-row td {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.25s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #fafbfc;
}

/* Image Upload */
.image-upload {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
  position: relative;
}

.image-upload:hover {
  border-color: var(--accent);
  background: #fff8f2;
}

.image-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.image-upload .placeholder {
  color: var(--text-light);
  pointer-events: none;
}

.image-upload .preview {
  max-height: 180px;
  border-radius: 8px;
  margin: 0 auto;
  pointer-events: none;
}

/* Categories management */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.category-item .icon-input {
  width: 60px;
  text-align: center;
}

.category-item .name-input {
  flex: 1;
}

.category-item .desc-input {
  flex: 2;
}

.category-item input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  font-size: 0.9rem;
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--success);
  color: white;
  padding: 14px 22px;
  border-radius: 8px;
  box-shadow: var(--shadow-hover);
  font-weight: 500;
  z-index: 300;
  transform: translateX(150%);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: var(--danger);
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 150;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: block;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 160;
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
  }
}

@media (min-width: 1025px) {
  .mobile-toggle {
    display: none;
  }
}

@media (max-width: 768px) {
  .login-card {
    padding: 32px 24px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .category-item {
    flex-wrap: wrap;
  }

  .category-item .desc-input {
    flex: 1 1 100%;
  }
}

.hidden {
  display: none !important;
}
