/* ============================================================
   ITAM Pro v2 — Main Stylesheet  (Dark + Light Theme)
   Pacific Associates Ltd. | Dhaka, Bangladesh
   ============================================================ */

:root,
[data-theme="dark"] {
  --bg:           #0a0e1a;
  --surface:      #111827;
  --card:         #151e2d;
  --border:       #1e2d42;
  --accent:       #00d4ff;
  --accent2:      #0066ff;
  --green:        #00e5a0;
  --amber:        #ffb800;
  --red:          #ff4757;
  --purple:       #8b5cf6;
  --text:         #e8f0fe;
  --text-muted:   #7b8fa6;
  --sidebar-w:    230px;
  --radius:       10px;
  --topbar-bg:    #111827;
  --input-bg:     #111827;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
}

[data-theme="light"] {
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --card:         #ffffff;
  --border:       #d1dbe8;
  --accent:       #0066ff;
  --accent2:      #0052cc;
  --green:        #00a870;
  --amber:        #d97706;
  --red:          #dc2626;
  --purple:       #7c3aed;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --topbar-bg:    #ffffff;
  --input-bg:     #f8fafc;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
}

*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  transition: background-color .2s, border-color .2s, color .15s;
}

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

a { color: inherit; text-decoration: none; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .25s, background-color .2s, border-color .2s;
  overflow: hidden; position: sticky; top: 0; height: 100vh;
  box-shadow: var(--shadow);
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .sidebar-brand { padding: 18px 14px; justify-content: center; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.brand-name { font-size: 13px; font-weight: 800; color: var(--text); }
.brand-org  { font-size: 10px; color: var(--text-muted); }

.sidebar-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 2px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent; white-space: nowrap;
}
.nav-item:hover { background: rgba(0,102,255,.08); color: var(--accent); }
[data-theme="light"] .nav-item:hover { background: rgba(0,102,255,.06); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(0,102,255,.15), rgba(0,212,255,.06));
  border-left-color: var(--accent); color: var(--accent); font-weight: 700;
}
.nav-icon { font-size: 16px; flex-shrink: 0; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px; border-top: 1px solid var(--border); font-size: 12px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0;
}
.user-name { font-weight: 700; color: var(--text); font-size: 12px; }
.user-role { color: var(--text-muted); font-size: 10px; }
.logout-btn { margin-left: auto; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px; border-radius: 6px; }
.logout-btn:hover { color: var(--red); background: rgba(255,71,87,.1); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--topbar-bg); position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left  { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.sidebar-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 7px 11px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }
.page-title { font-size: 18px; font-weight: 800; color: var(--text); }

/* ── Topbar buttons ──────────────────────────────────────── */
.topbar-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-muted); cursor: pointer; font-size: 17px; text-decoration: none;
  flex-shrink: 0;
}
.topbar-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

.alert-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--topbar-bg); pointer-events: none;
  animation: pulse-badge .8s ease infinite alternate;
}
@keyframes pulse-badge { from { transform: scale(1); } to { transform: scale(1.15); } }

/* Theme toggle pill */
.theme-pill {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px; cursor: pointer;
}
.theme-option {
  width: 28px; height: 28px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-muted); border: none; background: none;
  cursor: pointer;
}
.theme-option.active {
  background: var(--card); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.date-chip {
  font-size: 12px; color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; white-space: nowrap;
}

.page-body { padding: 28px; }

/* ── Flash alerts ─────────────────────────────────────────── */
.alert { padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.alert-success { background: rgba(0,229,160,.12); border: 1px solid rgba(0,229,160,.3); color: var(--green); }
.alert-error   { background: rgba(255,71,87,.12);  border: 1px solid rgba(255,71,87,.3);  color: var(--red); }
.alert-warning { background: rgba(255,184,0,.12);  border: 1px solid rgba(255,184,0,.3);  color: var(--amber); }

/* ── KPI / Stat cards ─────────────────────────────────────── */
.stats-grid { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-grid   { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }

.stat-card,
.kpi-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; flex: 1; min-width: 140px;
  position: relative; overflow: hidden;
}
.stat-icon,
.kpi-icon { position: absolute; top: -8px; right: -8px; font-size: 44px; opacity: .07; }
.stat-label,
.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
.stat-value,
.kpi-value { font-size: 28px; font-weight: 800; margin: 6px 0 2px; }
.stat-sub,
.kpi-sub   { font-size: 11px; color: var(--text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 20px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap,
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--surface); }
[data-theme="light"] thead tr { background: #f8fafc; }
th { padding: 11px 13px; text-align: left; color: var(--text-muted); font-weight: 600; font-size: 11px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 13px; border-bottom: 1px solid rgba(30,45,66,.5); vertical-align: middle; }
[data-theme="light"] td { border-bottom-color: #e8eef5; }
tr:hover td { background: rgba(0,102,255,.03); }
tr:nth-child(even) td { background: rgba(17,24,39,.3); }
[data-theme="light"] tr:nth-child(even) td { background: rgba(0,102,255,.015); }

.td-id   { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); font-weight: 700; }
.td-name { font-weight: 600; color: var(--text); }
.td-muted { color: var(--text-muted); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block; border-radius: 4px;
  padding: 2px 9px; font-size: 11px; font-weight: 700; letter-spacing: .4px;
}
.badge-active   { background: rgba(0,229,160,.15);  color: var(--green);       border: 1px solid rgba(0,229,160,.3); }
.badge-assigned { background: rgba(0,212,255,.15);  color: var(--accent);      border: 1px solid rgba(0,212,255,.3); }
.badge-storage  { background: rgba(255,184,0,.15);  color: var(--amber);       border: 1px solid rgba(255,184,0,.3); }
.badge-repair   { background: rgba(139,92,246,.15); color: var(--purple);      border: 1px solid rgba(139,92,246,.3); }
.badge-expired  { background: rgba(255,71,87,.15);  color: var(--red);         border: 1px solid rgba(255,71,87,.3); }
.badge-expiring { background: rgba(255,184,0,.15);  color: var(--amber);       border: 1px solid rgba(255,184,0,.3); }
.badge-disposed { background: rgba(100,116,139,.15);color: var(--text-muted);  border: 1px solid rgba(100,116,139,.2); }
.badge-inactive { background: rgba(100,116,139,.15);color: var(--text-muted);  border: 1px solid rgba(100,116,139,.2); }

/* ── Forms ────────────────────────────────────────────────── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

input[type=text], input[type=date], input[type=number],
input[type=email], input[type=password], select, textarea {
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 13px; color: var(--text); font-size: 13px;
  width: 100%; outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(0,102,255,.1); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; text-decoration: none; line-height: 1;
}
.btn:hover { opacity: .88; }
.btn-primary   { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }
.btn-success   { background: rgba(0,229,160,.15); border: 1px solid rgba(0,229,160,.35); color: var(--green); }
.btn-danger    { background: rgba(255,71,87,.12);  border: 1px solid rgba(255,71,87,.3);  color: var(--red); }
.btn-secondary { background: var(--surface);       border: 1px solid var(--border);        color: var(--text-muted); }
.btn-ghost     { background: transparent;           border: 1px solid transparent;          color: var(--text-muted); }
.btn-sm  { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; border-radius: 5px; }
.btn-icon{ width: 32px; height: 32px; padding: 0; border-radius: 6px; }

/* ── Filters ──────────────────────────────────────────────── */
.filters,
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px; align-items: center;
}
.filters input, .filters select,
.filter-bar input, .filter-bar select { flex: 1; min-width: 180px; max-width: 280px; }

/* ── Progress bars ────────────────────────────────────────── */
.progress-bar-wrap,
.progress-wrap { flex: 1; background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 4px; }

.bar-row   { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { font-size: 12px; color: var(--text-muted); width: 100px; flex-shrink: 0; }
.bar-value,.bar-val { font-size: 12px; font-weight: 700; width: 70px; text-align: right; flex-shrink: 0; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px); padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; width: 720px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity:0; transform:translateY(-12px) scale(.97); } to { opacity:1; transform:none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title  { font-size: 18px; font-weight: 800; color: var(--text); }
.modal-close  {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 18px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--red); border-color: var(--red); }

/* ── Tab nav ──────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 5px; margin-bottom: 22px; flex-wrap: wrap;
}
.tab-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 7px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); text-decoration: none; border: 1px solid transparent;
}
.tab-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab-item.active { background: var(--card); color: var(--accent); font-weight: 700; border-color: var(--border); }

/* ── Login ────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.login-left {
  background: linear-gradient(135deg, var(--accent2) 0%, var(--accent) 100%);
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; padding: 60px; text-align: center; position: relative; overflow: hidden;
}
.login-left::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
}
.login-hero-icon {
  width: 80px; height: 80px; background: rgba(255,255,255,.15); border-radius: 24px;
  display: flex; align-items: center; justify-content: center; font-size: 38px;
  margin-bottom: 28px; border: 1px solid rgba(255,255,255,.2); position: relative; z-index: 1;
}
.login-hero-title { font-size: 30px; font-weight: 800; color: #fff; margin-bottom: 10px; position: relative; z-index: 1; }
.login-hero-sub   { font-size: 14px; color: rgba(255,255,255,.7); position: relative; z-index: 1; max-width: 300px; line-height: 1.7; }
.login-features   { margin-top: 40px; display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; text-align: left; }
.login-feat       { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.8); font-size: 13px; }
.login-feat-icon  { width: 28px; height: 28px; background: rgba(255,255,255,.15); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.login-right      { display: flex; align-items: center; justify-content: center; padding: 60px; }
.login-card       { width: 100%; max-width: 400px; }
.login-card-title { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.login-card-sub   { font-size: 13.5px; color: var(--text-muted); margin-bottom: 32px; }

.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: rgba(0,229,160,.1);  border-color: rgba(0,229,160,.25); color: var(--green); }
.flash-error   { background: rgba(255,71,87,.1);  border-color: rgba(255,71,87,.25); color: var(--red); }
.flash-warning { background: rgba(255,184,0,.1);  border-color: rgba(255,184,0,.25); color: var(--amber); }

@media (max-width: 768px) {
  .login-bg { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { padding: 32px 24px; }
}

/* ── Utilities ────────────────────────────────────────────── */
.text-accent  { color: var(--accent); }  .text-green  { color: var(--green); }
.text-amber   { color: var(--amber); }   .text-red    { color: var(--red); }
.text-purple  { color: var(--purple); }  .text-muted  { color: var(--text-muted); }
.text-sub     { color: var(--text-muted); }
.fw-bold,.fw-600,.fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.font-mono    { font-family: 'JetBrains Mono', monospace; }
.fs-11        { font-size: 11px; } .fs-12 { font-size: 12px; }
.mb-0         { margin-bottom: 0 !important; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.d-flex       { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar .brand-text, .sidebar .nav-label, .sidebar .user-info { display: none; }
  .page-body { padding: 16px; }
  .date-chip { display: none; }
}
