/* ========================================
   选品助手 - 大窗口设计
   ======================================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1f2937;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-font-smoothing: antialiased;
}

/* 窗口容器 */
.popup-body {
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

.popup-container {
  background: #ffffff;
  min-height: 100vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ========================================
   窗口标题栏
   ======================================== */
.window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.window-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.window-icon {
  font-size: 24px;
}

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

.window-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.window-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
}

/* ========================================
   表单容器
   ======================================== */
.form-container {
  padding: 30px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.form-section {
  margin-bottom: 28px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #374151;
  background: #fafafa;
  transition: all 0.2s ease;
  outline: none;
}

.form-input:focus {
  border-color: #667eea;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========================================
   优先级选择 - 加大版
   ======================================== */
.priority-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.priority-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.priority-btn:hover {
  border-color: #d1d5db;
  background: #f9fafb;
  transform: translateY(-2px);
}

.priority-btn.active {
  border-color: #667eea;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.priority-btn .star {
  font-size: 20px;
  color: #fbbf24;
}

.priority-btn.active .star {
  color: #fff;
}

.priority-btn .label {
  font-size: 13px;
  font-weight: 500;
}

/* ========================================
   类目选择 - 网格布局
   ======================================== */
.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.text-btn {
  background: none;
  border: none;
  color: #667eea;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
}

.text-btn:hover {
  background: rgba(102, 126, 234, 0.1);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  user-select: none;
}

.checkbox-grid label:hover {
  border-color: #d1d5db;
  background: #f3f4f6;
}

.checkbox-grid label:has(input:checked) {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
  font-weight: 500;
}

.checkbox-grid input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #667eea;
  margin: 0;
}

/* ========================================
   颜色选择
   ======================================== */
.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.color-grid label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  user-select: none;
}

.color-grid label:hover {
  border-color: #d1d5db;
  background: #f9fafb;
  transform: translateY(-2px);
}

.color-grid label:has(input:checked) {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.color-grid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
  margin: 0;
  flex-shrink: 0;
  align-self: flex-start;
}

.color-preview {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}

.color-grid span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
  font-weight: 500;
  color: #374151;
}

.empty-text {
  padding: 30px;
  text-align: center;
  color: #9ca3af;
  font-style: italic;
  font-size: 14px;
  grid-column: 1 / -1;
}

.cloud-section {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
}

.cloud-status {
  margin-bottom: 10px;
  color: #6b7280;
  font-size: 13px;
}

.cloud-status.ok {
  color: #15803d;
}

.cloud-status.bad {
  color: #b45309;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.cloud-login-card {
  max-width: 720px;
  margin: 0 auto 20px;
  padding: 28px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.login-shell {
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 20px 32px;
}

.login-card {
  width: min(400px, 100%);
  padding: 26px 28px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.14);
  text-align: center;
}

.login-card h2 {
  margin: 0 0 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 22px;
  line-height: 1.2;
}

.login-card h3 {
  margin: 0 0 20px;
  color: #111827;
  font-size: 18px;
  line-height: 1.2;
}

.login-card p {
  margin: 0 0 20px;
  color: #64748b;
  font-size: 14px;
}

.login-card .login-panel {
  grid-template-columns: 1fr;
}

.login-submit {
  height: 42px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(79, 70, 229, 0.28);
}

.login-submit:hover {
  filter: brightness(1.03);
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}


.cloud-login-card h2 {
  margin: 0 0 8px;
  color: #111827;
}

.cloud-login-card p {
  margin: 0 0 18px;
  color: #6b7280;
}

.cloud-error {
  margin-top: 12px;
  color: #dc2626;
  font-size: 14px;
}

/* ========================================
   按钮组
   ======================================== */
.button-group {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #f3f4f6;
}

.btn {
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f3f4f6;
  color: #6b7280;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-outline {
  background: #ffffff;
  color: #667eea;
  border: 2px solid #667eea;
  padding: 12px 24px;
}

.btn-outline:hover {
  background: rgba(102, 126, 234, 0.05);
}

/* ========================================
   加载动画
   ======================================== */
.loading {
  padding: 100px 40px;
  text-align: center;
}

.loader {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}

.loader div {
  position: absolute;
  top: 33px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loader div:nth-child(1) { left: 8px; animation: loader1 0.6s infinite; }
.loader div:nth-child(2) { left: 8px; animation: loader2 0.6s infinite; }
.loader div:nth-child(3) { left: 32px; animation: loader2 0.6s infinite; }
.loader div:nth-child(4) { left: 56px; animation: loader3 0.6s infinite; }

@keyframes loader1 { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes loader3 { 0% { transform: scale(1); } 100% { transform: scale(0); } }
@keyframes loader2 { 0% { transform: translate(0, 0); } 100% { transform: translate(24px, 0); } }

.loading p {
  margin-top: 24px;
  color: #6b7280;
  font-size: 16px;
}

/* ========================================
   错误提示
   ======================================== */
.error {
  padding: 60px 40px;
  text-align: center;
}

.error-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.error-text {
  font-size: 18px;
  font-weight: 600;
  color: #ef4444;
  margin-bottom: 8px;
}

.error-hint {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 24px;
}

/* ========================================
   成功提示
   ======================================== */
.success {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 30px 50px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(16, 185, 129, 0.3);
  z-index: 1000;
}

.success-icon {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 12px;
}

.success p {
  font-size: 18px;
  font-weight: 600;
}

/* ========================================
   管理页面样式
   ======================================== */
.manage-body {
  padding: 0;
  margin: 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  min-height: 100vh;
}

.manage-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 20px 24px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.manage-header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.manage-actions,
.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.10);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.16);
  filter: brightness(1.02);
}

.export-btn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.export-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 12px;
  line-height: 1;
}

.export-excel {
  background: linear-gradient(135deg, #118c4f 0%, #16a34a 100%);
  border-color: rgba(22, 163, 74, 0.30);
}

.export-csv {
  background: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
  border-color: rgba(37, 99, 235, 0.30);
}

.export-btn.is-loading .export-icon {
  animation: spin 0.8s linear infinite;
}

.stats-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  color: #374151;
}

/* 搜索栏 */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding: 20px 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.select-filter,
.filter-select {
  min-width: 150px;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: white;
}

.select-filter:focus,
.filter-select:focus {
  border-color: #667eea;
}

/* 数据表格卡片 */
.table-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.table-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
}

tbody tr:hover {
  background: #f9fafb;
}

.small-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
  margin-bottom: 4px;
}

.stars {
  color: #fbbf24;
  letter-spacing: 2px;
}

.action-btn {
  padding: 6px 12px;
  border: 1px solid #e5e7eb;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 6px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f3f4f6;
}

.delete-btn {
  color: #ef4444;
  border-color: #fecaca;
}

.delete-btn:hover {
  background: #fef2f2;
}

.btn-danger {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: #ef4444;
  color: #fff;
  cursor: pointer;
}

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

.link-btn {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
}

.text-ellipsis {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  margin-right: 6px;
}

.btn-icon:hover {
  background: #f3f4f6;
}

.color-thumb-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  margin: 2px 6px 2px 0;
  vertical-align: middle;
}

.color-thumb-small {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.color-thumb-name {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #374151;
}

.loading-row {
  text-align: center;
  color: #6b7280;
}

.spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  border: 3px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(17, 24, 39, 0.45);
}

.modal-content {
  width: min(520px, calc(100vw - 32px));
  margin: 10vh auto;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.modal-footer {
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #f3f4f6;
  border-bottom: 0;
}

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-weight: 600;
}

.close {
  cursor: pointer;
  font-size: 24px;
  color: #6b7280;
}

.priority-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 空状态 */
.empty-state {
  padding: 80px 20px;
  text-align: center;
  color: #9ca3af;
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #6b7280;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 768px) {
  .login-panel {
    grid-template-columns: 1fr;
  }

  .color-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .color-preview {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  .color-grid {
    grid-template-columns: 1fr;
  }
  
  .color-preview {
    width: 140px;
    height: 140px;
  }
}
