/* ===== Tenza 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); }

/* 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;
  margin-bottom: 16px;
}
.downloader-header h4 {
  font-size: 15px;
  font-weight: 700;
}
.downloader-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--slate-100);
  color: var(--slate-500);
}
.downloader-status.active {
  background: #f0fdf4;
  color: var(--green);
}
.downloader-card .form-group {
  margin-bottom: 12px;
}
.downloader-card .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
  margin-bottom: 4px;
}
.downloader-card .form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
}
.downloader-card .primary-btn {
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  margin-top: 4px;
}
@media (max-width: 1024px) { .downloaders-grid { grid-template-columns: 1fr; } }

/* API Keys Section */
.api-keys-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.api-key-card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
}
.api-key-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-key-card .form-group {
  margin-bottom: 12px;
}
.api-key-card .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
  margin-bottom: 4px;
}
.api-key-card .form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
}
.api-key-card .primary-btn {
  margin-top: 4px;
}
@media (max-width: 900px) { .api-keys-grid { grid-template-columns: 1fr; } }

/* Vendor Table Styles */
.vendor-logo-cell {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--slate-100);
}
.vendor-platform-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-700);
  text-transform: capitalize;
}
.status-badge.status-active { background: #dcfce7; color: #16a34a; }
.status-badge.status-inactive { background: var(--slate-100); color: var(--slate-500); }

/* Platform import tabs */
.platform-tab { transition: color 0.2s, border-color 0.2s; }
.platform-tab:hover { color: #f97316 !important; }

/* Section description text */
.section-description {
  font-size: 14px;
  color: var(--slate-500);
  margin-bottom: 20px;
}

/* Store Settings */
.store-settings-form {
  max-width: 600px;
}
.store-settings-form .form-group {
  margin-bottom: 16px;
}
.store-settings-form .form-row {
  margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .earnings-grid { grid-template-columns: 1fr; }
  .downloaders-grid { grid-template-columns: 1fr; }
  .api-keys-grid { grid-template-columns: 1fr; }
}
