/* MegaBazaar Admin Panel Styles */
:root {
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --primary: #7B1E2B;
  --primary-hover: #6A1A26;
  --accent: #C4A04A;
  --text: #2A1F1A;
  --text-muted: #6B5D52;
  --text-faint: #9A8B7E;
  --border: #E8DFD4;
  --divider: #F0E8DD;
  --danger: #C0392B;
  --danger-bg: #FDF2F0;
  --success: #27AE60;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(42,31,26,0.06);
  --shadow-md: 0 4px 12px rgba(42,31,26,0.08);
  --shadow-lg: 0 8px 32px rgba(42,31,26,0.12);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Login Screen --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #7B1E2B 0%, #5A1620 50%, #2A1F1A 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.login-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s;
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 4px;
}

.login-back {
  display: inline-block;
  margin-top: 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.login-back:hover { color: var(--primary); }

/* --- Buttons --- */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn-secondary:hover { border-color: var(--accent); background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
}

.btn-ghost:hover { color: var(--primary); }

.btn-ghost-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-ghost-danger:hover { color: #A02818; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.btn-icon:hover { border-color: var(--accent); color: var(--primary); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* --- Admin Dashboard --- */
.admin-dashboard {
  min-height: 100vh;
}

.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.admin-brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1;
}

.admin-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-weight: 600;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Toolbar --- */
.admin-toolbar {
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.toolbar-left {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 300px;
}

.toolbar-right {
  display: flex;
  gap: 8px;
}

.toolbar-input, .toolbar-select {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}

.toolbar-input { flex: 1; max-width: 400px; }
.toolbar-input:focus, .toolbar-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  gap: 32px;
  padding: 20px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  font-weight: 600;
}

/* --- Product Table --- */
.table-container {
  padding: 0 32px 32px;
  overflow-x: auto;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.product-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 700;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.product-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  vertical-align: middle;
}

.product-table tr:hover td { background: var(--bg); }
.product-table tr:last-child td { border-bottom: none; }

.cell-image {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

.cell-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-name { font-weight: 600; }
.cell-price { font-weight: 600; color: var(--primary); }
.cell-price-original { text-decoration: line-through; color: var(--text-faint); font-size: 12px; }

.badge-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-best { background: #FFF3E0; color: #B8860B; }
.badge-new { background: #E8F5E9; color: #2E7D32; }
.badge-sale { background: #FDF2F0; color: #C0392B; }
.badge-none { color: var(--text-faint); font-size: 12px; }

.status-active { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--text-faint); }

.cell-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius-md);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42,31,26,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

/* --- Form --- */
.product-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea { resize: vertical; }

.form-checkbox-group {
  flex-direction: row;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}

/* --- Image Upload --- */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.image-upload-area:hover { border-color: var(--accent); background: var(--bg); }
.image-upload-area.dragover { border-color: var(--primary); background: var(--bg); }

.upload-prompt {
  text-align: center;
  color: var(--text-faint);
  padding: 20px;
}

.upload-prompt svg { margin-bottom: 8px; }
.upload-prompt p { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.upload-prompt span { font-size: 12px; }

.image-preview {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
}

.remove-image-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-image-btn:hover { background: var(--danger); }

/* --- Toast --- */
.admin-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.admin-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .admin-header { padding: 12px 16px; }
  .admin-toolbar { padding: 12px 16px; flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; min-width: 0; }
  .toolbar-right { justify-content: flex-end; }
  .stats-bar { padding: 16px; gap: 20px; flex-wrap: wrap; }
  .stat-value { font-size: 22px; }
  .table-container { padding: 0 16px 16px; }
  .product-table { font-size: 13px; }
  .product-table th, .product-table td { padding: 8px 10px; }
  .form-row { flex-direction: column; gap: 12px; }
  .modal-content { max-width: 100%; }
  .product-form { padding: 20px; }
  .admin-header-right { gap: 4px; }
  .admin-brand { font-size: 18px; }
}

@media (max-width: 480px) {
  .stats-bar { gap: 16px; }
  .stat-value { font-size: 20px; }
  .product-table th:nth-child(5),
  .product-table td:nth-child(5) { display: none; }
  .product-table th:nth-child(6),
  .product-table td:nth-child(6) { display: none; }
}

/* --- Section Tabs --- */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border, #E5E0D8);
}
.admin-tab {
  background: none;
  border: none;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-faint, #9A9187);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.admin-tab.active {
  color: var(--accent, #7B1E2B);
  border-bottom-color: var(--accent, #7B1E2B);
}

/* --- Order Status Badges --- */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-paid { background: #E8F5E9; color: #2E7D32; }
.status-pending { background: #FFF3E0; color: #B8860B; }

/* --- Order Detail Modal --- */
.order-detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.order-detail-overlay.open { display: flex; }
.order-detail-card {
  background: var(--bg, #fff);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}
.order-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #E5E0D8);
  font-size: 14px;
}
.order-detail-row:last-child { border-bottom: none; }
.order-items-list {
  margin: 12px 0;
  font-size: 14px;
}
.order-items-list li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
