/* ============================================================
   Asset Manager - Main Stylesheet
   ============================================================ */

:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --secondary: #764ba2;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --dark: #1a1f2e;
  --sidebar-bg: #1a1f2e;
  --sidebar-width: 260px;
  --header-height: 64px;
  --bg: #f0f2f7;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
}

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

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

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s;
}

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

.topbar {
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo h2 { color: #fff; font-size: 16px; font-weight: 700; }
.sidebar-logo p { color: rgba(255,255,255,.45); font-size: 11px; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section { padding: 8px 16px 4px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
  transition: all .15s;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-size: 13.5px;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: 0 4px 12px rgba(102,126,234,.35); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.06);
  border-radius: 8px;
}

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

.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,.4); font-size: 11px; }

.btn-logout {
  margin-left: auto;
  background: none; border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer; padding: 4px;
  border-radius: 4px; transition: color .2s;
}
.btn-logout:hover { color: var(--danger); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-title span { color: var(--primary); }
.topbar-search { display: flex; align-items: center; gap: 8px; }
.topbar-search input {
  padding: 8px 14px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  width: 240px;
  background: var(--bg);
  transition: all .2s;
}
.topbar-search input:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-icon { position: relative; }
.search-icon svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* ============================================================
   CARDS & STATS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px;
}

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

.stat-icon.blue { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: #f0fdf4; color: #10b981; }
.stat-icon.orange { background: #fff7ed; color: #f59e0b; }
.stat-icon.purple { background: #faf5ff; color: #8b5cf6; }
.stat-icon.red { background: #fef2f2; color: #ef4444; }

.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { background: #f3f4f6; color: var(--text); }
thead th.sorted { color: var(--primary); }
thead th.sorted::after { content: ' ↑'; }
thead th.sorted.desc::after { content: ' ↓'; }

tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background .1s;
}

tbody tr:hover { background: #f8faff; }

tbody td {
  padding: 11px 14px;
  vertical-align: middle;
}

tbody tr:last-child { border-bottom: none; }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #059669; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #dbeafe; color: #2563eb; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }
.badge-purple  { background: #ede9fe; color: #7c3aed; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: 0 2px 8px rgba(102,126,234,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(102,126,234,.4); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f8faff; }
.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--danger); }

.form-control {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102,126,234,.12); }
.form-control:disabled { background: #f9fafb; color: var(--text-muted); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center; justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}

.modal-lg { max-width: 900px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; }
.modal-body  { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

.btn-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.btn-close:hover { color: var(--danger); background: #fee2e2; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 16px;
}

.filter-bar .form-group { min-width: 160px; flex: 1; max-width: 220px; }
.filter-bar .btn { align-self: flex-end; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.page-info { color: var(--text-muted); font-size: 13px; flex: 1; }

.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: flex; align-items: center; gap: 10px;
  min-width: 260px;
  animation: toastIn .25s ease;
  border-left: 4px solid var(--success);
}
.toast.error  { border-color: var(--danger); }
.toast.warning{ border-color: var(--warning); }

@keyframes toastIn { from { opacity:0; transform:translateX(30px); } to { opacity:1; transform:none; } }

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-container { padding: 20px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 2px; background: #f3f4f6; border-radius: 10px; padding: 3px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 8px 12px; text-align: center;
  border-radius: 8px; cursor: pointer; border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: all .15s;
}
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; opacity: .3; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }

/* ============================================================
   LOADING
   ============================================================ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; border-radius: var(--radius);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar .form-group { max-width: 100%; }
  .topbar-search input { width: 160px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'Consolas', monospace; font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.w-full { width: 100%; }
