/* lk-go layout + tweaks layered on top of Bootstrap 5.3.3
 * (template/static/css/bootstrap.min.css). Keep Bootstrap's utilities where
 * they suffice; this file only holds the bits Bootstrap doesn't provide. */

body.logged-in {
  background: #f1f4f9;
}

/* Sidebar + content shell for authenticated users. The shell is pinned to the
 * viewport: the sidebar keeps a static viewport height while the main content
 * column scrolls internally, so the sidebar (and its bottom logout) never
 * scroll out of view. */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1f2d3d;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease;
}

/* Collapsed state driven by sidebar.js (topbar toggle, persisted to localStorage):
 * narrows to an icon-only rail rather than disappearing, so navigation stays
 * reachable. The class lives on <html> (set by an inline head script in
 * main.html before first paint) so a reload renders already-collapsed with no
 * expanded-then-collapsed flash. */
html.sidebar-collapsed .app-shell .sidebar {
  width: 64px;
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-mark {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
}

html.sidebar-collapsed .app-shell .sidebar-brand {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-nav .nav-link {
  color: #c8d0d9;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.sidebar-nav-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.sidebar-collapsed .app-shell .sidebar-brand-text,
html.sidebar-collapsed .app-shell .sidebar-nav-label {
  display: none;
}

html.sidebar-collapsed .app-shell .sidebar-nav .nav-link {
  justify-content: center;
  padding: 0.65rem 0;
}

/* Logout pinned to the bottom of the sidebar. It lives inside .sidebar-nav so
 * it inherits the exact nav-link hit-box and hover styling of the other items
 * (full-width clickable row, same padding); only the <button> UA chrome and
 * the pin-to-bottom need their own rules. */
.sidebar-logout {
  margin-top: auto;
  margin-bottom: 0;
}

.sidebar-logout-btn {
  width: 100%;
  background: none;
  border: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e3e6ea;
}

.topbar-user {
  color: #4b5563;
}

/* Editable values (see template/static/js/editable.js) look clickable */
[data-editable-url] {
  border-bottom: 1px dashed rgba(13, 110, 253, 0.5);
  cursor: pointer;
  min-height: 1.5rem;
}

[data-editable-url]:hover {
  background: #eef4ff;
}

[data-editable-url] input,
[data-editable-url] textarea {
  width: 100%;
}

/* Guest pages: centered narrow column instead of the sidebar shell */
body.guest {
  background: linear-gradient(180deg, #eef2f7, #f7f9fc);
  min-height: 100vh;
}

body.guest main {
  max-width: 520px;
  margin: 2rem auto;
}

/* Definition lists on the point/server detail pages */
.dl-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.dl-cards dt {
  color: #6b7280;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.dl-cards dd {
  margin-bottom: 0;
}

/* Dashboard / report menu cards */
.card-link {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card-link:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* Dashboard tile icons (index.html): stroke-style SVGs, same glyphs as the
 * sidebar, sized larger to read at card-body scale */
.dashboard-card-icon {
  width: 1.75rem;
  height: 1.75rem;
  margin-bottom: 0.5rem;
}

/* check-status.js badges (point_view.html) */
.status-ok {
  color: #198754;
}

.status-fail {
  color: #dc3545;
}

/* Chart legend (server_view.html — device-count buckets) */
.chart-legend {
  display: flex;
  gap: 1.25rem;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.chart-legend-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

/* Recheck button next to the ssh/ping status (check-status.js) */
.btn-recheck {
  line-height: 0.9;
  padding: 0.2rem 0.35rem;
  margin-left: 0.5rem;
}

.icon-recheck {
  width: 0.9rem;
  height: 0.9rem;
  display: block;
}

/* Table-header filter rows (e.g. /devices): compact controls under each column */
.table-filter-row th {
  vertical-align: top;
  background: #f8f9fa;
}

.table-filter-row .form-control,
.table-filter-row .form-select {
  width: 100%;
}

.table-filter-row select {
  max-width: 14rem;
}

.table-filter-row .date-range-picker {
  display: block;
}

/* Date-range picker popover (date-range-picker.js) */
.date-range-picker {
  position: relative;
  display: inline-block;
}

.date-range-picker-input {
  cursor: pointer;
  background-color: #fff;
}

.date-range-picker-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.date-range-picker-popover.show {
  display: block;
}

.date-range-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-range-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Responsive: stack the sidebar on top for small screens. The viewport-locked
 * shell doesn't fit a stacked layout, so fall back to natural page scrolling. */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-main {
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    overflow-y: visible;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-nav .nav-link {
    padding: 0.5rem 0.75rem;
  }
}
