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

:root {
  --bg: #0f0f11;
  --bg2: #17171a;
  --bg3: #1e1e22;
  --bg4: #26262c;
  --border: #2e2e36;
  --border2: #3a3a45;
  --text: #e8e8ec;
  --text2: #9898a8;
  --text3: #6060708;
  --accent: #7c5cfc;
  --accent2: #9c82ff;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --teal: #14b8a6;
  --pink: #ec4899;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

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

/* ── Auth ──────────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-brand .brand-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.auth-brand h1 { font-size: 24px; font-weight: 700; color: var(--accent2); }
.auth-brand p { color: var(--text2); font-size: 13px; margin-top: 4px; }

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.auth-link { display: block; text-align: center; margin-top: 16px; color: var(--accent2); font-size: 13px; text-decoration: none; }

/* ── Layout ────────────────────────────────────────────────────────────── */
#main-app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 18px;
  font-size: 17px; font-weight: 700;
  color: var(--accent2);
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  transition: all var(--transition);
  position: relative;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(124,92,252,.15); color: var(--accent2); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-info { flex: 1; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text2); text-transform: capitalize; }

.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
}

.page { display: none; padding: 28px 32px; }
.page.active { display: block; }

/* ── Page headers ──────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ── Stat cards ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--text2); margin-top: 4px; }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-amber { color: var(--amber); }
.stat-blue { color: var(--blue); }
.stat-accent { color: var(--accent2); }

/* ── Cards & Tables ────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 14px; }
.card-body { padding: 20px; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left; font-size: 12px; font-weight: 500;
  color: var(--text2); text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }

/* ── Product / Alert cards (grid) ─────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  cursor: pointer;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.product-card-img {
  width: 100%; height: 160px; object-fit: contain;
  background: var(--bg3); padding: 10px;
}
.product-card-img-placeholder {
  width: 100%; height: 160px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
.product-card-body { padding: 14px; }
.product-card-name {
  font-size: 13.5px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}
.product-card-price { font-size: 20px; font-weight: 700; color: var(--green); }
.product-card-mrp { font-size: 12px; color: var(--text2); text-decoration: line-through; margin-left: 6px; }
.product-card-discount {
  display: inline-block;
  background: rgba(239,68,68,.15); color: var(--red);
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; margin-top: 6px;
}
.product-card-coupon {
  display: inline-block;
  background: rgba(245,158,11,.12); color: var(--amber);
  font-size: 11px; padding: 2px 7px; border-radius: 20px; margin-top: 4px; margin-left: 4px;
}
.product-card-meta { margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.product-card-platform {
  font-size: 11px; color: var(--text2);
  background: var(--bg3); padding: 2px 7px; border-radius: 4px;
}
.product-card-actions { padding: 0 14px 14px; display: flex; gap: 8px; }

/* ── Badges & Pills ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
}
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-amber  { background: rgba(245,158,11,.15);  color: var(--amber); }
.badge-blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-purple { background: rgba(124,92,252,.15);  color: var(--accent2); }
.badge-gray   { background: var(--bg4); color: var(--text2); }

/* Priority badges */
.priority-1 { background: rgba(239,68,68,.2); color: #f87171; }
.priority-2 { background: rgba(245,158,11,.2); color: var(--amber); }
.priority-3 { background: rgba(59,130,246,.2); color: var(--blue); }
.priority-4 { background: rgba(34,197,94,.2); color: var(--green); }
.priority-5 { background: var(--bg4); color: var(--text2); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg4); border-color: var(--border2); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-icon { background: transparent; color: var(--text2); padding: 6px 8px; font-size: 16px; }
.btn-icon:hover { color: var(--text); }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

input, select, textarea {
  width: 100%; padding: 9px 13px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text2); }
select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"] {
  width: 16px; height: 16px; margin-right: 6px;
  accent-color: var(--accent);
}
.form-hint { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg2); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
#modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert-error {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.25);
  color: #f87171; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.alert-success {
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.25);
  color: #4ade80; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.alert-info {
  background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.25);
  color: #93c5fd; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 1000; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13.5px; min-width: 280px; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }
.toast-warning { border-left: 3px solid var(--amber); }

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

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 20px 0;
}
.page-btn {
  padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); cursor: pointer; font-size: 13px;
}
.page-btn:hover, .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-info { color: var(--text2); font-size: 13px; padding: 0 8px; }

/* ── Filters bar ───────────────────────────────────────────────────────── */
.filters-bar {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 20px;
}
.filters-bar input, .filters-bar select {
  width: auto; flex-shrink: 0;
  min-width: 120px; max-width: 200px;
}
.filter-search { flex: 1; min-width: 200px; max-width: 320px !important; }

/* ── Worker cards ──────────────────────────────────────────────────────── */
.worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.worker-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.worker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.worker-name { font-weight: 600; font-size: 15px; }
.worker-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.worker-status-dot.offline { background: var(--red); }
.worker-stat-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.worker-stat-row:last-child { border-bottom: none; }
.worker-stat-label { color: var(--text2); }
.worker-stat-value { font-weight: 500; }

/* ── Misc ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.tag {
  display: inline-block; background: var(--bg3); color: var(--text2);
  font-size: 11px; padding: 2px 8px; border-radius: 4px; margin: 2px;
}
.section-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Sortable layout builder ───────────────────────────────────────────── */
.layout-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  margin-bottom: 6px; cursor: grab;
}
.layout-field.dragging { opacity: .4; }
.drag-handle { color: var(--text2); cursor: grab; }

/* Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }
