/* License Management System - application shell + component styles */

:root {
  --sidebar-w: 250px;
  --sidebar-bg: #101828;
  --sidebar-fg: #cbd5e1;
  --sidebar-active: #2563eb;
  --topbar-h: 60px;
  --border: #e5e7eb;
  --surface: #ffffff;
  --page-bg: #f6f7f9;
}

body {
  background: var(--page-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  color: #1f2937;
}

/* ---------------------------------------------------------------- Shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff; font-weight: 600;
}
.brand-mark { font-size: 1.35rem; }
.brand-text { font-size: .95rem; line-height: 1.2; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }

.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: .92rem;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar-footer { padding: .85rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sidebar-active); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { color: #fff; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.role-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.role-admin   { color: #fca5a5; }
.role-manager { color: #93c5fd; }
.role-viewer  { color: #94a3b8; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.topbar-right { margin-left: auto; }
.clock { font-size: .85rem; color: #6b7280; font-variant-numeric: tabular-nums; }

.content { padding: 1.5rem 1.25rem; flex: 1; }
.app-footer {
  display: flex; justify-content: space-between;
  padding: .75rem 1.25rem;
  font-size: .78rem; color: #9ca3af;
  border-top: 1px solid var(--border);
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .main { margin-left: 0; }
}

/* ---------------------------------------------------------------- Cards */
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}

/* Dashboard stat tiles */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: .9rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .15rem;
  position: relative; overflow: hidden;
  text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .12s;
}
a.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.08); color: inherit; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, #2563eb); }
.stat-value { font-size: 1.75rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.stat-sub { font-size: .75rem; color: #9ca3af; }

.stat-total     { --accent: #2563eb; }
.stat-available { --accent: #16a34a; }
.stat-inuse     { --accent: #0891b2; }
.stat-expired   { --accent: #dc2626; }
.stat-disabled  { --accent: #6b7280; }
.stat-lost      { --accent: #111827; }

/* Expiry countdown chips */
.bucket-grid { display: flex; flex-wrap: wrap; gap: .55rem; }
.bucket {
  flex: 1 1 90px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .7rem .5rem;
  text-align: center;
  text-decoration: none; color: inherit;
  background: var(--surface);
  transition: border-color .12s, background .12s;
}
.bucket:hover { border-color: #2563eb; color: inherit; }
.bucket-n { display: block; font-size: 1.4rem; font-weight: 650; line-height: 1.1; }
.bucket-d { font-size: .74rem; color: #6b7280; }
.bucket.warn  { background: #fffbeb; border-color: #fde68a; }
.bucket.warn .bucket-n { color: #b45309; }
.bucket.crit  { background: #fef2f2; border-color: #fecaca; }
.bucket.crit .bucket-n { color: #b91c1c; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
.table { margin-bottom: 0; font-size: .88rem; }
.table > thead > tr > th {
  background: #f9fafb;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: #6b7280; font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table > tbody > tr > td { vertical-align: middle; }
.table-hover > tbody > tr:hover > td { background: #f8fafc; }

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: .84em; }
.key-cell { display: inline-flex; align-items: center; gap: .4rem; }
.key-cell .btn { --bs-btn-padding-y: .05rem; --bs-btn-padding-x: .35rem; --bs-btn-font-size: .72rem; }

.days-left { font-weight: 600; font-variant-numeric: tabular-nums; }
.days-ok   { color: #16a34a; }
.days-warn { color: #d97706; }
.days-crit { color: #dc2626; }
.days-past { color: #991b1b; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #9ca3af; }
.empty-state svg { width: 44px; height: 44px; opacity: .35; margin-bottom: .75rem; }

/* Filter bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .85rem;
  margin-bottom: 1rem;
}
.filter-bar .form-select, .filter-bar .form-control { font-size: .87rem; }

.form-label { font-size: .84rem; font-weight: 500; color: #374151; margin-bottom: .25rem; }
.form-text  { font-size: .78rem; }
.required::after { content: " *"; color: #dc2626; }

/* Audit diff */
.diff-table { font-size: .8rem; }
.diff-old { color: #b91c1c; background: #fef2f2; }
.diff-new { color: #15803d; background: #f0fdf4; }

/* ---------------------------------------------------------------- Auth */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-content: center; justify-items: center;
  gap: 1rem; padding: 2rem 1rem;
  background: linear-gradient(160deg, #101828 0%, #1e3a8a 100%);
}
.auth-card {
  background: #fff;
  width: min(420px, 92vw);
  padding: 2rem;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand .brand-mark { font-size: 2rem; }
.auth-brand h1 { font-size: 1.15rem; font-weight: 600; margin: .4rem 0 0; }
.auth-foot { color: rgba(255,255,255,.55); font-size: .8rem; margin: 0; }

/* Password strength meter */
.pw-meter { height: 4px; border-radius: 2px; background: #e5e7eb; overflow: hidden; margin-top: .4rem; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* Charts keep a fixed box so Chart.js does not grow on every resize. */
.chart-box { position: relative; height: 280px; }

@media print {
  .sidebar, .topbar, .app-footer, .filter-bar, .btn, .pagination { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
}
