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

/* ========================
   CSS Variables / Tokens
   ======================== */
:root {
  --bg-primary: #0a0f1e;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #263349;
  --border: #334155;
  --border-light: #475569;
  
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.1);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

  --transition: 0.25s ease;
}

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

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

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-primary); }

/* ========================
   Animated Background
   ======================== */
.animated-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.animated-bg::before {
  content: '';
  position: absolute;
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: float1 12s ease-in-out infinite;
}
.animated-bg::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(34,197,94,0.08) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  animation: float2 15s ease-in-out infinite;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(60px,40px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-50px,-30px)} }

/* ========================
   App Layout
   ======================== */
.app-layout { 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;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
  box-shadow: 0 0 20px var(--accent-glow);
}
.sidebar-logo h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.sidebar-logo p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-muted); text-transform: uppercase;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.nav-item.active {
  background: linear-gradient(135deg, var(--accent-glow), rgba(139,92,246,0.15));
  color: var(--accent);
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  transition: color var(--transition); padding: 4px;
  border-radius: 4px;
}
.logout-btn:hover { color: var(--danger); }

/* Main Content */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 22px; font-weight: 700; }
.topbar-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.page-content { padding: 32px; }

/* ========================
   Cards
   ======================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
}
.card:hover { border-color: var(--border-light); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; align-items: flex-start; justify-content: space-between;
  cursor: default;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.indigo::before { background: linear-gradient(90deg, var(--accent), #8b5cf6); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #10b981); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--warning), #ef4444); }
.stat-card.blue::before { background: linear-gradient(90deg, var(--info), #0ea5e9); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-light); }

.stat-info { flex: 1; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 36px; font-weight: 800; margin-top: 6px; line-height: 1; }
.stat-value.indigo { color: var(--accent); }
.stat-value.green { color: var(--success); }
.stat-value.amber { color: var(--warning); }
.stat-value.blue { color: var(--info); }
.stat-change { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-icon { font-size: 32px; opacity: 0.6; }

/* ========================
   Buttons
   ======================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition); white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ========================
   Forms
   ======================== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px; font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

/* ========================
   Tables
   ======================== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-secondary); }
thead th {
  padding: 14px 16px;
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }
td { padding: 14px 16px; font-size: 14px; color: var(--text-secondary); }
td.primary { color: var(--text-primary); font-weight: 500; }

/* ========================
   Badges
   ======================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-available { background: var(--success-bg); color: var(--success); }
.badge-checkedout { background: var(--warning-bg); color: var(--warning); }
.badge-admin { background: var(--accent-glow); color: var(--accent); }
.badge-staff { background: var(--info-bg); color: var(--info); }
.badge::before { content: '●'; font-size: 8px; }

/* ========================
   Modal
   ======================== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  z-index: 999; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 22px;
  transition: color var(--transition); line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ========================
   Search & Filters
   ======================== */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.search-wrapper { position: relative; flex: 1; min-width: 200px; }
.search-wrapper .search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 16px; color: var(--text-muted);
}
.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px; font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-muted); }

/* ========================
   Grid
   ======================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ========================
   Auth / Login
   ======================== */
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; position: relative;
  background: var(--bg-primary);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  animation: slideUp 0.5s ease;
}
.auth-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 0 30px var(--accent-glow);
}
.auth-logo h1 { font-size: 22px; font-weight: 800; }
.auth-logo p { font-size: 12px; color: var(--text-muted); }
.auth-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }
.auth-toggle { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-toggle a { color: var(--accent); font-weight: 600; }

/* ========================
   QR Code / Scan
   ======================== */
.scanner-container {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  overflow: hidden; background: var(--bg-secondary);
  min-height: 300px; display: flex;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
}
.scanner-placeholder { text-align: center; color: var(--text-muted); }
.scanner-placeholder .scan-icon { font-size: 56px; margin-bottom: 12px; }
#qr-reader { width: 100% !important; border: none !important; }
#qr-reader video { border-radius: var(--radius) !important; }

.asset-result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  animation: slideUp 0.3s ease;
}
.asset-result-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.asset-icon-circle {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent-glow), rgba(139,92,246,0.2));
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 24px; flex-shrink: 0;
}
.asset-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.meta-item label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.meta-item p { font-size: 14px; color: var(--text-primary); margin-top: 2px; }

/* QR Modal */
.qr-modal-body { text-align: center; }
.qr-image { width: 240px; height: 240px; border-radius: var(--radius); border: 2px solid var(--border); margin: 0 auto 16px; display: block; }
.qr-tag { font-family: monospace; font-size: 16px; font-weight: 700; color: var(--accent); background: var(--accent-glow); padding: 6px 16px; border-radius: 999px; display: inline-block; }

/* ========================
   Empty State
   ======================== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 52px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ========================
   Toast
   ======================== */
.toast-container {
  position: fixed; top: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 280px; max-width: 380px;
  animation: slideIn 0.3s ease;
  font-size: 14px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-msg { flex: 1; color: var(--text-primary); }
.toast-close { cursor: pointer; color: var(--text-muted); font-size: 16px; background: none; border: none; }

/* ========================
   Animations
   ======================== */
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideIn { from{opacity:0;transform:translateX(40px)} to{opacity:1;transform:translateX(0)} }

/* ========================
   Scrollbar
   ======================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========================
   Responsive
   ======================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-content { padding: 20px; }
  .topbar { padding: 16px 20px; }
}
