:root {
  --primary: #c26938;
  --primary-hover: #ab572a;
  --bg-dark: #121316;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px -4px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 36px 30px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-logo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
  border: 3px solid #f1f5f9;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.auth-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-input-group {
  margin-bottom: 20px;
  text-align: left;
}

.auth-input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s;
  outline: none;
}

.auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(194, 105, 56, 0.15);
}

.btn-auth {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

/* Header Navbar */
.admin-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.brand-badge {
  font-size: 0.72rem;
  background: #eff6ff;
  color: #2563eb;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid #bfdbfe;
  letter-spacing: 0.5px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-secondary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.btn-secondary-link:hover {
  background: #e2e8f0;
}

.btn-logout {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  background: #fee2e2;
}

/* Main Container */
.admin-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.stat-info h4 {
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-info .stat-number {
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-green { background: #f0fdf4; color: #16a34a; }
.icon-amber { background: #fffbeb; color: #d97706; }
.icon-purple { background: #faf5ff; color: #9333ea; }

/* Control Toolbar */
.admin-toolbar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 280px;
}

.search-box {
  position: relative;
  min-width: 240px;
  flex: 1;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.90rem;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.search-box input:focus {
  background: #ffffff;
  border-color: var(--primary);
}

.select-filter {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: #f8fafc;
  outline: none;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.btn-outline {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: #f8fafc;
}

/* Products Table & Grid */
.products-wrapper {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.product-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.product-table th {
  background: #f8fafc;
  padding: 14px 18px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.product-table td {
  padding: 16px 18px;
  font-size: 0.90rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.product-table tr:hover {
  background: #fdfefe;
}

.cell-product {
  display: flex;
  align-items: center;
  gap: 14px;
}

.p-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}

.p-meta .p-name {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.p-meta .p-id {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: monospace;
}

.badge-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
}

.badge-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.stock-in { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.stock-low { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.stock-out { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.quick-stock-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-stock-adj {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  transition: all 0.15s;
}

.btn-stock-adj:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.stock-num-input {
  width: 48px;
  padding: 4px 2px;
  text-align: center;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #475569;
}

.btn-action-icon:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-action-icon.delete:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fca5a5;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.98);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #64748b;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.90rem;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(194, 105, 56, 0.12);
}

/* Image Upload Manager */
.image-uploader-box {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.image-uploader-box:hover {
  border-color: var(--primary);
  background: #fdf8f5;
}

.image-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.preview-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.preview-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb-wrap .btn-del-img {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(220, 38, 38, 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.preview-thumb-wrap.is-main {
  border-color: var(--primary);
}

.preview-thumb-wrap.is-main::after {
  content: 'MAIN';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  font-size: 0.60rem;
  font-weight: 800;
  text-align: center;
  padding: 1px 0;
}

.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: #ffffff;
  z-index: 10;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: slideToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }

@keyframes slideToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
  .admin-navbar { padding: 12px 16px; }
  .admin-container { padding: 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .toolbar-left { min-width: 100%; }
}
