/* ============================================================
   RFID & BLOCKCHAIN TRACKER — Main Stylesheet
   Industrial-Tech Aesthetic | Dark Theme
   ============================================================ */

:root {
  --bg-base:       #0a0e17;
  --bg-surface:    #0f1521;
  --bg-elevated:   #151d2e;
  --bg-card:       #1a2235;
  --bg-hover:      #1f2a40;

  --accent:        #00d4ff;
  --accent-dim:    rgba(0,212,255,0.12);
  --accent-border: rgba(0,212,255,0.3);
  --accent-glow:   0 0 20px rgba(0,212,255,0.25);

  --green:         #00e676;
  --green-dim:     rgba(0,230,118,0.12);
  --orange:        #ff9100;
  --orange-dim:    rgba(255,145,0,0.12);
  --red:           #ff1744;
  --red-dim:       rgba(255,23,68,0.12);
  --yellow:        #ffd740;

  --text-primary:  #e8edf5;
  --text-secondary:#8b9ab5;
  --text-muted:    #4a5568;
  --text-accent:   #00d4ff;

  --border:        rgba(255,255,255,0.06);
  --border-accent: rgba(0,212,255,0.25);

  --sidebar-w:     260px;
  --topnav-h:      60px;
  --radius:        10px;
  --radius-lg:     16px;

  --font-main:     'Space Grotesk', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 2px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

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

.brand-icon {
  width: 40px; height: 40px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 18px;
  box-shadow: var(--accent-glow);
}

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

.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), #0070ff);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px 20px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s;
  margin-bottom: 2px;
  position: relative;
}

.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item span { display: flex; align-items: center; gap: 6px; width: 100%; }

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

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-logout:hover { background: var(--red-dim); color: var(--red); }

/* ============================================================
   MAIN WRAPPER & TOPNAV
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .3s cubic-bezier(.4,0,.2,1);
}

.topnav {
  height: var(--topnav-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all .2s;
}

.sidebar-toggle:hover { border-color: var(--accent-border); color: var(--accent); }

.topnav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  text-decoration: none;
  position: relative;
  transition: all .2s;
}

.topnav-btn:hover { border-color: var(--accent-border); color: var(--accent); }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(1.3); }
}

.chain-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(0,230,118,0.2);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ── NOTIFICATIONS DROPDOWN ── */
.notif-dropdown {
  width: 320px;
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  padding: 0 !important;
  box-shadow: var(--shadow-lg) !important;
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.notif-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  transition: background .2s;
}

.notif-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.notif-item.read { opacity: .6; }
.notif-item i { font-size: 16px; margin-top: 2px; flex-shrink: 0; }
.notif-title { font-size: 12.5px; font-weight: 500; }
.notif-time { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  width: 100%;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header-left h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.page-breadcrumb a { color: var(--accent); text-decoration: none; }
.page-breadcrumb span { color: var(--text-muted); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .3s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity .3s;
}

.stat-card:hover { border-color: var(--accent-border); transform: translateY(-2px); box-shadow: var(--accent-glow); }
.stat-card:hover::before { opacity: 1; }

.stat-card.danger::before { background: linear-gradient(90deg, var(--red), transparent); }
.stat-card.success::before { background: linear-gradient(90deg, var(--green), transparent); }
.stat-card.warning::before { background: linear-gradient(90deg, var(--orange), transparent); }

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

.stat-icon.cyan { background: var(--accent-dim); color: var(--accent); }
.stat-icon.green { background: var(--green-dim); color: var(--green); }
.stat-icon.orange { background: var(--orange-dim); color: var(--orange); }
.stat-icon.red { background: var(--red-dim); color: var(--red); }

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

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.stat-delta {
  font-size: 11px;
  font-family: var(--font-mono);
  margin-top: 4px;
}

.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
}

.card-header {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0 !important;
  padding: 14px 20px !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--accent); }
.card-body { padding: 20px !important; }

/* ============================================================
   TABLES
   ============================================================ */
.table {
  color: var(--text-primary) !important;
  font-size: 13.5px;
}

.table > :not(caption) > * > * {
  background-color: transparent !important;
  border-bottom-color: var(--border) !important;
  padding: 12px 14px !important;
}

.table thead th {
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted) !important;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.table tbody tr:hover td { background-color: var(--bg-hover) !important; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--text-muted) !important; }

.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-secondary) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent-dim) !important;
  border-color: var(--accent-border) !important;
  color: var(--accent) !important;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-family: var(--font-main) !important;
  font-size: 13.5px !important;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 0 3px rgba(0,212,255,0.1) !important;
  outline: none !important;
  background: var(--bg-card) !important;
}

.form-control::placeholder { color: var(--text-muted) !important; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: 0.3px; }
.input-group-text { background: var(--bg-elevated) !important; border: 1px solid var(--border) !important; color: var(--text-muted) !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-main) !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  font-size: 13.5px !important;
  padding: 9px 18px !important;
  transition: all .2s !important;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0070ff) !important;
  border: none !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(0,212,255,0.3) !important;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,212,255,0.4) !important; }

.btn-success {
  background: linear-gradient(135deg, var(--green), #00b248) !important;
  border: none !important;
  color: #000 !important;
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #c62828) !important;
  border: none !important;
  color: #fff !important;
}

.btn-warning {
  background: linear-gradient(135deg, var(--orange), #e65100) !important;
  border: none !important;
  color: #fff !important;
}

.btn-outline-primary { border-color: var(--accent-border) !important; color: var(--accent) !important; background: transparent !important; }
.btn-outline-primary:hover { background: var(--accent-dim) !important; }

.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.btn-icon { width: 32px; height: 32px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
}

.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: 18px 22px !important;
}

.modal-title { font-weight: 700 !important; font-size: 16px !important; }

.modal-footer {
  border-top: 1px solid var(--border) !important;
  padding: 14px 22px !important;
}

.btn-close { filter: invert(1) !important; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-family: var(--font-mono) !important;
  font-size: 10.5px !important;
  font-weight: 600 !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  letter-spacing: 0.3px;
}

/* ============================================================
   RFID TAG DISPLAY
   ============================================================ */
.rfid-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* ── BLOCKCHAIN TX HASH ── */
.tx-hash {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--green);
  background: var(--green-dim);
  padding: 3px 8px;
  border-radius: 6px;
  word-break: break-all;
}

/* ── BLOCK CARD ── */
.block-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  transition: border-color .3s;
}

.block-card.invalid { border-color: var(--red); background: var(--red-dim); }
.block-card.valid { border-color: rgba(0,230,118,0.2); }

.block-card::after {
  content: '▼';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 10px;
  z-index: 1;
}

.block-card:last-child::after { display: none; }
.block-index { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-bottom: 8px; }
.block-hash-display { font-family: var(--font-mono); font-size: 10px; color: var(--accent); word-break: break-all; }

/* ============================================================
   SCAN SIMULATOR
   ============================================================ */
.scan-area {
  background: var(--bg-card);
  border: 2px dashed var(--accent-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all .3s;
  position: relative;
  overflow: hidden;
}

.scan-area.scanning {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.scan-area::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,0.08), transparent);
  transition: left .6s;
}

.scan-area.scanning::before { left: 100%; animation: scanLine 1.5s infinite; }

@keyframes scanLine {
  0% { left: -100%; }
  100% { left: 100%; }
}

.scan-icon { font-size: 64px; color: var(--accent); margin-bottom: 16px; display: block; }
.scan-text { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.scan-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-family: var(--font-mono); }

/* ── SCAN RESULT ── */
.scan-result-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 20px;
  display: none;
}

.scan-result-card.success { background: var(--green-dim); border: 1px solid rgba(0,230,118,0.3); }
.scan-result-card.error   { background: var(--red-dim); border: 1px solid rgba(255,23,68,0.3); }
.scan-result-card.warning { background: var(--orange-dim); border: 1px solid rgba(255,145,0,0.3); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 10px;
  transition: border-color .2s;
}

.alert-item.critical { border-left: 4px solid var(--red); }
.alert-item.high     { border-left: 4px solid var(--orange); }
.alert-item.medium   { border-left: 4px solid var(--yellow); }
.alert-item.low      { border-left: 4px solid var(--green); }

/* ============================================================
   TIMELINE / SCAN HISTORY
   ============================================================ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-base);
  box-shadow: 0 0 8px var(--accent);
}

.timeline-dot.danger  { background: var(--red); box-shadow: 0 0 8px var(--red); }
.timeline-dot.warning { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.timeline-dot.success { background: var(--green); box-shadow: 0 0 8px var(--green); }

.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.timeline-time { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); }

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

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,212,255,0.06) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,112,255,0.06) 0%, transparent 70%);
  bottom: -50px; right: -50px;
  pointer-events: none;
}

.login-card {
  width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  position: relative;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  color: var(--accent);
  margin: 0 auto 12px;
  box-shadow: var(--accent-glow);
}

.login-logo h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-logo p { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
}

/* ── MISC UTILS ── */
.mono { font-family: var(--font-mono) !important; }
.text-accent { color: var(--accent) !important; }
.text-green { color: var(--green) !important; }
.text-orange { color: var(--orange) !important; }
.bg-card { background: var(--bg-card) !important; }
.border-accent { border-color: var(--accent-border) !important; }
.rounded-12 { border-radius: 12px !important; }
.gap-2 { gap: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-family: var(--font-mono); margin-bottom: 12px; }
