/* DocuWare Audit Dashboard — DashboardKit-style shell on plain Bootstrap 5. */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1d2135;
  --text-muted: #6b7188;
  --accent: #5b5fc7;
  --accent-rgb: 91, 95, 199;
  --accent-soft: rgba(91, 95, 199, 0.12);
  --sidebar-bg: #1f2233;
  --sidebar-text: #b9bdd1;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgba(29, 33, 53, 0.05), 0 6px 20px rgba(29, 33, 53, 0.06);
  --success: #2ea87e;
  --danger: #d9534f;
  --grid: rgba(29, 33, 53, 0.08);
}

[data-theme="dark"] {
  --bg: #14161f;
  --surface: #1c1f2b;
  --border: #2b3040;
  --text: #e8eaf2;
  --text-muted: #9298ae;
  --accent: #8b8ff0;
  --accent-rgb: 139, 143, 240;
  --accent-soft: rgba(139, 143, 240, 0.16);
  --sidebar-bg: #171926;
  --sidebar-text: #9298ae;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.28);
  --success: #46c79b;
  --danger: #ef7a76;
  --grid: rgba(232, 234, 242, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */

.dw-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.2s ease;
}

.dw-brand {
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
/* The logo artwork is white-background, so give it a white chip of its own. */
.dw-brand-logo {
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.dw-brand-logo img { display: block; width: 100%; height: auto; }
.dw-brand-caption {
  margin-top: 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  text-align: center;
}

.dw-nav { padding: 0.9rem 0.75rem; flex: 1; }
.dw-sidebar-foot { padding: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.07); }

.dw-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.2rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.dw-nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.dw-nav-link.active { background: var(--accent); color: var(--sidebar-active); }
.dw-nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; }

/* Sign out is a POST form, so the nav item is a button styled as a link. */
.dw-nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dw-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}
.dw-backdrop.show { display: block; }

/* ---------- Shell ---------- */

.dw-main { margin-left: 240px; min-height: 100vh; }

.dw-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 60px;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.dw-page-title { font-size: 1rem; font-weight: 600; margin: 0; }
.dw-navbar-right { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }

.dw-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.25rem 0.6rem 0.25rem 0.3rem;
  min-height: 36px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.dw-user-btn:hover { background: var(--accent-soft); }
.dw-user-btn i { font-size: 0.7rem; color: var(--text-muted); }
.dw-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.dw-user-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  padding: 0.35rem;
  min-width: 210px;
}
.dw-user-menu-head { padding: 0.5rem 0.7rem; font-size: 0.8rem; color: var(--text); }
.dw-user-menu .dropdown-item {
  color: var(--text);
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  width: 100%;
  font: inherit;
  cursor: pointer;
}
.dw-user-menu .dropdown-item:hover { background: var(--accent-soft); color: var(--accent); }
.dw-user-menu .dropdown-divider { border-color: var(--border); }

@media (max-width: 575.98px) { .dw-user-name { display: none; } }

.dw-icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dw-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* Only one theme icon is visible at a time. */
[data-theme="light"] [data-theme-icon="dark"],
[data-theme="dark"] [data-theme-icon="light"] { display: none; }

.dw-content { padding: 1.5rem; }

/* ---------- Cards ---------- */

.dw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  height: 100%;
}
.dw-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

.dw-kpi { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dw-kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.dw-kpi-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.dw-kpi-sub { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; }
.dw-kpi-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.dw-chart-wrap { position: relative; height: 280px; }
.dw-chart-wrap.sm { height: 240px; }

/* ---------- Tables ---------- */

.dw-table { width: 100%; margin: 0; color: var(--text); border-collapse: collapse; }
.dw-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dw-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dw-table tbody tr:last-child td { border-bottom: 0; }
.dw-table tbody tr:hover { background: var(--accent-soft); }
.dw-table-wrap { overflow-x: auto; }
.dw-truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-mono { font-variant-numeric: tabular-nums; white-space: nowrap; }

.dw-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.dw-badge.store { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dw-badge.edit { background: rgba(230, 162, 60, 0.15); color: #d08700; border-color: transparent; }
[data-theme="dark"] .dw-badge.edit { color: #f0b64c; }
.dw-badge.ok { background: rgba(46, 168, 126, 0.15); color: var(--success); border-color: transparent; }
.dw-badge.error { background: rgba(217, 83, 79, 0.16); color: var(--danger); border-color: transparent; }

/* ---------- Forms / controls ---------- */

.dw-filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.dw-field { display: flex; flex-direction: column; gap: 0.25rem; }
.dw-field label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.dw-input,
.dw-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.42rem 0.6rem;
  font-size: 0.85rem;
  min-height: 36px;
}
.dw-input:focus,
.dw-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dw-input::placeholder { color: var(--text-muted); }

.dw-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dw-btn-primary { background: var(--accent); color: #fff; }
.dw-btn-primary:hover { filter: brightness(1.06); color: #fff; text-decoration: none; }
.dw-btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.dw-btn-ghost:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.dw-pagination { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.dw-pagination a,
.dw-pagination span {
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.dw-pagination a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.dw-pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.dw-pagination .disabled { opacity: 0.4; }

.dw-empty { padding: 2.25rem 1rem; text-align: center; color: var(--text-muted); }
.dw-muted { color: var(--text-muted); }

.dw-row-link { cursor: pointer; }

.dw-crumb { font-size: 0.82rem; }
.dw-crumb a { color: var(--text-muted); }
.dw-crumb a:hover { color: var(--accent); }

.dw-userhead { display: flex; align-items: center; gap: 1rem; }
.dw-userhead-name { font-size: 1.25rem; font-weight: 700; margin: 0; }
.dw-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ---------- Date range control ---------- */

.dw-range-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
}
.dw-range-slider-col { flex: 1 1 340px; min-width: 260px; }
.dw-range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.dw-range-readout { font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dw-range-fields { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }

/* noUiSlider, restyled to the dashboard palette. Extra bottom room for pips. */
#dwRangeSlider { margin: 0.35rem 0.6rem 2.6rem; }
.noUi-target {
  background: var(--border);
  border: 0;
  box-shadow: none;
  height: 6px;
  border-radius: 999px;
}
.noUi-connect { background: var(--accent); }
.noUi-handle {
  width: 18px !important;
  height: 18px !important;
  right: -9px !important;
  top: -7px !important;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}
.noUi-handle:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.noUi-handle::before, .noUi-handle::after { display: none; }
.noUi-handle:active { cursor: grabbing; }
.noUi-pips { color: var(--text-muted); padding-top: 6px; height: auto; }
.noUi-marker-horizontal.noUi-marker { background: var(--border); }
.noUi-value {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.noUi-value:hover { color: var(--accent); }
.noUi-tooltip { display: none; }

/* ---------- Login ---------- */

.dw-login-page { background: var(--bg); }
.dw-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* The logo artwork is white-background, so this card stays light in both
   themes — its colours are hard-coded rather than pulled from the theme vars. */
.dw-login-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  color: #1d2135;
  border: 1px solid #e6e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(29, 33, 53, 0.05), 0 12px 34px rgba(29, 33, 53, 0.12);
  padding: 1.9rem 1.75rem 1.6rem;
}

.dw-login-logo {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
  margin: 0 auto 1.1rem;
}
.dw-login-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 1.35rem;
  color: #1d2135;
}

.dw-login-field { margin-bottom: 0.9rem; }
.dw-login-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7188;
  margin-bottom: 0.3rem;
}
/* Inputs inside the login card follow the card, not the theme. */
.dw-login-card .dw-input {
  width: 100%;
  background: #f7f8fc;
  border: 1px solid #e6e8f0;
  color: #1d2135;
  min-height: 42px;
}
.dw-login-card .dw-input:focus {
  border-color: #5b5fc7;
  box-shadow: 0 0 0 3px rgba(91, 95, 199, 0.15);
}

.dw-login-submit {
  width: 100%;
  justify-content: center;
  min-height: 42px;
  margin-top: 0.4rem;
  background: #5b5fc7;
}
a.dw-login-submit { text-decoration: none; }

.dw-login-error {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: rgba(217, 83, 79, 0.1);
  color: #b3403c;
  border: 1px solid rgba(217, 83, 79, 0.25);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.dw-login-foot {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: #6b7188;
}

/* ---------- KPI period-over-period delta ---------- */

.dw-kpi-delta { font-size: 0.76rem; font-weight: 600; margin-top: 0.25rem; }
.dw-delta-up { color: var(--success); }
.dw-delta-down { color: var(--danger); }
.dw-delta-flat, .dw-delta-none { color: var(--text-muted); }

/* ---------- Day x hour heatmap ---------- */

.dw-heatmap-wrap { overflow-x: auto; padding-top: 0.4rem; }
.dw-heatmap {
  display: grid;
  grid-template-columns: max-content repeat(24, minmax(14px, 1fr));
  gap: 3px;
  min-width: 560px;
}
.dw-heat-corner { grid-column: 1; }
.dw-heat-hour {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  align-self: end;
  padding-bottom: 2px;
}
.dw-heat-day {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-right: 0.6rem;
  display: flex;
  align-items: center;
}
.dw-heat-cell {
  height: 22px;
  border-radius: 3px;
  background: var(--accent);           /* overridden inline with per-cell opacity */
  border: 1px solid transparent;
}
.dw-heat-cell.empty {
  background: var(--bg);
  border-color: var(--border);
}
.dw-heat-cell:hover { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Users-table sparkline ---------- */

.dw-spark {
  display: block;
  overflow: visible;
}
.dw-spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* ---------- Entity links, sortable headers, copy button ---------- */

.dw-entity-link { color: var(--text); border-bottom: 1px dotted var(--border); }
.dw-entity-link:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

.dw-sortable a {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.dw-sortable a:hover { color: var(--accent); text-decoration: none; }
.dw-sortable i { font-size: 0.7rem; }

.dw-copy-link.dw-copied { color: var(--success); border-color: var(--success); }

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
  .dw-sidebar { transform: translateX(-100%); }
  .dw-sidebar.open { transform: translateX(0); }
  .dw-main { margin-left: 0; }
  .dw-content { padding: 1rem; }
}
