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

/* ===== CSS Variables ===== */
:root {
  --bg-primary: #060913;
  --bg-secondary: #0b101f;
  --bg-card: #141e33;
  --bg-hover: #1a2744;
  --sidebar-width: 260px;
  --accent: #06b6d4;
  --accent-hover: #0891b2;
  --accent-glow: rgba(6, 182, 212, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(6, 182, 212, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: calc(50% + 130px);
  transform: translate(-50%, -50%);
  width: 550px;
  height: 550px;
  max-width: 65vw;
  max-height: 65vh;
  background: url('../watermark.png') center/contain no-repeat;
  opacity: 0.15;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 90;
}

@media (max-width: 992px) {
  body::before {
    left: 50%;
    width: 350px;
    height: 350px;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== Layout ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.brand-text .brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  display: block;
}

.brand-text .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.nav-item {
  padding: 4px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
}

.nav-link.active::before { opacity: 1; }

.nav-link i {
  font-size: 17px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  height: 64px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h5, .card-header h6 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.card-body { padding: 22px; }

/* ===== Stat Cards ===== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.06;
  transform: translate(30%, -30%);
}

.stat-card.cyan::after { background: var(--accent); }
.stat-card.green::after { background: var(--success); }
.stat-card.red::after { background: var(--danger); }
.stat-card.amber::after { background: var(--warning); }

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.stat-info .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  padding: 9px 18px;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0891b2);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
  transform: translateY(-2px);
  color: white;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
}
.btn-danger:hover {
  transform: translateY(-2px);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 4px; font-size: 14px; }

/* ===== Forms ===== */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  display: block;
}

.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control, .form-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 13.5px;
  width: 100%;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}

.form-control::placeholder { color: var(--text-muted); }

.form-select option { background: var(--bg-card); color: var(--text-primary); }

.form-group { margin-bottom: 18px; }

/* Image Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon { font-size: 36px; color: var(--text-muted); margin-bottom: 10px; }
.upload-text { color: var(--text-secondary); font-size: 13px; }
.upload-hint { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }

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

.data-table thead tr {
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: left;
}

.data-table td {
  padding: 14px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 13.5px;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

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

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent); }
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-gray { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* Stock badges */
.stock-in { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stock-out { background: rgba(239, 68, 68, 0.12); color: var(--danger); }

/* ===== Alerts ===== */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}
.alert-success { background: rgba(16, 185, 129, 0.12); color: var(--success); border-left: 3px solid var(--success); }
.alert-danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); border-left: 3px solid var(--danger); }
.alert-warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-left: 3px solid var(--warning); }
.alert-info { background: rgba(6, 182, 212, 0.12); color: var(--accent); border-left: 3px solid var(--accent); }

/* ===== Product Image ===== */
.product-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-hover);
}

.product-img-lg {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== Barcode Scanner ===== */
.scanner-layout-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 992px) {
  .scanner-layout-grid {
    grid-template-columns: 1fr;
  }
  .scanner-section {
    position: static !important;
  }
}

.scanner-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

#interactive.viewport {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
}

#interactive video {
  width: 100%;
  display: block;
}

#interactive canvas { display: none; }

.scan-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: none;
}

.scan-result.found {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  display: block;
}

.scan-result.not-found {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  display: block;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: scanLine 2s ease-in-out infinite;
  z-index: 10;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a, .pagination span {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: white; border-color: var(--accent); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon { font-size: 56px; color: var(--text-muted); margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-muted); }

/* ===== Confirm Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

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

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  transform: scale(0.9);
  transition: var(--transition);
}

.modal-overlay.show .modal-box { transform: scale(1); }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(6,182,212,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.05) 0%, transparent 50%);
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.5);
  animation: fadeInUp 0.5s ease;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 24px;
  box-shadow: 0 0 40px rgba(6, 182, 212, 0.3);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scanLine {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 3px); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.fade-in { animation: fadeInUp 0.4s ease; }

/* ===== Utility ===== */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.d-none-lg { display: none; }

.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

.row-gap { row-gap: 20px; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  
  .d-none-lg { display: inline-flex !important; }
}

@media (max-width: 576px) {
  .page-body { padding: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Review Barcode List ===== */
.review-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 20px;
}

.review-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.review-table-body {
  max-height: 400px;
  overflow-y: auto;
}

/* Custom Checkbox */
.form-check-input {
  width: 18px;
  height: 18px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.form-check-input:checked::after {
  content: '\2714';
  font-size: 12px;
  color: white;
}
