/* ===== Tenza Shop Admin Panel Styles ===== */
:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #fff7ed;
  --red: #e8380d;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --green: #16a34a;
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--slate-900), var(--slate-800));
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
}

.login-logo h1 { font-size: 22px; font-weight: 800; }
.login-subtitle { color: var(--slate-500); font-size: 14px; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--slate-700); }

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,0.1); }

select.form-input {
  background: var(--white);
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
  color: var(--slate-900);
  min-height: 40px;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}

.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-message {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}

.login-message.error { display: block; background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.login-message.success { display: block; background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.back-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--slate-500);
  text-decoration: none;
  font-size: 13px;
}
.back-link:hover { color: var(--orange); }

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--slate-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-title { font-size: 16px; font-weight: 700; }
.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.nav-item:hover { color: white; background: rgba(255,255,255,0.06); }
.nav-item.active { color: white; background: var(--orange); }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.logout-btn { color: var(--slate-400); }
.logout-btn:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

/* Admin user dropdown menu */
.admin-user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 100;
  padding: 4px;
}
.admin-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--slate-600, #475569);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
}
.admin-user-menu-item:hover {
  background: #fef2f2;
  color: #ef4444;
}
.admin-user-menu-item.logout svg { stroke: currentColor; }

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: white;
  border-bottom: 1px solid var(--slate-100);
  position: sticky;
  top: 0;
  z-index: 40;
}
.admin-header h2 { font-size: 20px; font-weight: 700; }
.admin-user { display: flex; align-items: center; gap: 10px; }
.admin-user span { font-size: 13px; color: var(--slate-500); }
.admin-avatar {
  width: 36px;
  height: 36px;
  background: var(--orange);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* Sections */
.admin-section { padding: 24px 28px; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid var(--slate-100);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-label { font-size: 13px; color: var(--slate-500); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 800; }
.stat-change {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.stat-change.positive { background: #f0fdf4; color: var(--green); }
.stat-change.negative { background: #fef2f2; color: #ef4444; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--slate-100);
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--slate-100);
}
.data-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--slate-50);
}
.data-table tr:hover { background: var(--slate-50); }
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.shipped { background: #eff6ff; color: #3b82f6; }
.status-badge.processing { background: #fff7ed; color: #f97316; }
.status-badge.delivered { background: #f0fdf4; color: #16a34a; }
.status-badge.cancelled { background: #fef2f2; color: #ef4444; }

/* Top Products */
.top-products { display: flex; flex-direction: column; gap: 12px; }
.top-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.top-product-item:hover { background: var(--slate-50); }
.tp-rank {
  width: 28px;
  height: 28px;
  background: var(--orange-light);
  color: var(--orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.tp-info { flex: 1; }
.tp-info strong { display: block; font-size: 13px; font-weight: 600; }
.tp-info span { font-size: 12px; color: var(--slate-500); }
.tp-revenue { font-size: 14px; font-weight: 700; color: var(--green); }

/* Toolbar */
.section-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar-search {
  flex: 1;
  max-width: 300px;
  padding: 8px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.toolbar-search:focus { border-color: var(--orange); }
.primary-btn {
  padding: 8px 20px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary-btn:hover { opacity: 0.9; }
.action-btn {
  padding: 4px 12px;
  border: 1px solid var(--slate-200);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--slate-700);
}
.action-btn:hover { background: var(--slate-50); }
.action-btn.delete { color: #ef4444; border-color: #fecaca; }
.action-btn.delete:hover { background: #fef2f2; }

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid .form-group { margin-bottom: 16px; }
.settings-grid .primary-btn { margin-top: 8px; }
.integration-item {
  padding: 16px;
  border: 1px solid var(--slate-100);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.integration-item div { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.integration-item p { font-size: 13px; color: var(--slate-500); }
.integration-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.integration-status.connected { background: #f0fdf4; color: var(--green); }

/* Product Form Modal */
.modal-overlay-admin {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-card-header h3 {
  font-size: 18px;
  font-weight: 700;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Order Status */
.status-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
}
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-badge.status-pending { background: #fef3c7; color: #d97706; }
.status-badge.status-shipped { background: #dbeafe; color: #2563eb; }
.status-badge.status-delivered { background: #dcfce7; color: #16a34a; }

/* Projected Earnings */
.earnings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.earnings-item {
  text-align: center;
  padding: 16px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-100);
}
.earnings-item .earnings-label {
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.earnings-item .earnings-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}
@media (max-width: 1024px) { .earnings-grid { grid-template-columns: repeat(2, 1fr); } }

/* Downloaders Grid */
.downloaders-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.downloader-card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
}
.downloader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== Category Management ===== */
.categories-manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.category-manage-card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
}
.category-manage-card:hover {
  border-color: var(--orange);
  box-shadow: 0 2px 8px rgba(249,115,22,0.12);
}
.category-manage-card .cat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.category-manage-card .cat-info {
  flex: 1;
  min-width: 0;
}
.category-manage-card .cat-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--slate-900);
  text-transform: capitalize;
}
.category-manage-card .cat-count {
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 2px;
}
.category-manage-card .cat-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
}
.cat-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
  cursor: pointer;
}

/* ===== Stripe Dashboard ===== */
.stripe-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.stripe-tab {
  padding: 8px 16px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate-700);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.stripe-tab:hover {
  background: #f0edff;
  border-color: #6772e5;
  color: #6772e5;
}
.stripe-tab.active {
  background: #6772e5;
  color: var(--white);
  border-color: #6772e5;
}
.stripe-tab-content {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Fulfillment status badges for automation */
.fulfillment-status-pending_handoff { background: #fff7ed; color: #c2410c; }
.fulfillment-status-handed_off { background: #eff6ff; color: #1d4ed8; }
.fulfillment-status-vendor_confirmed { background: #f0fdf4; color: #15803d; }
.fulfillment-status-shipped { background: #ecfdf5; color: #059669; }
.fulfillment-status-delivered { background: #f0fdf4; color: #16a34a; }
.fulfillment-status-failed { background: #fef2f2; color: #dc2626; }

/* Automation method badge */
.method-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.method-badge.auto { background: #ecfdf5; color: #059669; }
.method-badge.manual { background: #fff7ed; color: #c2410c; }
.method-badge.retry { background: #fef3c7; color: #92400e; }

/* CJ Setup messages */
.cj-message { display: none; }
.cj-message.success { display: block; background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* "Open CJ Order" button on order details (links admin to the CJ order page so
   the operator can view fulfillment on CJ's dashboard). */
.cj-pay-btn {
  display: inline-block;
  background: #ff6f00;
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
}

.cj-pay-btn:hover {
  background: #e65f00;
  color: white;
  text-decoration: none;
}
.cj-message.error { display: block; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }