/* IT Metrics Platform — Custom Styles */
/* Based on Herotel LANScan reference app (check-ux / check-branding) */

/* ── Base font ───────────────────────────────────────────────────── */
html { font-size: 15px; }

/* ── Barlow font (self-hosted) ──────────────────────────────────── */
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/barlow-700.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/barlow-800.woff2') format('woff2'); }

/* ── Herotel brand tokens (theme-independent) ───────────────────── */
:root {
  --herotel-orange: #FF5000;
  --herotel-orange-75: #FC6445;
  --herotel-orange-50: #FD9E80;
  --herotel-orange-25: #FDD2C2;
  --herotel-charcoal: #3D3B34;
  --herotel-charcoal-75: #656359;
  --herotel-charcoal-65: #6D6A63;
  --herotel-charcoal-50: #9B9993;
  --herotel-charcoal-25: #CDCCC9;
  --herotel-teal: #17A2B1;
  --header-height: 72px;
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 56px;
  --sidebar-transition: width 0.2s ease;
}

/* ── Dark mode semantic tokens ──────────────────────────────────── */
[data-bs-theme="dark"] {
  --bg: #18181b;
  --surface: #303036;
  --surface-2: #28282d;
  --surface-hover: #3c3c42;
  --text: #ececea;
  --text-2: #a8a8a8;
  --text-3: #787878;
  --border: #454550;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
  --gradient-warm-1: linear-gradient(135deg, #303036 0%, #3a3230 100%);
  --gradient-warm-2: linear-gradient(135deg, #303036 0%, #2e303a 100%);
  --gradient-warm-3: linear-gradient(135deg, #303036 0%, #303630 100%);
  --gradient-warm-4: linear-gradient(135deg, #303036 0%, #363230 100%);
  --gradient-surface: linear-gradient(135deg, #303036 0%, #343230 100%);
  --row-alt: rgba(255,255,255,0.025);
  --row-hover: rgba(255,255,255,0.055);
}

/* ── Light mode semantic tokens ─────────────────────────────────── */
[data-bs-theme="light"] {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #f0ece6;
  --surface-hover: #f0ece6;
  --text: #3D3B34;
  --text-2: #656359;
  --text-3: #9B9993;
  --border: #CDCCC9;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --gradient-warm-1: linear-gradient(135deg, #ffffff 0%, #fef8f4 100%);
  --gradient-warm-2: linear-gradient(135deg, #ffffff 0%, #f4f8fe 100%);
  --gradient-warm-3: linear-gradient(135deg, #ffffff 0%, #f4fef6 100%);
  --gradient-warm-4: linear-gradient(135deg, #ffffff 0%, #fef6f4 100%);
  --gradient-surface: linear-gradient(135deg, #ffffff 0%, #fefcfa 100%);
  --row-alt: rgba(0,0,0,0.02);
  --row-hover: rgba(0,0,0,0.03);
}

/* ── Base ────────────────────────────────────────────────────────── */
body {
  background: var(--bg) !important;
  color: var(--text);
  font-family: Arial, system-ui, sans-serif;
}

/* ── Header ─────────────────────────────────────────────────────── */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 1050;
  background: var(--herotel-charcoal);
  border-bottom: 3px solid var(--herotel-orange);
  padding: 0 48px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  height: 36px;
  width: auto;
  /* White variant — do NOT apply filter, the white logo is correct as-is */
}

.header-tagline {
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-style: italic;
  white-space: nowrap;
}

.theme-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.15s;
  margin-left: auto;
}

.theme-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* Light mode: show moon. Dark mode: show sun. */
.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: flex; }
[data-bs-theme="dark"] .theme-btn .icon-sun { display: flex; }
[data-bs-theme="dark"] .theme-btn .icon-moon { display: none; }

.user-chip {
  margin-left: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  overflow: hidden;
}

.user-name-sm {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

@media (max-width: 599.98px) {
  header { padding: 0 16px; }
  .user-chip { display: none !important; }
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: calc(var(--header-height) + 3px);
  left: 0;
  height: calc(100vh - var(--header-height) - 3px);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  overflow: hidden;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: var(--sidebar-transition);
  border-right: 1px solid var(--bs-border-color);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

[data-bs-theme="dark"] .sidebar {
  background-color: #222228;
  border-right-color: #3a3a42;
}
[data-bs-theme="light"] .sidebar {
  background-color: #f8f9fa;
  border-right-color: #dee2e6;
}

.sidebar .sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  min-height: 56px;
  white-space: nowrap;
  overflow: hidden;
  border-bottom: 1px solid var(--bs-border-color);
  flex-shrink: 0;
}

[data-bs-theme="dark"] .sidebar .sidebar-brand { border-bottom-color: #3a3a42; }
[data-bs-theme="light"] .sidebar .sidebar-brand { border-bottom-color: #dee2e6; }

.sidebar .sidebar-brand .brand-name {
  font-family: 'Barlow', Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  overflow: hidden;
  transition: opacity 0.15s ease, width 0.2s ease;
}

.sidebar.collapsed .brand-name {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar .sidebar-toggle {
  background: none;
  border: none;
  color: var(--bs-body-color);
  cursor: pointer;
  padding: 0.25rem;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar .sidebar-toggle:hover {
  color: var(--herotel-orange);
}

.sidebar-nav {
  list-style: none;
  padding: 0.5rem 0;
  margin: 0;
  flex: 1;
  overflow: hidden;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  color: var(--bs-secondary-color);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  border-radius: 0;
  border-left: 3px solid transparent;
  padding-left: calc(1rem - 3px);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  gap: 0.75rem;
}

.sidebar-nav-item:hover {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  text-decoration: none;
}

/* Active: orange text + 3px left orange border — NO background fill */
.sidebar-nav-item.active {
  background-color: transparent;
  color: var(--herotel-orange);
  border-left-color: var(--herotel-orange);
  font-weight: 600;
}

.sidebar-nav-item .nav-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
}

.sidebar-nav-item .nav-label {
  overflow: hidden;
  transition: opacity 0.15s ease, width 0.2s ease;
  flex: 1;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-bottom {
  border-top: 1px solid var(--bs-border-color);
  padding: 0.5rem 0;
  flex-shrink: 0;
}

[data-bs-theme="dark"] .sidebar-bottom { border-top-color: #3a3a42; }
[data-bs-theme="light"] .sidebar-bottom { border-top-color: #dee2e6; }

/* ── Main content ─────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: calc(var(--header-height) + 3px);
  min-height: calc(100vh - var(--header-height) - 3px);
  padding: 1.25rem;
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.main-content.no-sidebar {
  margin-left: 0;
}

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-header h1 {
  margin: 0;
  font-family: 'Barlow', Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

/* ── Cards and surfaces ───────────────────────────────────────────── */
.card {
  background: var(--gradient-surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.card-header {
  background: transparent;
  border-bottom-color: var(--border);
  border-left: 3px solid var(--herotel-orange);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--herotel-orange);
  padding: 10px 12px;
  font-family: 'Barlow', Arial, sans-serif;
}

.card-body { padding: 12px; }

.surface-card {
  background: var(--gradient-surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

/* ── KPI stat cards ───────────────────────────────────────────────── */
.stat-card {
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-decoration: none !important;
  display: block;
  color: var(--text) !important;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow), 0 4px 12px rgba(0,0,0,0.15);
}

[data-bs-theme="dark"] .stat-card { border-color: transparent; }

.stat-card .stat-number {
  font-family: 'Barlow', Arial, sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 9px;
  color: var(--text-2);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card-1 { background: var(--gradient-warm-1); }
.stat-card-2 { background: var(--gradient-warm-2); }
.stat-card-3 { background: var(--gradient-warm-3); }
.stat-card-4 { background: var(--gradient-warm-4); }

/* ── Login page ───────────────────────────────────────────────────── */
.login-card {
  max-width: 420px;
  margin: 80px auto;
  background: var(--gradient-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  text-align: center;
}

.login-card .login-logo {
  height: 48px;
  width: auto;
  margin-bottom: 20px;
}

.login-card h2 {
  font-family: 'Barlow', Arial, sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.login-card p {
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 24px;
}

.btn-login {
  background: var(--herotel-orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-login:hover {
  background: #e64800;
  color: #fff;
  transform: scale(1.02);
  text-decoration: none;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

.btn-primary {
  background: var(--herotel-orange) !important;
  border-color: var(--herotel-orange) !important;
  color: #fff !important;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

.btn-primary:hover {
  background: #e64800 !important;
  border-color: #e64800 !important;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.form-control, .form-select {
  font-size: 0.8rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--herotel-orange) !important;
  box-shadow: 0 0 0 2px rgba(255,80,0,0.15) !important;
}

/* ── Modals ───────────────────────────────────────────────────────── */
.modal-content {
  background: var(--gradient-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-lg);
}

.modal-header { border-bottom: 1px solid var(--border); padding: 12px 16px; }
.modal-header .modal-title { font-family: 'Barlow', Arial, sans-serif; font-size: 15px; font-weight: 600; }
.modal-footer { border-top: 1px solid var(--border); padding: 10px 16px; }

[data-bs-theme="dark"] .modal-header .btn-close { filter: invert(1); }

/* ── DataTables 2.x (dt-container) ───────────────────────────────── */

/* Override Bootstrap .row's own --bs-gutter-x so negative margins don't escape the card.
   margin-top: 0 removes the mt-2 Bootstrap class DT adds to toolbar/pagination rows. */
.card > .card-body.p-0 .dt-container .row {
    --bs-gutter-x: 0;
    margin-top: 0 !important;
}
/* 5px side + 5px vertical padding on toolbar/pagination cells */
.card > .card-body.p-0 .dt-container .dt-layout-start {
    padding: 5px 0 5px 5px;
}
.card > .card-body.p-0 .dt-container .dt-layout-end {
    padding: 5px 5px 5px 0;
}
/* Strip the 2px bottom margin DT adds to the pagination ul */
.card > .card-body.p-0 .dt-container .dt-paging ul {
    margin-bottom: 0;
}

/* Container colour */
.dt-container { color: var(--text); }

/* Toolbar label text */
.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-info,
.dt-container .dt-paging {
    color: var(--text-2);
    font-size: 0.8rem;
}

/* Search input + length select theming */
.dt-container .dt-search input,
.dt-container .dt-length select {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px;
    padding: 4px 8px;
}
[data-bs-theme="light"] .dt-container .dt-search input,
[data-bs-theme="light"] .dt-container .dt-length select {
    background: transparent !important;
}
.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus {
    outline: none;
    border-color: var(--herotel-orange) !important;
    box-shadow: 0 0 0 2px rgba(255,80,0,0.15);
}

/* Right-side toolbar cell — flex so search + refresh + columns are inline, 6px gaps */
.dt-container .dt-layout-end {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}
/* Override DT's own 1em left-margin on toolbar children */
.dt-container .dt-layout-end > * {
    margin-left: 0 !important;
}

/* Pagination */
.dt-container .pagination .page-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}
.dt-container .pagination .page-link:hover { background: var(--surface-hover); }
.dt-container .pagination .page-item.active .page-link {
    background: var(--herotel-orange);
    border-color: var(--herotel-orange);
    color: white;
}

/* Processing indicator */
.dt-container .dt-processing {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* Table cell styles */
table.dataTable thead th,
table.dataTable thead td {
  font-size: 0.7rem !important;
  color: var(--text-3) !important;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  border-bottom: 2px solid var(--herotel-orange) !important;
  border-top: none !important;
  padding: 8px 10px !important;
  background: transparent !important;
}

table.dataTable tbody tr > td {
  font-size: 0.8rem;
  padding: 7px 10px !important;
  vertical-align: middle;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--row-alt) !important;
    --bs-table-bg-type: var(--row-alt);
}
.table-hover > tbody > tr:hover > * {
    background-color: var(--row-hover) !important;
    --bs-table-bg-type: var(--row-hover);
}

/* Row action buttons */
.btn-row {
    padding: 1px 6px;
    font-size: 0.75rem;
    line-height: 1.5;
    border-radius: 4px;
}

/* Badge sizing */
.badge { font-weight: 600; --bs-badge-font-size: 9px; }

/* ── Nav tabs ─────────────────────────────────────────────────────── */
.nav-tabs .nav-link.active {
  color: var(--herotel-orange);
  border-bottom-color: var(--herotel-orange);
  background: transparent;
}

/* ── Animations ───────────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeSlideIn 0.3s ease forwards;
  opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.10s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.20s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.30s; }

/* ── Utilities ────────────────────────────────────────────────────── */
.nobr { white-space: nowrap; }

/* Select2 dark mode overrides */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--text); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__placeholder { color: var(--text-3); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option { color: var(--text); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
  background-color: var(--herotel-orange);
  color: white;
}
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
  background-color: var(--bg);
  color: var(--text);
}
