:root {
  --primary: #0071e3;
  --primary-dark: #005bb5;
  --primary-light: rgb(0 113 227 / 8%);
  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;
  --bg: #f5f5f7;
  --card-bg: #fff;
  --text: #1d1d1f;
  --text-muted: #86868b;
  --border: rgb(0 0 0 / 10%);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow: 0 8px 30px rgb(0 0 0 / 4%);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 30px;
}

/* --- SHARED NAVIGATION --- */
nav {
  background: #fff;
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgb(0 0 0 / 3%);
}

nav .container {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}

nav h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

nav h1 span {
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 5px;
  align-items: center;
}

.nav-item {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid rgb(0 113 227 / 10%);
}

/* --- COMMON COMPONENTS --- */
.content-block {
  background: white;
  padding: 25px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.btn-primary-custom {
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
}

.btn-primary-custom:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary-custom {
  background: #f2f2f7;
  color: var(--text);
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
}

.btn-secondary-custom:hover {
  background: #e5e5ea;
}

.badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success {
  background: #e8f9ed;
  color: #1a7f37;
}

.badge-danger {
  background: #ffebeb;
  color: #cf222e;
}

.badge-warning {
  background: #fff4e5;
  color: #ff9500;
}

.badge-pending {
  background: #f2f2f7;
  color: #1d1d1f;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fbfbfb;
  transition: all 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.table-container {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 15px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 15px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tr:hover td {
  background: #fbfbfb;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.stat-card {
  background: #fff;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 7%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 20px;
}

.stat-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

/* Global Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1040;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: 0.3s;
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-container {
  background: white;
  width: 95%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 32px;
  position: relative;
  box-shadow: 0 40px 100px rgb(0 0 0 / 20%);
}

.modal-header {
  padding: 35px 40px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 850;
  letter-spacing: -0.5px;
  margin: 0;
}

.modal-body {
  padding: 30px 40px 40px;
}

/* Admin UI Helpers */
.badge {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  display: inline-block;
  text-transform: uppercase;
}

.btn-primary-custom {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: 0.2s;
}

.btn-primary-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgb(0 113 227 / 20%);
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1.5px solid #e5e5ea;
  font-size: 15px;
  transition: 0.3s;
  background: white;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-action {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: #f2f2f7;
  color: #1d1d1f;
  text-decoration: none;
}

.btn-edit:hover {
  background: #e5e5ea;
  color: var(--primary);
}

.btn-delete {
  background: #fff2f2;
  color: #ff3b30;
  border: 1px solid #ffdbdb;
}

.btn-delete:hover {
  background: #ff3b30;
  color: white;
}

.modal-close {
  position: absolute;
  top: 25px;
  right: 25px;
  border: none;
  background: rgb(0 0 0 / 4%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader {
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* SweetAlert2 Z-Index Fix */
.swal2-container {
  z-index: 3000 !important;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 25px;
}

/* --- PRODUCT CATALOG --- */
.category-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 30px 0;
  padding-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  padding: 10px 24px;
  border-radius: 14px;
  background: white;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 4%);
}

.cat-pill:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
  color: var(--text);
}

.cat-pill.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
  box-shadow: 0 8px 20px -5px rgb(0 0 0 / 20%);
}

.product-list {
  padding: 30px 0 100px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
}

.product-card {
  background: #fff;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.product-card-img-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.product-card-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.6s ease;
}

.product-card:hover .product-card-img {
  transform: scale(1.1);
}

.product-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.product-card-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.product-card-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.3;
}

.product-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 15px;
  border-top: 1px solid #f1f5f9;
}

.product-card-price {
  font-size: 20px;
  font-weight: 850;
  color: var(--text);
}

.stock-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  z-index: 5;
}

.stock-badge.in-stock {
  background: #ecfdf5;
  color: #065f46;
}

.stock-badge.out-of-stock {
  background: #fef2f2;
  color: #991b1b;
}

.stock-badge.low-stock {
  background: #fffbeb;
  color: #92400e;
}

.btn-quick-add {
  background: var(--primary);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
}

.btn-quick-add:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

@media (width <= 768px) {
  .container {
    padding: 0 15px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  nav .container {
    flex-direction: row;
    height: 64px;
  }
}
