/* PTS Central Monitoring - design system
   Navy sidebar + diagonal blue/hex topbar, matching the PTS Central platform look. */

:root {
  --navy-950: #071427;
  --navy-900: #0a1c33;
  --navy-800: #12294a;
  --navy-700: #1b3a63;
  --blue-700: #144f9e;
  --blue-600: #1a68d1;
  --blue-500: #2f8cf0;
  --blue-400: #5aa8f5;
  --blue-100: #e8f2fe;
  --ink: #16233a;
  --muted: #64748b;
  --bg: #eef2f8;
  --card-bg: #ffffff;
  --border: #e3e8f0;
  --success: #17a673;
  --danger: #e5484d;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --chip-bg: rgba(255, 255, 255, 0.9);
  --shadow-color: rgba(15, 35, 65, 0.06);
  --danger-soft: #fdecec;
  --danger-ink: #9c2b2f;
  --danger-border: #f3c6c8;
  --warning-soft: #fef6e0;
  --warning-ink: #8a600f;
  --success-soft: #e3f6ee;
  --success-ink: #0f6e4c;
  --bs-border-color: var(--border);
  --bs-tertiary-bg: #f8f9fa;
  color-scheme: light;
  --radius: 14px;
  --radius-sm: 8px;
  --sidebar-w: 250px;
}

/* Dark theme: only the neutral surfaces/text change - the navy sidebar and
   blue accents stay the same so the look is still the PTS Central scheme.
   Toggled via data-theme on <html> (see _Layout.cshtml). */
:root[data-theme="dark"] {
  --blue-100: rgba(47, 140, 240, 0.16);
  --ink: #e4ebf5;
  --muted: #8ea2bf;
  --bg: #0b1628;
  --card-bg: #11223b;
  --border: #22385a;
  --surface: #11223b;
  --surface-alt: #0f1e34;
  --chip-bg: rgba(17, 34, 59, 0.9);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --danger-soft: rgba(229, 72, 77, 0.15);
  --danger-ink: #f4a3a6;
  --danger-border: rgba(229, 72, 77, 0.5);
  --warning-soft: rgba(224, 165, 33, 0.15);
  --warning-ink: #f2cf7c;
  --success-soft: rgba(23, 166, 115, 0.15);
  --success-ink: #7fdcb6;
  --bs-tertiary-bg: #0f1e34;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); }

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
  color: #cfe0f7;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 2px 0 18px rgba(4, 12, 26, 0.25);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.4rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-brand:hover { color: #fff; }

.brand-mark {
  display: inline-flex;
  color: var(--blue-400);
  filter: drop-shadow(0 0 6px rgba(90, 168, 245, 0.45));
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #eaf3ff;
}

.brand-name b {
  font-weight: 800;
  background: linear-gradient(90deg, #7fc0ff, #3a86f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: #7f97b8;
  margin-top: 0.15rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: #a9c0dd;
  font-weight: 500;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item .nav-icon {
  display: inline-flex;
  flex: none;
  width: 20px;
  height: 20px;
}

.nav-item .nav-icon svg { width: 100%; height: 100%; }

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

.nav-item.active {
  background: linear-gradient(90deg, rgba(47, 140, 240, 0.22), rgba(47, 140, 240, 0.06));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--blue-400);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: #6d84a3;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 1100;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--navy-900);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.sidebar-backdrop { display: none; }

.sidebar-toggle span {
  width: 18px;
  height: 2px;
  background: #cfe0f7;
  border-radius: 2px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 96px;
}

.topbar-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 62%, var(--blue-600) 62.5%, var(--blue-500) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-opacity='0.16' d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15z'/%3E%3C/svg%3E");
  background-size: cover, 28px 49px;
}

.topbar-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  min-height: 96px;
}

.topbar-title h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.35rem;
  box-shadow: 0 2px 10px var(--shadow-color);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  flex: none;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
}

.user-role {
  font-size: 0.72rem;
  color: var(--muted);
}

.logout-form { display: inline-flex; }

.logout-btn, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.logout-btn svg, .theme-toggle svg { width: 18px; height: 18px; }
.logout-btn:hover { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.theme-toggle:hover { color: var(--blue-600); border-color: var(--blue-400); background: var(--blue-100); }

/* Show the icon for the theme you'd switch TO. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Content ---------- */

.content {
  flex: 1;
  padding: 1.75rem 2rem 2.5rem;
}

.app-footer {
  padding: 1rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

.content h1, .content h2 {
  color: var(--ink);
}

.page-subtitle {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

.page-lead {
  color: var(--muted);
  margin-top: -0.5rem;
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 14px var(--shadow-color);
}

.card .card-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card .display-4 {
  font-weight: 700;
  color: var(--ink);
}

/* ---------- Buttons ---------- */

.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.86rem; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  border-color: var(--blue-700);
}

.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, var(--blue-600), var(--navy-800));
  border-color: var(--navy-800);
}

.btn-outline-primary {
  color: var(--blue-600);
  border-color: var(--blue-500);
}

.btn-outline-primary:hover {
  background: var(--blue-600);
  border-color: var(--blue-600);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(47, 140, 240, 0.25);
}

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

.table {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.table thead th {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  background: var(--surface-alt);
}

.table td, .table th { vertical-align: middle; }

/* ---------- Badges ---------- */

.badge { border-radius: 999px; font-weight: 600; padding: 0.35em 0.75em; }
.bg-success { background-color: var(--success) !important; }
.bg-danger { background-color: var(--danger) !important; }

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

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border);
}

.form-control:focus, .form-select:focus {
  border-color: var(--blue-500);
}

.form-floating > label {
  color: var(--muted);
}

.form-check-input:checked {
  background-color: var(--blue-600);
  border-color: var(--blue-600);
}

/* ---------- Auth pages ---------- */

.auth-card {
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px var(--shadow-color);
  padding: 2rem;
  margin-top: 1.5rem;
}

.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-card .page-lead {
  font-size: 0.88rem;
  margin-top: 0;
  margin-bottom: 1.25rem;
}

/* ---------- Nav tabs ---------- */

.nav-tabs {
  border-bottom: 1px solid var(--border);
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.6rem 1rem;
}

.nav-tabs .nav-link:hover {
  color: var(--blue-600);
  border-color: transparent;
  background: var(--blue-100);
}

.nav-tabs .nav-link.active {
  color: var(--blue-700);
  background: var(--blue-100);
  box-shadow: inset 0 -2px 0 var(--blue-600);
}

/* ---------- Alerts (bootstrap message boxes) ---------- */

.alert {
  border: none;
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
}

.alert-danger {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: var(--danger-ink);
}

.alert-info {
  background: var(--blue-100);
  border-left-color: var(--blue-500);
  color: var(--blue-700);
}

.alert-warning {
  background: var(--warning-soft);
  border-left-color: #e0a521;
  color: var(--warning-ink);
}

.alert-success {
  background: var(--success-soft);
  border-left-color: var(--success);
  color: var(--success-ink);
}

/* ---------- Pagination ---------- */

.pagination { gap: 0.25rem; }

.page-link {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--blue-600);
  font-weight: 600;
  font-size: 0.85rem;
}

.page-link:hover {
  background: var(--blue-100);
  color: var(--blue-700);
}

.page-item.disabled .page-link {
  color: var(--muted);
  background: var(--surface-alt);
}

/* ---------- List groups ---------- */

.list-group-item {
  border-color: var(--border);
  padding: 0.75rem 1rem;
}

.list-group-item:first-child { border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); }
.list-group-item:last-child { border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

/* ---------- Detail (dl/dt/dd) views ---------- */

dl.row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.5rem;
}

dl.row dt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

dl.row dd {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0;
}

dl.row dt, dl.row dd {
  border-bottom: 1px solid var(--border);
}

dl.row dt:last-of-type, dl.row dd:last-of-type {
  border-bottom: none;
}

/* ---------- Code / raw blocks ---------- */

code {
  color: var(--blue-700);
  background: var(--blue-100);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

pre {
  background: var(--surface-alt) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--ink);
}

pre code { background: none; padding: 0; }

h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 1.5rem;
}

/* ---------- Dark theme: Bootstrap 5.1 component overrides ----------
   Bootstrap 5.1 has no built-in dark mode, so its hardcoded light
   surfaces/text are remapped onto our tokens here. */

/* Blue text on dark surfaces needs to be lighter to stay readable;
   blue fills (buttons, topbar, avatar) are left untouched. */
:root[data-theme="dark"] a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-brand) { color: var(--blue-400); }
:root[data-theme="dark"] a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-brand):hover { color: #8cc3fa; }
:root[data-theme="dark"] code,
:root[data-theme="dark"] .alert-info,
:root[data-theme="dark"] .nav-tabs .nav-link.active,
:root[data-theme="dark"] .nav-tabs .nav-link:hover,
:root[data-theme="dark"] .page-link,
:root[data-theme="dark"] .btn-outline-primary:not(:hover) { color: var(--blue-400); }

:root[data-theme="dark"] .text-muted,
:root[data-theme="dark"] .form-text { color: var(--muted) !important; }
:root[data-theme="dark"] .text-dark { color: var(--ink) !important; }
:root[data-theme="dark"] .bg-light { background-color: var(--surface-alt) !important; }
:root[data-theme="dark"] .border,
:root[data-theme="dark"] .border-top,
:root[data-theme="dark"] .border-bottom { border-color: var(--border) !important; }

:root[data-theme="dark"] .table {
  --bs-table-bg: var(--card-bg);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-striped-color: var(--ink);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-table-hover-color: var(--ink);
  --bs-table-active-color: var(--ink);
  color: var(--ink);
  border-color: var(--border);
}
:root[data-theme="dark"] .table > :not(:last-child) > :last-child > * { border-bottom-color: #2e4a72; }

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
  background-color: var(--surface-alt);
  color: var(--ink);
}
:root[data-theme="dark"] .form-control:disabled,
:root[data-theme="dark"] .form-control[readonly],
:root[data-theme="dark"] .form-select:disabled { background-color: var(--bg); }
:root[data-theme="dark"] .form-control::placeholder { color: #5f7392; }
:root[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238ea2bf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}
:root[data-theme="dark"] .form-check-input:not(:checked) {
  background-color: var(--surface-alt);
  border-color: #3a5378;
}
:root[data-theme="dark"] .form-floating > label { color: var(--muted); }

:root[data-theme="dark"] .card-header {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--ink);
}
:root[data-theme="dark"] .list-group-item {
  background: var(--card-bg);
  color: var(--ink);
}
:root[data-theme="dark"] .page-link { background: var(--card-bg); }
:root[data-theme="dark"] .alert-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--muted);
  color: var(--ink);
}
:root[data-theme="dark"] .btn-outline-secondary {
  color: #b4c3d9;
  border-color: #3a5378;
}
:root[data-theme="dark"] .btn-outline-secondary:hover {
  color: #fff;
  background: #2a4166;
  border-color: #2a4166;
}
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

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

@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

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

  /* Keep the toggle clear of the brand logo while the sidebar is open. */
  .sidebar.open .sidebar-brand { padding-left: 4.25rem; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(4, 12, 26, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

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

  .topbar-content {
    padding: 1.25rem 1.25rem 1.25rem 4.25rem;
  }

  .content {
    padding: 1.25rem;
  }
}
