/* Signed-in page shell shared by the root, Admin and App layouts: left side navigation
   (Government of Karnataka emblem on top, Allvy at the bottom) + scrolling content area.
   Below 992px the sidebar becomes a Bootstrap off-canvas drawer opened from .kswan-mobilebar. */

:root {
  --kswan-sidebar-width: 264px;
  --kswan-primary: #0b5fa5;
  --kswan-primary-dark: #08447a;
  --kswan-primary-light: #e8f1fa;
  --kswan-ink: #1c2530;
  --kswan-ink-soft: #5b6b7c;
  --kswan-border: #dde3ea;
  --kswan-bg: #f4f6f9;
}

html, body {
  height: auto;
  min-height: 100%;
}

body.kswan-has-sidebar {
  display: block;
  background: var(--kswan-bg);
}

.kswan-layout {
  display: flex;
  min-height: 100vh;
}

.kswan-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.kswan-content {
  flex: 1 0 auto;
  width: 100%;
  padding: 1.5rem 1.75rem 2.5rem;
}

/* ---- Sidebar ------------------------------------------------------------------------------ */
.kswan-sidebar {
  --bs-offcanvas-width: 280px;
}

.kswan-sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--kswan-border);
}

@media (min-width: 992px) {
  .kswan-sidebar {
    flex: 0 0 var(--kswan-sidebar-width);
    width: var(--kswan-sidebar-width);
    position: sticky;
    top: 0;
    height: 100vh;
  }
}

.kswan-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.1rem 1rem;
  border-bottom: 1px solid var(--kswan-border);
  background: linear-gradient(180deg, var(--kswan-primary-light) 0%, #fff 100%);
}
.kswan-sidebar-brand img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  object-fit: contain;
}
.kswan-sidebar-brand .text {
  flex: 1 1 auto;
  min-width: 0;
}
.kswan-sidebar-brand .title {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--kswan-primary-dark);
  line-height: 1.2;
}
.kswan-sidebar-brand .sub {
  font-size: 0.75rem;
  color: var(--kswan-ink-soft);
  font-weight: 600;
}

.kswan-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 1rem;
}

.kswan-sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--kswan-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--kswan-ink);
  background: #fafbfc;
}
.kswan-sidebar-user:hover {
  border-color: var(--kswan-primary);
  color: var(--kswan-ink);
}
.kswan-sidebar-user .avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kswan-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  overflow: hidden;
}
.kswan-sidebar-user .avatar.has-photo {
  background: transparent;
  padding: 0;
}
.kswan-sidebar-user .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kswan-sidebar-user .who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.kswan-sidebar-user .name {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kswan-sidebar-user .role {
  font-size: 0.74rem;
  color: var(--kswan-ink-soft);
}

.kswan-sidebar-section {
  margin: 1rem 0.6rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a97a6;
}

.kswan-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.52rem 0.7rem;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--kswan-ink);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kswan-sidebar-link i {
  font-size: 1.05rem;
  width: 1.2rem;
  text-align: center;
  color: var(--kswan-ink-soft);
}
.kswan-sidebar-link:hover {
  background: #f1f4f8;
  color: var(--kswan-primary-dark);
}
.kswan-sidebar-link:hover i {
  color: var(--kswan-primary);
}
.kswan-sidebar-link.active {
  background: var(--kswan-primary-light);
  color: var(--kswan-primary-dark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--kswan-primary);
}
.kswan-sidebar-link.active i {
  color: var(--kswan-primary);
}
.kswan-sidebar-link.logout:hover {
  background: #fbeae8;
  color: #c0392b;
}
.kswan-sidebar-link.logout:hover i {
  color: #c0392b;
}
.kswan-sidebar-link:focus-visible {
  outline: 2px solid var(--kswan-primary);
  outline-offset: 1px;
}

/* ---- Collapsible menu groups (Checks & reports, User management, Settings, ...) ------------ */
.kswan-sidebar-group { margin-top: 0.15rem; }
.kswan-sidebar-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.52rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--kswan-ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
}
.kswan-sidebar-group-toggle > i:first-child {
  font-size: 1.05rem;
  width: 1.2rem;
  text-align: center;
  color: var(--kswan-ink-soft);
}
.kswan-sidebar-group-toggle .label { flex: 1 1 auto; min-width: 0; }
.kswan-sidebar-group-toggle .chev { font-size: 0.75rem; color: var(--kswan-ink-soft); transition: transform 0.15s ease; }
.kswan-sidebar-group-toggle.collapsed .chev { transform: rotate(-90deg); }
.kswan-sidebar-group-toggle:hover { background: var(--kswan-primary-light); color: var(--kswan-primary-dark); }
.kswan-sidebar-group-toggle:focus-visible { outline: 2px solid var(--kswan-primary); outline-offset: 1px; }
.kswan-sidebar-group[data-active="true"] > .kswan-sidebar-group-toggle,
.kswan-sidebar-group[data-active="true"] > .kswan-sidebar-group-toggle > i:first-child { color: var(--kswan-primary); }
/* The group's badge only matters while its items are hidden. */
.kswan-sidebar-group-toggle:not(.collapsed) .when-collapsed { display: none; }
.kswan-sidebar-group-items {
  margin: 0.1rem 0 0.35rem 1.25rem;
  padding-left: 0.45rem;
  border-left: 1px solid var(--kswan-border);
}
.kswan-sidebar-group-items .kswan-sidebar-link { font-size: 0.86rem; padding: 0.42rem 0.6rem; }

/* Count flag, e.g. users inactive for 3h+ on Employee presence. */
.kswan-sidebar-badge {
  margin-left: auto;
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #f79009;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.kswan-sidebar-footer {
  flex-shrink: 0;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--kswan-border);
  text-align: center;
}
.kswan-sidebar-footer span {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8a97a6;
  margin-bottom: 0.35rem;
}
.kswan-sidebar-footer img {
  max-width: 150px;
  height: auto;
}

/* ---- Small-screen top bar (opens the drawer) ------------------------------------------------ */
.kswan-mobilebar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: #fff;
  border-bottom: 1px solid var(--kswan-border);
  box-shadow: 0 1px 4px rgba(20, 30, 45, 0.06);
}
.kswan-mobilebar .menu-btn {
  border: 1px solid var(--kswan-border);
  background: #fff;
  border-radius: 8px;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: var(--kswan-primary-dark);
}
.kswan-mobilebar img {
  width: 34px;
  height: 34px;
}
.kswan-mobilebar .title {
  font-weight: 800;
  color: var(--kswan-primary-dark);
  line-height: 1.1;
}
.kswan-mobilebar .title small {
  display: block;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--kswan-ink-soft);
}

/* ---- Footer inside the content column ------------------------------------------------------- */
.kswan-main .kswan-footer {
  flex-shrink: 0;
  padding: 0.9rem 1.75rem;
  background: transparent;
  border-top: 1px solid var(--kswan-border);
  color: var(--kswan-ink-soft);
  font-size: 0.8rem;
}

@media (max-width: 576px) {
  .kswan-content {
    padding: 1rem 0.75rem 2rem;
  }
}

/* ---- Responsive tables -----------------------------------------------------------------------
   js/responsive-tables.js adds .is-stacked when a table's area is narrow (under 860px: phones, tablets,
   laptops where the sidebar leaves little room) or the table doesn't fit. Each row then becomes a card:
   the first column is the card title, every other cell shows its column name (data-label) and action
   buttons sit at the bottom. Without JavaScript the table simply scrolls sideways. Opt out: .no-stack */
.table-responsive > table.table.is-stacked {
  border: 0;
}
.table-responsive > table.table.is-stacked thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.table-responsive > table.table.is-stacked,
.table-responsive > table.table.is-stacked > tbody,
.table-responsive > table.table.is-stacked > tbody > tr,
.table-responsive > table.table.is-stacked > tbody > tr > td {
  display: block;
  width: 100%;
}
.table-responsive > table.table.is-stacked > tbody > tr {
  margin: 0 0 0.6rem;
  padding: 0.55rem 0.8rem;
  background: #fafbfc;
  border: 1px solid var(--kswan-border);
  border-radius: 10px;
}
.table-responsive > table.table.is-stacked > tbody > tr:last-child {
  margin-bottom: 0;
}
.table-responsive > table.table.is-stacked > tbody > tr > td {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0 !important;
  border: 0 !important;
  text-align: right !important;
  white-space: normal !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow-wrap: anywhere;
}
.table-responsive > table.table.is-stacked > tbody > tr > td::before {
  content: attr(data-label);
  flex: 0 0 auto;
  max-width: 45%;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--kswan-ink-soft);
}
.table-responsive > table.table.is-stacked > tbody > tr > td[data-label=""]::before {
  content: none;
}
/* The cell's content (wrapped by the script) sits right of the label; inputs take the remaining width. */
.table-responsive > table.table.is-stacked > tbody > tr > td > .cell-value {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}
.table-responsive > table.table.is-stacked > tbody > tr > td > .cell-value > .form-control,
.table-responsive > table.table.is-stacked > tbody > tr > td > .cell-value > .form-select {
  margin-left: auto;
  max-width: 16rem;
}
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-title {
  display: block;
  padding-bottom: 0.4rem !important;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--kswan-border) !important;
  text-align: left !important;
  font-weight: 600;
}
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-title::before,
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-actions::before,
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-full::before {
  content: none;
}
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.3rem;
  padding-top: 0.5rem !important;
  border-top: 1px solid var(--kswan-border) !important;
}
.table-responsive > table.table.is-stacked > tbody > tr > td.cell-full {
  display: block;
  text-align: center !important;
}
/* Wide card lists (e.g. a 10-column table on a laptop): fields in two columns. */
.table-responsive > table.table.is-stacked.is-wide > tbody > tr {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 2.5rem;
}
.table-responsive > table.table.is-stacked.is-wide > tbody > tr > td.cell-title,
.table-responsive > table.table.is-stacked.is-wide > tbody > tr > td.cell-actions,
.table-responsive > table.table.is-stacked.is-wide > tbody > tr > td.cell-full {
  grid-column: 1 / -1;
}

/* ---- Field-app-only web landing (non–SuperAdmin/Admin) ------------------------------------ */
.kswan-field-app {
  display: flex;
  justify-content: center;
  padding: 1.25rem 0 2rem;
}
.kswan-field-app-card {
  position: relative;
  width: min(100%, 36rem);
  padding: 2rem 1.75rem 1.75rem;
  border: 1px solid var(--kswan-border);
  border-radius: 18px;
  background: var(--kswan-surface, #fff);
  box-shadow: var(--kswan-shadow, 0 8px 24px rgba(16, 24, 40, 0.06));
  text-align: center;
}
.kswan-field-lang-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--kswan-border);
  border-radius: 999px;
  background: var(--kswan-bg, #f4f6f9);
}
.kswan-field-lang-toggle button {
  min-width: 44px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kswan-ink-soft);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.kswan-field-lang-toggle button:hover { color: var(--kswan-primary); }
.kswan-field-lang-toggle button.is-active {
  background: var(--kswan-primary);
  color: #fff;
}
.kswan-field-app-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--kswan-primary-light, #e8f1fa);
  color: var(--kswan-primary, #0b5fa5);
  font-size: 1.6rem;
}
.kswan-field-app-title {
  margin: 0 0 0.65rem;
  padding-right: 6.5rem;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--kswan-ink, #1c2530);
  line-height: 1.25;
}
.kswan-field-app-lead {
  margin: 0 auto 1.35rem;
  max-width: 30rem;
  color: var(--kswan-ink-soft, #5b6b7c);
  font-size: 0.95rem;
  line-height: 1.5;
}
.kswan-play-badge {
  display: inline-block;
  line-height: 0;
  margin-bottom: 1.35rem;
}
.kswan-play-badge img {
  height: 56px;
  width: auto;
  max-width: 100%;
}
.kswan-play-badge .kswan-play-dark { display: none; }
html[data-bs-theme="dark"] .kswan-play-badge .kswan-play-light { display: none; }
html[data-bs-theme="dark"] .kswan-play-badge .kswan-play-dark { display: inline-block; }
.kswan-field-app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}
