/* ============================================================
   MANDEEHUB – SELLER PANEL (mobile-first responsive)
   ============================================================ */

:root {
  --primary: #123B80;
  --primary-dark: #0d2c60;
  --secondary: #FF8A00;
  --secondary-dark: #e07a00;
  --bg: #F5F7FB;
  --text: #1a1f36;
  --muted: #6b7280;
  --border: #e5e9f0;
  --sidebar-w: 255px;
  --topbar-h: 64px;
  --radius: 10px;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --info: #3b82f6;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; display: block; }

.seller-wrap { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.seller-sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  overflow-x: hidden;
}

.seller-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.seller-brand .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
}
.seller-brand strong {
  display: block;
  font-size: 14px;
  color: var(--primary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seller-brand small { font-size: 11px; color: var(--muted); }

.seller-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  -webkit-overflow-scrolling: touch;
}
.seller-nav::-webkit-scrollbar { width: 6px; }
.seller-nav::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.nav-group { margin-bottom: 16px; }
.nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .6px;
  padding: 6px 12px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: .15s;
  min-height: 40px;
}
.nav-link i { font-size: 17px; color: var(--muted); flex-shrink: 0; }
.nav-link:hover { background: var(--bg); color: var(--primary); }
.nav-link.active { background: rgba(18, 59, 128, .1); color: var(--primary); font-weight: 600; }
.nav-link.active i { color: var(--primary); }
.nav-link span:not(.badge-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-count {
  margin-left: auto;
  background: var(--secondary);
  color: #fff;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1029;
  display: none;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.seller-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Topbar */
.seller-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.btn-icon {
  border: 0;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  position: relative;
  transition: .15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg); color: var(--primary); }
.btn-icon i { font-size: 18px; }
.btn-icon .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--secondary);
  border-radius: 50%;
  border: 2px solid #fff;
}

.topbar-search {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
}
.topbar-search input {
  border: 0;
  background: transparent;
  flex: 1;
  outline: none;
  font-size: 13.5px;
  min-width: 0;
}
.topbar-search i { color: var(--muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.seller-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: inherit;
  max-width: 100%;
}
.seller-user:hover { background: var(--bg); }
.seller-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.smaller { font-size: 11.5px; }

/* Content */
.seller-content {
  padding: 24px;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.seller-footer {
  padding: 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.page-intro { margin-bottom: 20px; }
.page-intro h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; line-height: 1.2; }
.page-intro p { margin: 0; color: var(--muted); font-size: 13px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  position: relative;
  transition: .2s;
  min-width: 0;
}
.kpi-card:hover { box-shadow: 0 6px 20px rgba(18, 59, 128, .08); transform: translateY(-2px); }
.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.kpi-icon.blue   { background: rgba(18, 59, 128, .1); color: var(--primary); }
.kpi-icon.orange { background: rgba(255, 138, 0, .12); color: var(--secondary); }
.kpi-icon.green  { background: rgba(22, 163, 74, .1); color: var(--success); }
.kpi-icon.red    { background: rgba(220, 38, 38, .1); color: var(--danger); }
.kpi-icon.purple { background: rgba(147, 51, 234, .1); color: #9333ea; }

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  word-break: break-word;
}
.kpi-delta { font-size: 11.5px; margin-top: 8px; font-weight: 600; }

/* ============================================================
   DATA CARD
   ============================================================ */
.data-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}
.data-card-head {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.data-card-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.data-card-head .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================
   TABLE
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead { background: #fafbfd; }
.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
  word-break: break-word;
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Horizontal scroll on mobile */
@media (max-width: 767px) {
  .data-card > .table-responsive,
  .data-card .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { min-width: 640px; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-outline,
.btn-success,
.btn-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 0;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
  text-decoration: none;
  min-height: 38px;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover   { background: #15803d; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #b91c1c; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover   { background: var(--primary); color: #fff; }
.btn-sm        { padding: 6px 10px; font-size: 12px; border-radius: 6px; min-height: 32px; }
.w-100         { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}
.form-control,
.form-select {
  border-radius: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: .15s;
  max-width: 100%;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 59, 128, .1);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pill.success { background: #dcfce7; color: #166534; }
.badge-pill.pending { background: #fef3c7; color: #92400e; }
.badge-pill.danger  { background: #fee2e2; color: #991b1b; }
.badge-pill.info    { background: #dbeafe; color: #1e40af; }
.badge-pill.muted   { background: #f1f5f9; color: #475569; }
.badge-pill.warning { background: #fef3c7; color: #92400e; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text);
  min-width: 36px;
  text-align: center;
}
.pagination a:hover { background: var(--bg); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast-item {
  background: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  border-left: 4px solid var(--primary);
  font-size: 13px;
  min-width: 260px;
  max-width: 420px;
  animation: slideIn .3s;
  pointer-events: auto;
}
.toast-item.success { border-left-color: var(--success); }
.toast-item.error   { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ============================================================
   IMAGE UPLOADER
   ============================================================ */
.image-uploader {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.img-slot {
  width: 100px;
  height: 100px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #fafbfd;
  transition: .15s;
  flex-shrink: 0;
}
.img-slot:hover { border-color: var(--primary); background: #f0f4fc; }
.img-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-slot .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  border: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}
.img-slot .primary-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: var(--secondary);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}
.img-slot input[type=file] { display: none; }
.img-slot.add-slot { color: var(--muted); font-size: 22px; }
.img-slot.add-slot:hover { color: var(--primary); }

/* ============================================================
   MISC
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}
.low-stock { background: #fef3c7 !important; }
.low-stock td { color: #92400e; }

.dropdown-menu {
  font-size: 13.5px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
  min-width: 200px;
}
.dropdown-item { padding: 9px 14px; display: flex; gap: 8px; align-items: center; }
.dropdown-item:hover { background: var(--bg); color: var(--primary); }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tabs a.active,
.tabs a:hover { border-bottom-color: var(--primary); color: var(--primary); }

/* ============================================================
   RESPONSIVE — TABLET  (≤ 991px)
   ============================================================ */
@media (max-width: 991px) {
  .seller-sidebar { transform: translateX(-100%); }
  .seller-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0, 0, 0, .15); }
  .sidebar-backdrop.open { display: block; }
  .seller-main { margin-left: 0; }
  .topbar-search { max-width: none; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ============================================================
   RESPONSIVE — PHONE  (≤ 767px)
   ============================================================ */
@media (max-width: 767px) {
  .seller-topbar {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
  }
  .topbar-search { display: none; }
  .seller-user > div { display: none; }
  .seller-user > i { display: none; }
  .seller-content { padding: 14px; }
  .seller-footer { padding: 12px 16px; font-size: 11px; }

  .page-intro { margin-bottom: 14px; }
  .page-intro h1 { font-size: 18px; }
  .page-intro p { font-size: 12px; }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card { padding: 12px; border-radius: 10px; }
  .kpi-card .kpi-icon { width: 34px; height: 34px; font-size: 16px; margin-bottom: 6px; }
  .kpi-label { font-size: 11px; }
  .kpi-value { font-size: 18px; }
  .kpi-delta { font-size: 10.5px; margin-top: 4px; }

  .data-card-head {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .data-card-head .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .data-card-head .filters .form-control,
  .data-card-head .filters .form-select,
  .data-card-head .filters .btn-primary {
    width: 100% !important;
    max-width: 100% !important;
  }

  .data-table { font-size: 12.5px; }
  .data-table th,
  .data-table td { padding: 9px 10px; }

  .form-control,
  .form-select { font-size: 16px; } /* prevents iOS zoom */

  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-outline,
  .btn-success,
  .btn-warning {
    min-height: 42px;
    padding: 10px 16px;
  }
  .btn-sm { min-height: 36px; padding: 7px 12px; font-size: 12.5px; }

  .toast-container {
    top: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
  .toast-item {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .img-slot { width: 84px; height: 84px; }

  .pagination { padding: 12px; justify-content: center; }
}

/* ============================================================
   RESPONSIVE — SMALL PHONE  (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  .seller-content { padding: 12px; }
  .kpi-value { font-size: 16px; }
  .badge-pill { font-size: 10.5px; padding: 2px 8px; }
  .kpi-card .kpi-icon { width: 30px; height: 30px; font-size: 14px; }
}

/* ============================================================
   EXTRA SMALL  (≤ 360px)
   ============================================================ */
@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .seller-brand strong { font-size: 13px; }
  .seller-brand small { font-size: 10px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .seller-sidebar,
  .seller-topbar,
  .seller-footer,
  .toast-container,
  .btn-icon,
  .data-card-head .filters {
    display: none !important;
  }
  .seller-main { margin-left: 0 !important; }
  .seller-content { padding: 0; }
  .data-card { border: 1px solid #ccc; box-shadow: none; }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}