/* ===================================================
   Pegasus Next Co., Ltd. - Premium Dark Purple Theme
   =================================================== */

:root {
  --primary: #8B5CF6;
  --primary-light: #A78BFA;
  --primary-dark: #7C3AED;
  --primary-soft: #EDE9FE;
  --accent: #F5D0FE;
  --success: #10B981;
  --success-bg: #D1FAE5;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.15);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --bg-gradient: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 50%, #F9FAFB 100%);
  --sidebar-bg: linear-gradient(180deg, #FFFFFF 0%, #F9FAFB 100%);
  --card-bg: #FFFFFF;
  --topbar-bg: #FFFFFF;
  --input-bg: #FFFFFF;
  --modal-bg: #FFFFFF;
  --toast-bg: #FFFFFF;
  --dropdown-bg: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
}

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

body {
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
  font-size: 15px;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,0.04);
  border-right: 1px solid var(--gray-200);
}

.sidebar-logo {
  padding: 28px 24px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.15);
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-logo img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.4));
}

.sidebar-logo-text {
  line-height: 1.3;
}

.sidebar-logo-text .company {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sidebar-logo-text .app-name {
  font-size: 16px;
  color: var(--primary);
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  margin-bottom: 6px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

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

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* ── Main Content ── */
.main {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--topbar-bg);
  padding: 20px 32px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.topbar-sub {
  font-size: 13px;
  color: var(--gray-500);
}

.page-content {
  padding: 32px 36px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--gray-200);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.1);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
}

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
  margin-bottom: 26px;
}

.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.stat-icon.purple { background: var(--primary-soft); }
.stat-icon.green { background: var(--success-bg); }
.stat-icon.yellow { background: var(--warning-bg); }
.stat-icon.red { background: var(--danger-bg); }
.stat-icon.blue { background: #DBEAFE; }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #A78BFA 0%, #7C3AED 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(167, 139, 250, 0.45);
}

.btn-success {
  background: linear-gradient(135deg, #34D399 0%, #10B981 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(52, 211, 153, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #F87171 0%, #EF4444 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  transform: translateY(-2px);
}

.btn-warning {
  background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.3);
}

.btn-gray {
  background: var(--gray-300);
  color: var(--gray-900);
}

.btn-gray:hover {
  background: var(--gray-500);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.3);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ── Form Controls ── */
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
  background: var(--input-bg);
  color: var(--text-main);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
  color: #FFFFFF;
}

th {
  padding: 15px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.4px;
}

td {
  padding: 14px;
  border-bottom: 1px solid var(--gray-300);
  color: var(--gray-700);
}

tbody tr {
  transition: all 0.2s;
}

tbody tr:hover {
  background: rgba(167, 139, 250, 0.08);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

.empty-state .icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.4;
  filter: grayscale(0.5);
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--modal-bg);
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  transition: all 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--gray-300);
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--gray-800);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--gray-300);
  color: #fff;
}

.modal-body {
  padding: 26px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 18px 26px;
  border-top: 1px solid var(--gray-300);
  background: rgba(0,0,0,0.2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 26px;
  right: 26px;
  z-index: 2000;
}

.toast {
  background: var(--toast-bg);
  padding: 15px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--primary);
  border: 1px solid var(--gray-200);
  color: var(--text-main);
  transition: all 0.3s ease;
}

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

.toast.success { 
  border-left-color: var(--success);
  box-shadow: 0 4px 20px rgba(52, 211, 153, 0.2);
}
.toast.error { 
  border-left-color: var(--danger);
  box-shadow: 0 4px 20px rgba(248, 113, 113, 0.2);
}
.toast.info { 
  border-left-color: var(--primary);
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.2);
}

/* ── Utilities ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { justify-content: space-between; }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

.page-btn {
  padding: 9px 16px;
  border: 2px solid var(--gray-300);
  background: rgba(10,10,15,0.6);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  transition: all 0.2s;
}

.page-btn:hover {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.3);
}

.page-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.4);
}

/* ── Alert ── */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius);
  margin-bottom: 22px;
  font-size: 14px;
  font-weight: 500;
}

.alert-danger {
  background: var(--danger-bg);
  color: #FCA5A5;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.alert-success {
  background: var(--success-bg);
  color: #6EE7B7;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

/* ── Autocomplete ── */
.autocomplete-wrap {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--dropdown-bg);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 6px;
  transition: all 0.3s ease;
}

.autocomplete-item {
  padding: 13px 18px;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.autocomplete-item:hover {
  background: rgba(167, 139, 250, 0.1);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item strong {
  color: var(--primary);
  font-weight: 700;
}

.autocomplete-item small {
  color: var(--gray-500);
  display: block;
  margin-top: 4px;
}

/* ── Product Search ── */
.product-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

/* ── Sign Grid ── */
.sign-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 16px;
}

.sign-box {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sign-label {
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 600;
}

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-approved {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-returned {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.total-badge {
  background: rgba(167, 139, 250, 0.15);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 1024px) {
  .main { margin-left: 0; }
  .sidebar { width: 76px; }
  .sidebar-logo-text, .nav-item span:not(.icon) { display: none; }
  .sidebar-logo { justify-content: center; padding: 22px 14px; }
  .sidebar-nav { padding: 18px 10px; }
  .nav-item { justify-content: center; padding: 14px; }
  .nav-item .icon { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 14px; padding: 18px; }
  .page-content { padding: 18px; }
  .sign-grid { grid-template-columns: 1fr; }
}
