/* ------------------------------------------------------------------
   Temple Management System - application shell
   ------------------------------------------------------------------
   Layers a simple two-part layout (fixed sidebar + sticky topbar) on top
   of the MatDash theme in styles.css. Every colour below is taken from a
   MatDash CSS variable, so the app stays visually consistent with the
   reference design while keeping a much simpler DOM than MatDash's own
   two-column mini-nav sidebar.
   ------------------------------------------------------------------ */

:root {
  --tms-sidebar-width: 260px;
  --tms-topbar-height: 64px;
  --tms-sidebar-bg: #ffffff;
  --tms-shell-bg: var(--bs-light-gray, #f4f7fb);
  --tms-malayalam-font: "Noto Sans Malayalam", "Manjari", "Meera",
    "AnjaliOldLipi", var(--bs-font-sans-serif);
}

body {
  background: var(--tms-shell-bg);
  min-height: 100vh;
}

/* Malayalam glyphs need a script-capable face; Manrope has no coverage. */
.ml,
[lang="ml"] {
  font-family: var(--tms-malayalam-font);
}

/* ------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------ */
.tms-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--tms-sidebar-width);
  background: var(--tms-sidebar-bg);
  border-right: 1px solid var(--bs-border-color);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.25s ease-in-out;
}

.tms-sidebar__brand {
  height: var(--tms-topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--bs-border-color);
  flex: 0 0 auto;
}

.tms-sidebar__brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bs-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: 0 0 auto;
}

.tms-sidebar__brand-text {
  min-width: 0;
}

.tms-sidebar__brand-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--bs-heading-color);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tms-sidebar__brand-sub {
  font-size: 0.6875rem;
  color: var(--bs-gray-400);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tms-sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px 24px;
}

.tms-nav-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bs-gray-400);
  padding: 18px 12px 6px;
}

.tms-nav-heading:first-child {
  padding-top: 4px;
}

.tms-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--bs-gray-500);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.tms-nav-link i {
  font-size: 1.125rem;
  flex: 0 0 auto;
}

.tms-nav-link:hover {
  background: var(--bs-light);
  color: var(--bs-heading-color);
}

.tms-nav-link.is-active {
  background: var(--bs-primary);
  color: #fff;
}

.tms-nav-link.is-active:hover {
  color: #fff;
}

.tms-nav-link__badge {
  margin-left: auto;
  font-size: 0.6875rem;
}

/* ------------------------------------------------------------------
   Topbar + content
   ------------------------------------------------------------------ */
.tms-main {
  margin-left: var(--tms-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tms-topbar {
  height: var(--tms-topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.tms-topbar__title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--bs-heading-color);
  margin: 0;
  line-height: 1.2;
}

.tms-topbar__subtitle {
  font-size: 0.75rem;
  color: var(--bs-gray-400);
}

.tms-topbar__spacer {
  flex: 1 1 auto;
}

.tms-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary);
  display: grid;
  place-items: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex: 0 0 auto;
}

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

.tms-sidebar-backdrop {
  display: none;
}

/* ------------------------------------------------------------------
   Shared page furniture
   ------------------------------------------------------------------ */
.tms-page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Empty-state block shown when a filtered table returns nothing. */
.tms-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--bs-gray-400);
}

.tms-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Dense table tuned for master-data lists. */
.tms-table {
  margin-bottom: 0;
}

.tms-table > :not(caption) > * > * {
  padding: 12px 16px;
}

.tms-table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--bs-gray-400);
  background: var(--bs-light);
  border-bottom: 1px solid var(--bs-border-color);
  white-space: nowrap;
}

.tms-table tbody td {
  vertical-align: middle;
  color: var(--bs-gray-500);
}

.tms-table .tms-cell-primary {
  color: var(--bs-heading-color);
  font-weight: 600;
}

/* Secondary Malayalam line under an English name. */
.tms-cell-sub {
  font-size: 0.8125rem;
  color: var(--bs-gray-400);
  font-family: var(--tms-malayalam-font);
}

.tms-stat-card .tms-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--bs-heading-color);
  line-height: 1.2;
}

.tms-stat-card .tms-stat-label {
  font-size: 0.8125rem;
  color: var(--bs-gray-400);
}

.tms-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  flex: 0 0 auto;
}

/* Required-field marker on form labels. */
.form-label .req {
  color: var(--bs-danger);
  margin-left: 2px;
}

/* Diff rendering in the audit log detail view. */
.tms-diff-old {
  color: var(--bs-danger);
  text-decoration: line-through;
  word-break: break-word;
}

.tms-diff-new {
  color: var(--bs-success);
  word-break: break-word;
}

/* ------------------------------------------------------------------
   Auth screen
   ------------------------------------------------------------------ */
.tms-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bs-primary-bg-subtle), transparent 70%),
    var(--tms-shell-bg);
}

.tms-auth__card {
  width: 100%;
  max-width: 420px;
}

/* ------------------------------------------------------------------
   Responsive: the sidebar becomes an off-canvas drawer below 992px
   ------------------------------------------------------------------ */
@media (max-width: 991.98px) {
  .tms-sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  }

  body.tms-sidebar-open .tms-sidebar {
    transform: translateX(0);
  }

  body.tms-sidebar-open .tms-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 37, 64, 0.4);
    z-index: 1035;
  }

  .tms-main {
    margin-left: 0;
  }

  .tms-content {
    padding: 16px;
  }

  .tms-topbar {
    padding: 0 16px;
  }
}

/* ------------------------------------------------------------------
   Print: drop the shell so receipts and reports use the full page
   ------------------------------------------------------------------ */
@media print {
  .tms-sidebar,
  .tms-topbar,
  .tms-no-print {
    display: none !important;
  }

  .tms-main {
    margin-left: 0;
  }

  .tms-content {
    padding: 0;
  }

  body {
    background: #fff;
  }
}
