@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #f8f7fa;
  --surface: #ffffff;
  --surface-2: #faf9fb;

  --text: #29242b;
  --muted: #8c838d;

  --primary: #d94f91;
  --primary-dark: #b93672;
  --primary-light: #fce4ef;

  --gold: #c7a45b;
  --gold-light: #f7efd9;

  --green: #29966a;
  --green-light: #e4f6ee;

  --red: #d94d5b;
  --red-light: #fde8eb;

  --orange: #d98a35;
  --orange-light: #fff0dc;

  --border: #eee9ef;

  --shadow:
    0 10px 35px rgba(40, 25, 45, 0.07);

  --radius: 18px;

  --sidebar-width: 265px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button,
input,
select {
  font-family: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}


/* =========================
   SIDEBAR
========================= */

.sidebar {
  position: fixed;
  top: 0;
  right: 0;

  width: var(--sidebar-width);
  height: 100vh;

  background: var(--surface);

  border-left: 1px solid var(--border);

  display: flex;
  flex-direction: column;

  z-index: 1000;

  transition: transform 0.3s ease;
}

.sidebar-header {
  height: 95px;

  padding: 20px;

  display: flex;
  align-items: center;

  gap: 12px;

  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 48px;
  height: 48px;

  flex-shrink: 0;

  border-radius: 15px;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--gold)
    );

  color: white;

  font-size: 24px;

  box-shadow:
    0 8px 20px rgba(217, 79, 145, 0.25);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 800;
}

.sidebar-header span {
  display: block;

  color: var(--muted);

  font-size: 11px;

  margin-top: 3px;
}

.sidebar-close {
  display: none;

  margin-right: auto;

  border: 0;

  background: transparent;

  font-size: 27px;

  color: var(--muted);
}

.sidebar-nav {
  padding: 22px 14px;

  display: flex;
  flex-direction: column;

  gap: 7px;

  flex: 1;
}

.nav-item {
  height: 52px;

  padding: 0 15px;

  border-radius: 13px;

  display: flex;
  align-items: center;

  gap: 13px;

  color: var(--muted);

  font-size: 14px;

  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}

.nav-item:hover {
  background: var(--surface-2);

  color: var(--primary);

  transform: translateX(-2px);
}

.nav-item.active {
  background: var(--primary-light);

  color: var(--primary);

  font-weight: 700;
}

.nav-icon {
  width: 25px;

  text-align: center;

  font-size: 19px;
}

.sidebar-bottom {
  padding: 15px;

  border-top: 1px solid var(--border);
}

.admin-mini {
  display: flex;
  align-items: center;

  gap: 10px;

  margin-bottom: 12px;

  padding: 10px;
}

.admin-avatar {
  width: 40px;
  height: 40px;

  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--primary-light);

  color: var(--primary);

  font-weight: 800;
}

.admin-mini-info {
  min-width: 0;
}

.admin-mini-info strong {
  display: block;

  font-size: 13px;
}

.admin-mini-info small {
  display: block;

  color: var(--muted);

  font-size: 10px;

  margin-top: 3px;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.logout-btn {
  width: 100%;

  height: 45px;

  border: 1px solid var(--border);

  border-radius: 12px;

  background: transparent;

  color: var(--red);

  font-size: 13px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 8px;

  transition: 0.2s;
}

.logout-btn:hover {
  background: var(--red-light);
}


/* =========================
   MAIN
========================= */

.main-content {
  margin-right: var(--sidebar-width);

  min-height: 100vh;
}

.topbar {
  min-height: 95px;

  padding: 18px 30px;

  background: var(--surface);

  border-bottom: 1px solid var(--border);

  display: flex;
  align-items: center;

  gap: 20px;
}

.menu-toggle {
  display: none;

  width: 43px;
  height: 43px;

  border: 1px solid var(--border);

  background: var(--surface);

  border-radius: 12px;

  font-size: 20px;
}

.page-heading {
  flex: 1;
}

.page-heading h1 {
  font-size: 21px;

  font-weight: 800;
}

.page-heading p {
  color: var(--muted);

  font-size: 12px;

  margin-top: 5px;
}

.topbar-actions {
  display: flex;

  align-items: center;

  gap: 10px;
}

.theme-btn {
  width: 43px;
  height: 43px;

  border-radius: 12px;

  border: 1px solid var(--border);

  background: var(--surface);

  color: var(--text);

  font-size: 20px;
}

.add-product-btn {
  height: 43px;

  padding: 0 17px;

  border-radius: 12px;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--primary-dark)
    );

  color: white;

  font-size: 12px;

  font-weight: 700;

  display: flex;
  align-items: center;

  gap: 6px;

  box-shadow:
    0 7px 18px rgba(217, 79, 145, 0.22);
}

.add-product-btn span {
  font-size: 19px;
}


/* =========================
   CONTENT
========================= */

.content {
  padding: 28px 30px 50px;

  max-width: 1600px;

  margin: auto;
}


/* =========================
   STATS
========================= */

.stats-grid {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap: 16px;

  margin-bottom: 22px;
}

.stat-card {
  min-height: 110px;

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  padding: 18px;

  box-shadow: var(--shadow);

  display: flex;
  align-items: center;

  gap: 14px;
}

.stat-icon {
  width: 53px;
  height: 53px;

  border-radius: 16px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 21px;
}

.products-icon {
  background: var(--primary-light);
  color: var(--primary);
}

.active-icon {
  background: var(--green-light);
  color: var(--green);
}

.inactive-icon {
  background: var(--red-light);
  color: var(--red);
}

.stock-icon {
  background: var(--gold-light);
  color: var(--gold);
}

.stat-card span {
  display: block;

  color: var(--muted);

  font-size: 11px;

  margin-bottom: 7px;
}

.stat-card strong {
  font-size: 23px;
}


/* =========================
   PANEL
========================= */

.panel,
.products-panel {
  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 20px;

  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;

  justify-content: space-between;

  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 16px;

  font-weight: 800;
}

.panel-header span {
  display: block;

  margin-top: 4px;

  color: var(--muted);

  font-size: 11px;
}

.refresh-btn {
  border: 1px solid var(--border);

  background: var(--surface);

  color: var(--text);

  height: 38px;

  padding: 0 14px;

  border-radius: 10px;

  font-size: 11px;
}

.refresh-btn:hover {
  border-color: var(--primary);

  color: var(--primary);
}


/* =========================
   FILTERS
========================= */

.filters {
  display: grid;

  grid-template-columns:
    minmax(230px, 1.5fr)
    repeat(3, minmax(150px, 1fr));

  gap: 12px;
}

.search-box {
  position: relative;

  height: 48px;
}

.search-box input {
  width: 100%;
  height: 100%;

  border: 1px solid var(--border);

  background: var(--surface-2);

  border-radius: 12px;

  outline: none;

  padding:
    0 42px
    0 38px;

  color: var(--text);

  font-size: 12px;
}

.search-box input:focus {
  border-color: var(--primary);

  box-shadow:
    0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;

  right: 15px;

  top: 50%;

  transform: translateY(-50%);

  color: var(--muted);

  font-size: 21px;
}

.clear-search {
  position: absolute;

  left: 10px;

  top: 50%;

  transform: translateY(-50%);

  width: 25px;
  height: 25px;

  border: 0;

  background: transparent;

  color: var(--muted);

  display: none;

  font-size: 19px;
}

.clear-search.visible {
  display: block;
}

.filter-field label {
  display: block;

  color: var(--muted);

  font-size: 10px;

  margin-bottom: 6px;
}

.filter-field select {
  width: 100%;

  height: 48px;

  border: 1px solid var(--border);

  background: var(--surface-2);

  color: var(--text);

  border-radius: 12px;

  padding: 0 12px;

  outline: none;

  font-size: 11px;
}

.filter-field select:focus {
  border-color: var(--primary);
}


/* =========================
   TABLE
========================= */

.products-panel {
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;

  border-collapse: collapse;

  min-width: 1000px;
}

thead {
  background: var(--surface-2);
}

th {
  padding: 15px 13px;

  color: var(--muted);

  font-size: 10px;

  font-weight: 600;

  text-align: right;

  white-space: nowrap;

  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 13px;

  border-bottom: 1px solid var(--border);

  font-size: 11px;

  vertical-align: middle;
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover {
  background: var(--surface-2);
}


/* Product */

.product-info {
  display: flex;
  align-items: center;

  gap: 11px;

  min-width: 220px;
}

.product-image {
  width: 52px;
  height: 52px;

  border-radius: 13px;

  object-fit: cover;

  flex-shrink: 0;

  background: var(--surface-2);

  border: 1px solid var(--border);
}

.product-image-placeholder {
  width: 52px;
  height: 52px;

  border-radius: 13px;

  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      135deg,
      var(--primary-light),
      var(--gold-light)
    );

  color: var(--primary);

  font-size: 21px;
}

.product-name {
  font-weight: 700;

  max-width: 210px;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.product-id {
  display: block;

  color: var(--muted);

  font-size: 9px;

  margin-top: 3px;
}

.category-name {
  color: var(--muted);
}

.price {
  font-weight: 700;

  white-space: nowrap;
}

.old-price {
  display: block;

  color: var(--muted);

  text-decoration: line-through;

  font-size: 9px;

  margin-top: 3px;
}

.stock {
  font-weight: 700;
}

.stock.low {
  color: var(--red);
}

.stock.medium {
  color: var(--orange);
}

.stock.good {
  color: var(--green);
}


/* Badges */

.status-badge,
.feature-badge {
  display: inline-flex;

  align-items: center;

  justify-content: center;

  min-width: 65px;

  height: 27px;

  padding: 0 8px;

  border-radius: 20px;

  font-size: 9px;

  font-weight: 600;
}

.status-active {
  color: var(--green);

  background: var(--green-light);
}

.status-inactive {
  color: var(--red);

  background: var(--red-light);
}

.feature-list {
  display: flex;

  gap: 5px;

  flex-wrap: wrap;
}

.feature-badge.featured {
  color: var(--primary);

  background: var(--primary-light);
}

.feature-badge.recommended {
  color: var(--gold);

  background: var(--gold-light);
}


/* Actions */

.actions {
  display: flex;

  align-items: center;

  gap: 6px;
}

.action-btn {
  width: 34px;
  height: 34px;

  border-radius: 9px;

  border: 1px solid var(--border);

  background: var(--surface);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 15px;

  transition: 0.2s;
}

.action-btn.edit:hover {
  border-color: var(--primary);

  color: var(--primary);

  background: var(--primary-light);
}

.action-btn.delete:hover {
  border-color: var(--red);

  color: var(--red);

  background: var(--red-light);
}


/* =========================
   MOBILE CARDS
========================= */

.mobile-products {
  display: none;

  padding: 12px;
}

.mobile-product-card {
  border: 1px solid var(--border);

  border-radius: 15px;

  padding: 13px;

  margin-bottom: 10px;

  background: var(--surface);
}

.mobile-product-top {
  display: flex;

  align-items: center;

  gap: 10px;
}

.mobile-product-info {
  flex: 1;

  min-width: 0;
}

.mobile-product-name {
  font-size: 12px;

  font-weight: 700;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.mobile-product-category {
  font-size: 9px;

  color: var(--muted);

  margin-top: 3px;
}

.mobile-product-data {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 8px;

  margin-top: 12px;
}

.mobile-data-item {
  background: var(--surface-2);

  border-radius: 9px;

  padding: 9px;
}

.mobile-data-item span {
  display: block;

  color: var(--muted);

  font-size: 8px;

  margin-bottom: 3px;
}

.mobile-data-item strong {
  font-size: 10px;
}

.mobile-actions {
  display: flex;

  gap: 7px;

  margin-top: 10px;
}

.mobile-actions .action-btn {
  flex: 1;

  width: auto;
}


/* =========================
   PAGINATION
========================= */

.pagination {
  min-height: 65px;

  padding: 12px 17px;

  border-top: 1px solid var(--border);

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 6px;
}

.page-btn {
  height: 35px;

  min-width: 60px;

  border: 1px solid var(--border);

  background: var(--surface);

  color: var(--text);

  border-radius: 9px;

  font-size: 10px;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);

  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;

  cursor: not-allowed;
}

#pageNumbers {
  display: flex;

  gap: 5px;
}

.page-number {
  width: 35px;
  height: 35px;

  border: 1px solid var(--border);

  background: var(--surface);

  color: var(--text);

  border-radius: 9px;

  font-size: 10px;
}

.page-number.active {
  background: var(--primary);

  border-color: var(--primary);

  color: white;
}


/* =========================
   LOADING
========================= */

.loading-box {
  min-height: 300px;

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  box-shadow: var(--shadow);

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  gap: 14px;
}

.loader {
  width: 38px;
  height: 38px;

  border-radius: 50%;

  border: 3px solid var(--primary-light);

  border-top-color: var(--primary);

  animation: spin 0.8s linear infinite;
}

.loading-box p {
  color: var(--muted);

  font-size: 11px;
}

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


/* =========================
   ERROR / EMPTY
========================= */

.error-box,
.empty-box {
  min-height: 300px;

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  box-shadow: var(--shadow);

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  text-align: center;

  padding: 30px;
}

.error-icon,
.empty-icon {
  width: 65px;
  height: 65px;

  border-radius: 20px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 28px;

  margin-bottom: 15px;
}

.error-icon {
  background: var(--red-light);

  color: var(--red);

  font-weight: 800;
}

.empty-icon {
  background: var(--primary-light);

  color: var(--primary);
}

.error-box h3,
.empty-box h3 {
  font-size: 15px;

  margin-bottom: 6px;
}

.error-box p,
.empty-box p {
  color: var(--muted);

  font-size: 11px;

  margin-bottom: 16px;
}

.error-box button,
.empty-box button {
  height: 39px;

  padding: 0 18px;

  border: 0;

  border-radius: 10px;

  background: var(--primary);

  color: white;

  font-size: 10px;
}


/* =========================
   MODAL
========================= */

.modal-overlay {
  position: fixed;

  inset: 0;

  background: rgba(20, 15, 22, 0.55);

  backdrop-filter: blur(5px);

  z-index: 3000;

  display: flex;

  align-items: center;
  justify-content: center;

  padding: 20px;
}

.modal {
  position: relative;

  width: 100%;

  max-width: 430px;

  background: var(--surface);

  border-radius: 22px;

  padding: 30px;

  text-align: center;

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.2);

  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;

    transform: scale(0.95);
  }

  to {
    opacity: 1;

    transform: scale(1);
  }
}

.modal-close {
  position: absolute;

  left: 16px;
  top: 14px;

  width: 32px;
  height: 32px;

  border: 0;

  background: transparent;

  color: var(--muted);

  font-size: 22px;
}

.modal-danger-icon {
  width: 62px;
  height: 62px;

  border-radius: 20px;

  margin: 0 auto 14px;

  background: var(--red-light);

  color: var(--red);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 27px;

  font-weight: 800;
}

.modal h2 {
  font-size: 17px;

  margin-bottom: 10px;
}

.modal p {
  color: var(--muted);

  font-size: 11px;

  line-height: 2;
}

.modal p strong {
  color: var(--text);
}

.modal-warning {
  margin-top: 13px;

  padding: 10px;

  border-radius: 10px;

  background: var(--red-light);

  color: var(--red);

  font-size: 10px;
}

.modal-actions {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 9px;

  margin-top: 20px;
}

.cancel-btn,
.confirm-delete-btn {
  height: 43px;

  border-radius: 11px;

  font-size: 11px;

  font-weight: 600;
}

.cancel-btn {
  border: 1px solid var(--border);

  background: var(--surface);

  color: var(--text);
}

.confirm-delete-btn {
  border: 0;

  background: var(--red);

  color: white;
}


/* =========================
   TOAST
========================= */

.toast {
  position: fixed;

  top: 20px;

  left: 20px;

  min-width: 250px;

  max-width: calc(100% - 40px);

  padding: 13px 17px;

  border-radius: 12px;

  background: var(--text);

  color: white;

  font-size: 11px;

  z-index: 5000;

  opacity: 0;

  transform: translateY(-15px);

  pointer-events: none;

  transition: 0.25s;
}

.toast.show {
  opacity: 1;

  transform: translateY(0);
}

.toast.success {
  background: var(--green);
}

.toast.error {
  background: var(--red);
}


/* =========================
   UTILITY
========================= */

.hidden {
  display: none !important;
}


/* =========================
   DARK MODE
========================= */

@media (prefers-color-scheme: dark) {

  :root {
    --bg: #171419;
    --surface: #211c22;
    --surface-2: #29232a;

    --text: #f5eef3;
    --muted: #aaa0aa;

    --border: #383039;

    --primary-light: #3c2533;

    --green-light: #1c342a;

    --red-light: #3b2227;

    --gold-light: #382f20;

    --orange-light: #392b1d;

    --shadow:
      0 10px 35px rgba(0, 0, 0, 0.18);
  }

}



/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1150px) {

  .stats-grid {
    grid-template-columns:
      repeat(2, 1fr);
  }

  .filters {
    grid-template-columns:
      repeat(2, 1fr);
  }

  .search-box {
    grid-column: span 2;
  }

}


@media (max-width: 900px) {

  .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .main-content {
    margin-right: 0;
  }

  .menu-toggle {
    display: block;
  }

  .sidebar-overlay {
    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, 0.4);

    z-index: 999;

    opacity: 0;

    pointer-events: none;

    transition: 0.3s;
  }

  .sidebar-overlay.show {
    opacity: 1;

    pointer-events: auto;
  }

}


@media (max-width: 650px) {

  .topbar {
    padding: 14px 15px;

    min-height: 75px;
  }

  .page-heading h1 {
    font-size: 16px;
  }

  .page-heading p {
    font-size: 9px;
  }

  .theme-btn {
    display: none;
  }

  .add-product-btn {
    width: 43px;

    padding: 0;

    justify-content: center;

    font-size: 0;
  }

  .add-product-btn span {
    font-size: 21px;
  }

  .content {
    padding: 17px 12px 35px;
  }

  .stats-grid {
    grid-template-columns:
      repeat(2, 1fr);

    gap: 9px;
  }

  .stat-card {
    min-height: 90px;

    padding: 12px;

    gap: 9px;
  }

  .stat-icon {
    width: 41px;
    height: 41px;

    border-radius: 12px;

    font-size: 17px;
  }

  .stat-card span {
    font-size: 9px;
  }

  .stat-card strong {
    font-size: 18px;
  }

  .panel {
    padding: 14px;
  }

  .panel-header {
    margin-bottom: 15px;
  }

  .panel-header h2 {
    font-size: 14px;
  }

  .refresh-btn {
    font-size: 9px;

    padding: 0 9px;
  }

  .filters {
    display: block;
  }

  .search-box {
    margin-bottom: 10px;
  }

  .filter-field {
    margin-bottom: 10px;
  }

  .filter-field:last-child {
    margin-bottom: 0;
  }

  .table-wrapper {
    display: none;
  }

  .mobile-products {
    display: block;
  }

  .pagination {
    padding: 11px;
  }

  .page-btn {
    min-width: 50px;

    font-size: 9px;
  }

  .page-number {
    width: 32px;
    height: 32px;
  }

  .modal {
    padding: 25px 18px;
  }

}