/* ============================================================
   WMS - Warehouse Management System
   Shared Stylesheet
   ============================================================ */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-hover: #3d4f68;
  --accent-blue: #3b82f6;
  --accent-blue-dark: #2563eb;
  --accent-green: #22c55e;
  --accent-green-dark: #16a34a;
  --accent-red: #ef4444;
  --accent-red-dark: #dc2626;
  --accent-yellow: #f59e0b;
  --accent-yellow-dark: #d97706;
  --accent-purple: #a855f7;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #475569;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

/* ── LIGHT MODE ── */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --shadow: 0 4px 20px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo { font-size: 18px; font-weight: 800; color: var(--accent-blue); letter-spacing: -0.5px; }
.sidebar-logo span { color: var(--text-secondary); font-weight: 400; font-size: 12px; display: block; margin-top: 2px; }
.sidebar-user { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-blue); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-info .user-name { font-weight: 600; font-size: 14px; }
.user-info .user-role { font-size: 11px; color: var(--text-secondary); }
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: var(--text-secondary);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.15s; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--accent-blue); border-right: 3px solid var(--accent-blue); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.btn-logout { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; background: rgba(239,68,68,0.1); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ── MAIN CONTENT ── */
.main-content { margin-left: 240px; flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.page-body { flex: 1; padding: 24px; }

.hamburger { display: none; background: none; border: none; color: var(--text-primary); font-size: 22px; cursor: pointer; padding: 4px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }

/* ── CARDS ── */
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-blue-dark); }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--accent-green-dark); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--accent-red-dark); }
.btn-warning { background: var(--accent-yellow); color: #000; }
.btn-warning:hover:not(:disabled) { background: var(--accent-yellow-dark); }
.btn-ghost { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: var(--radius); }
.btn-full { width: 100%; }

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 11px 14px; background: var(--bg-tertiary); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px; font-family: inherit; transition: border-color 0.15s; outline: none; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent-blue); background: var(--bg-secondary); }
.form-input::placeholder { color: var(--text-muted); }
.form-select option { background: var(--bg-secondary); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── SCAN INPUT ── */
.scan-area { background: var(--bg-primary); border: 2px dashed var(--border-light); border-radius: var(--radius); padding: 20px; text-align: center; transition: border-color 0.15s; }
.scan-area:focus-within { border-color: var(--accent-blue); }
.scan-area .scan-icon { font-size: 36px; margin-bottom: 8px; display: block; }
.scan-area .scan-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.scan-big-input { width: 100%; padding: 16px; background: var(--bg-secondary); border: 2px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 20px; font-weight: 700; letter-spacing: 2px; text-align: center; outline: none; transition: border-color 0.15s; font-family: 'Courier New', monospace; }
.scan-big-input:focus { border-color: var(--accent-blue); }
.scan-big-input::placeholder { color: var(--text-muted); font-weight: 400; font-size: 15px; letter-spacing: 0; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-available { background: rgba(34,197,94,0.15); color: var(--accent-green); border: 1px solid rgba(34,197,94,0.3); }
.badge-active { background: rgba(59,130,246,0.15); color: var(--accent-blue); border: 1px solid rgba(59,130,246,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent-yellow); border: 1px solid rgba(245,158,11,0.3); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--accent-purple); border: 1px solid rgba(168,85,247,0.3); }
.badge-gray { background: rgba(100,116,139,0.15); color: var(--text-secondary); border: 1px solid rgba(100,116,139,0.3); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--bg-tertiary); padding: 12px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--bg-tertiary); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; color: var(--text-primary); }

/* ── SCAN LIST ── */
.scan-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.scan-list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; transition: background 0.1s; }
.scan-list-item:last-child { border-bottom: none; }
.scan-list-item:hover { background: var(--bg-tertiary); }
.scan-list-item.ok { border-left: 3px solid var(--accent-green); }
.scan-list-item.error { border-left: 3px solid var(--accent-red); }
.scan-list-item.warn { border-left: 3px solid var(--accent-yellow); }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-number { font-size: 32px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-blue .stat-number { color: var(--accent-blue); }
.stat-green .stat-number { color: var(--accent-green); }
.stat-red .stat-number { color: var(--accent-red); }
.stat-yellow .stat-number { color: var(--accent-yellow); }

/* ── TOAST ── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; box-shadow: var(--shadow); animation: toastIn 0.3s ease; pointer-events: all; min-width: 240px; max-width: 320px; }
.toast-success { background: var(--accent-green); color: #fff; }
.toast-error { background: var(--accent-red); color: #fff; }
.toast-warning { background: var(--accent-yellow); color: #000; }
.toast-info { background: var(--accent-blue); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); animation: modalIn 0.2s ease; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── HELPERS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'Courier New', monospace; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.progress-wrap { background: var(--bg-tertiary); border-radius: 20px; height: 10px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.3s ease; }
.progress-blue { background: var(--accent-blue); }
.progress-green { background: var(--accent-green); }
.progress-red { background: var(--accent-red); }
.progress-yellow { background: var(--accent-yellow); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; display: block; }
.empty-state .empty-text { font-size: 14px; }

/* ── RESPONSIVE ── */
/* ── RESPONSIVE — TABLET (768px) ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-body { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 16px; }
  .topbar-title { font-size: 16px; }
  .topbar-subtitle { font-size: 12px; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .modal { padding: 18px; }
  .btn-lg { padding: 12px 18px; font-size: 15px; }
  .scan-big-input { font-size: 16px; padding: 14px; }
  .stat-number { font-size: 26px; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 10px 10px; }
}

/* ── RESPONSIVE — MOBILE (480px) ── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-box { padding: 12px 10px; }
  .stat-number { font-size: 22px; }
  .stat-label { font-size: 10px; }
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .module-card { padding: 14px; }
  .module-card .module-icon { font-size: 26px; margin-bottom: 6px; }
  .module-card .module-name { font-size: 13px; }
  .module-card .module-desc { font-size: 11px; }
  .page-body { padding: 12px; }
  .login-card { padding: 24px 18px; }
  .pin-key { padding: 12px; font-size: 18px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-title { font-size: 15px; }
  .topbar-subtitle { display: none; }
  .card { padding: 14px; border-radius: var(--radius-sm); }
  .btn { padding: 9px 14px; font-size: 13px; }
  .btn-lg { padding: 11px 16px; font-size: 14px; }
  .scan-big-input { font-size: 15px; padding: 12px; letter-spacing: 1px; }
  .table-wrap { font-size: 12px; }
  thead th { padding: 8px; font-size: 10px; }
  tbody td { padding: 8px; }
  .badge { font-size: 10px; padding: 2px 7px; }
  .form-input, .form-select { font-size: 14px; padding: 10px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .audit-output { font-size: 12px; }
  /* RTS two-column → single on mobile */
  .rts-layout { grid-template-columns: 1fr !important; }
}

/* ── LOGIN ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); padding: 20px; }
.login-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.login-logo .logo-title { font-size: 22px; font-weight: 800; }
.login-logo .logo-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.pin-display { display: flex; justify-content: center; gap: 10px; margin: 16px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-light); background: transparent; transition: all 0.15s; }
.pin-dot.filled { background: var(--accent-blue); border-color: var(--accent-blue); }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.pin-key { padding: 16px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 20px; font-weight: 700; cursor: pointer; text-align: center; transition: all 0.1s; user-select: none; }
.pin-key:hover { background: var(--bg-hover); }
.pin-key:active { transform: scale(0.95); }
.pin-key.delete { font-size: 16px; color: var(--accent-red); }
.pin-key.empty { background: transparent; border-color: transparent; cursor: default; }

/* ── DASHBOARD ── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.module-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; text-decoration: none; color: var(--text-primary); transition: all 0.2s; cursor: pointer; display: block; }
.module-card:hover { border-color: var(--accent-blue); background: var(--bg-tertiary); transform: translateY(-2px); }
.module-card .module-icon { font-size: 32px; display: block; margin-bottom: 10px; }
.module-card .module-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.module-card .module-desc { font-size: 12px; color: var(--text-secondary); }

/* ── AUDIT OUTPUT ── */
.audit-output { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; color: var(--text-primary); min-height: 120px; }

/* ── PRINT (Barcode Labels) ── */
@media print {
  @page { size: 180mm 100mm landscape; margin: 0; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; inset: 0; background: #fff; }
  .barcode-label { width: 180mm; height: 100mm; display: flex; flex-direction: column; align-items: center; justify-content: center; page-break-after: always; background: #fff; color: #000; padding: 8mm; }
  .barcode-label .label-item-name { font-size: 18pt; font-weight: 900; text-transform: uppercase; margin-bottom: 4mm; letter-spacing: 1px; color: #000; text-align: center; }
  .barcode-label svg, .barcode-label img { max-width: 140mm; height: auto; }
  .barcode-label .label-code { font-size: 10pt; font-family: 'Courier New', monospace; margin-top: 3mm; color: #000; letter-spacing: 2px; }
}
