/* ============================================================
   MPMS Application Styles — Anjali Labtech Ltd.
   ============================================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 68px;
  --sidebar-bg: #16213e;
  --sidebar-hover-bg: rgba(255,255,255,.07);
  --sidebar-active-bg: #4e73df;
  --sidebar-text: #c0c9e8;
  --sidebar-heading: rgba(255,255,255,.35);
  --topbar-bg: #4e73df;
  --topbar-height: 58px;
  --primary: #4e73df;
  --success: #1cc88a;
  --warning: #f6c23e;
  --danger: #e74a3b;
  --card-shadow: 0 .125rem 1rem rgba(0,0,0,.075);
}

/* ── Layout ──────────────────────────────────────────────── */

body { font-size: .875rem; }

#wrapper { min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
}

.sidebar-brand-icon {
  font-size: 1.4rem;
  color: var(--sidebar-active-bg);
  min-width: 36px;
  text-align: center;
}

.sidebar-brand-text { font-size: .8rem; color: #fff; letter-spacing: .04em; }

/* Section headings */
.sidebar-heading {
  padding: .65rem 1rem .25rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-heading);
  white-space: nowrap;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-heading { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Nav links */
.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  font-size: .82rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
  gap: .6rem;
}

.sidebar-nav .nav-link i.fa-fw { min-width: 1.25rem; text-align: center; font-size: .85rem; }

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: var(--sidebar-hover-bg);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: var(--sidebar-active-bg);
}

/* Collapsed state: hide text */
#sidebar.collapsed .sidebar-nav .nav-link span { display: none; }
#sidebar.collapsed .sidebar-nav .nav-link { justify-content: center; gap: 0; padding: .6rem; }
#sidebar.collapsed .sidebar-brand-text { display: none; }

/* ── Topbar ──────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-height);
  background: linear-gradient(90deg, var(--topbar-bg) 0%, #224abe 100%);
  flex-shrink: 0;
}

/* ── User avatar ─────────────────────────────────────────── */

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  color: #fff;
  flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  border: none;
  border-radius: .5rem;
  box-shadow: var(--card-shadow);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e8ecf5;
  font-weight: 600;
  font-size: .85rem;
  padding: .85rem 1.25rem;
}

/* ── KPI Cards ───────────────────────────────────────────── */

.kpi-card { border-left: 4px solid; border-radius: .4rem; }
.kpi-card.kpi-primary { border-left-color: var(--primary); }
.kpi-card.kpi-success { border-left-color: var(--success); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-danger  { border-left-color: var(--danger);  }

.kpi-value  { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.kpi-label  { font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #858796; }
.kpi-icon   { font-size: 2rem; color: #e0e3ef; }

/* ── Tables ──────────────────────────────────────────────── */

.table th {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #5a5c69;
  background: #f8f9fc;
  border-bottom: 2px solid #e3e6f0;
  white-space: nowrap;
}

.table-hover tbody tr:hover { background-color: #f0f4ff; }

/* ── Badges ──────────────────────────────────────────────── */

.badge-active      { background-color: #1cc88a; color: #fff; }
.badge-inactive    { background-color: #858796; color: #fff; }
.badge-maintenance { background-color: #f6c23e; color: #333; }
.badge-open        { background-color: #4e73df; color: #fff; }
.badge-closed      { background-color: #1cc88a; color: #fff; }
.badge-draft       { background-color: #858796; color: #fff; }

/* ── Forms ───────────────────────────────────────────────── */

.form-label { font-size: .8rem; font-weight: 600; color: #444; margin-bottom: .3rem; }
.form-control, .form-select { font-size: .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(78,115,223,.2); }

.required-star::after { content: ' *'; color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: .78rem; }

/* ── Page header ─────────────────────────────────────────── */

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; color: #2d3561; margin: 0; }
.page-header .subtitle { font-size: .8rem; color: #858796; margin-top: .15rem; }

/* ── Footer ──────────────────────────────────────────────── */

.footer { font-size: .75rem; flex-shrink: 0; }

/* ── HTMX ────────────────────────────────────────────────── */

.htmx-indicator { display: none !important; }
.htmx-request .htmx-indicator { display: inline-block !important; }
.htmx-swapping { opacity: .5; transition: opacity .2s; }

/* ── Responsive: mobile sidebar overlay ─────────────────── */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    z-index: 1045;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease, width .25s ease;
  }

  #sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  #content-wrapper { width: 100%; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1044;
  }

  .sidebar-overlay.show { display: block; }
}

/* ── Utilities ───────────────────────────────────────────── */

.text-primary-custom { color: var(--primary) !important; }
.bg-sidebar          { background: var(--sidebar-bg) !important; }
.cursor-pointer      { cursor: pointer; }
.transition-all      { transition: all .2s; }
