/*
 * FLC Utility: visual refinement layer.
 * Loaded after vertical-layout-light/style.css. It changes only colour,
 * type, depth, radius and interaction states. No layout, widths or
 * structure are changed here.
 */

:root {
  /* Brand: the template's own indigo, kept as the anchor */
  --flc-indigo: #4b49ac;
  --flc-indigo-600: #403e98;
  --flc-indigo-700: #34327e;
  --flc-indigo-50: #f0f0fb;
  --flc-indigo-100: #e2e1f6;

  /* Surfaces and ink (tinted toward the brand, never pure gray) */
  --flc-canvas: #f4f5fb;
  --flc-surface: #ffffff;
  --flc-surface-sunk: #f7f7fc;
  --flc-ink: #1d1d35;
  --flc-ink-soft: #4a4a66;
  --flc-ink-faint: #6b6b88;
  --flc-line: #e6e6f2;
  --flc-line-strong: #d3d3e6;

  /* Status: tinted wash + readable ink */
  --flc-ok: #1f7a4d;
  --flc-ok-wash: #e3f5eb;
  --flc-warn: #8a5a00;
  --flc-warn-wash: #fff3d6;
  --flc-danger: #b4232f;
  --flc-danger-wash: #fde8ea;
  --flc-info: #2856c4;
  --flc-info-wash: #e6eeff;

  /* Stat tiles: same hue families as before, deepened for white text */
  --flc-tile-blue: #3a5fcf;
  --flc-tile-indigo: #4747a1;
  --flc-tile-violet: #5b59d0;
  --flc-tile-red: #c8414b;

  --flc-radius-card: 16px;
  --flc-radius-control: 10px;
  --flc-shadow-sm: 0 1px 2px rgba(29, 29, 53, 0.05), 0 1px 1px rgba(29, 29, 53, 0.03);
  --flc-shadow-md: 0 2px 4px rgba(29, 29, 53, 0.04), 0 8px 24px -8px rgba(29, 29, 53, 0.12);
  --flc-ring: 0 0 0 3px rgba(75, 73, 172, 0.28);
  --flc-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */

body {
  color: var(--flc-ink);
  background: var(--flc-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.content-wrapper {
  background: var(--flc-canvas);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--flc-ink);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.text-muted,
.card-description {
  color: var(--flc-ink-faint) !important;
}

a {
  text-underline-offset: 3px;
}

a.text-primary,
.text-primary {
  color: var(--flc-indigo) !important;
}

a.text-primary:hover {
  color: var(--flc-indigo-700) !important;
  text-decoration: underline;
}

::selection {
  background: var(--flc-indigo-100);
  color: var(--flc-indigo-700);
}

input, textarea {
  caret-color: var(--flc-indigo);
}

code {
  color: var(--flc-indigo-700);
  background: var(--flc-indigo-50);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.85em;
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--flc-line-strong) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--flc-line-strong);
  border-radius: 10px;
  border: 2px solid var(--flc-canvas);
}
::-webkit-scrollbar-thumb:hover { background: #b9b9d3; }

/* Keyboard focus, everywhere */
:focus-visible {
  outline: 2px solid var(--flc-indigo);
  outline-offset: 2px;
}

/* ---------- Navbar ---------- */

.navbar {
  box-shadow: none;
  border-bottom: 1px solid var(--flc-line);
}

.navbar .navbar-brand-wrapper,
.navbar .navbar-menu-wrapper {
  background: var(--flc-surface);
}

.navbar .navbar-menu-wrapper .navbar-toggler {
  color: var(--flc-ink-soft);
  border-radius: 8px;
  transition: background-color 160ms var(--flc-ease), color 160ms var(--flc-ease);
}

.navbar .navbar-menu-wrapper .navbar-toggler:hover {
  color: var(--flc-indigo);
  background: var(--flc-indigo-50);
}

.navbar .navbar-menu-wrapper .navbar-nav .nav-item.nav-profile .nav-link {
  color: var(--flc-ink-soft);
  font-weight: 600;
}

.navbar .navbar-menu-wrapper .navbar-nav .nav-item.nav-profile img {
  box-shadow: 0 0 0 2px var(--flc-surface), 0 0 0 3px var(--flc-line-strong);
}

.navbar-dropdown,
.dropdown-menu {
  border: 1px solid var(--flc-line);
  border-radius: 12px;
  box-shadow: var(--flc-shadow-md);
  padding: 6px;
}

.dropdown-item {
  border-radius: 8px;
  color: var(--flc-ink);
  transition: background-color 140ms var(--flc-ease);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--flc-indigo-50);
  color: var(--flc-indigo-700);
}

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

.sidebar {
  background: var(--flc-surface);
  border-right: 1px solid var(--flc-line);
}

.sidebar .nav .nav-item .nav-link {
  color: var(--flc-ink-soft);
  transition: background-color 160ms var(--flc-ease), color 160ms var(--flc-ease);
}

.sidebar .nav .nav-item .nav-link i.menu-icon {
  color: var(--flc-ink-faint);
  transition: color 160ms var(--flc-ease);
}

/* Light hover tint only for rows that are not already indigo (active or expanded) */
.sidebar .nav:not(.sub-menu) > .nav-item:hover:not(.active) > .nav-link:not([aria-expanded="true"]),
.sidebar .nav:not(.sub-menu) > .nav-item:hover:not(.active) > .nav-link:not([aria-expanded="true"]) i,
.sidebar .nav:not(.sub-menu) > .nav-item:hover:not(.active) > .nav-link:not([aria-expanded="true"]) .menu-title {
  color: var(--flc-indigo);
}

.sidebar .nav:not(.sub-menu) > .nav-item:hover:not(.active) > .nav-link:not([aria-expanded="true"]) {
  background: var(--flc-indigo-50);
}

/* Icon-only sidebar: the hovered label pops out as an indigo flyout, so keep its text white */
.sidebar-icon-only .sidebar .nav:not(.sub-menu) > .nav-item:hover > .nav-link:not([aria-expanded="true"]) .menu-title {
  color: #ffffff;
}

.sidebar .nav .nav-item.active > .nav-link {
  background: var(--flc-indigo);
}

/* Indigo rows (active, or expanded with its submenu open) always get white content */
.sidebar .nav .nav-item.active > .nav-link i,
.sidebar .nav .nav-item.active > .nav-link .menu-title,
.sidebar .nav .nav-item.active > .nav-link .menu-arrow,
.sidebar .nav:not(.sub-menu) > .nav-item > .nav-link[aria-expanded="true"] i,
.sidebar .nav:not(.sub-menu) > .nav-item > .nav-link[aria-expanded="true"] .menu-title,
.sidebar .nav:not(.sub-menu) > .nav-item > .nav-link[aria-expanded="true"] .menu-arrow {
  color: #ffffff;
}

/* The submenu panel is always indigo (expanded and icon-only flyout), so links are light */
.sidebar .nav.sub-menu .nav-item .nav-link {
  color: rgba(255, 255, 255, 0.78);
}

.sidebar .nav.sub-menu .nav-item .nav-link:hover,
.sidebar .nav.sub-menu .nav-item .nav-link:focus-visible,
.sidebar .nav.sub-menu .nav-item .nav-link.active {
  color: #ffffff;
}

.sidebar .nav.sub-menu .nav-item .nav-link.active {
  font-weight: 700;
}

.sidebar .nav.sub-menu .nav-item::before {
  background: rgba(255, 255, 255, 0.45);
}

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

.card {
  border: 1px solid var(--flc-line);
  border-radius: var(--flc-radius-card);
  box-shadow: none;
  background: var(--flc-surface);
}

.card .card-title {
  color: var(--flc-ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Stat tiles: same order and hues, deeper fills so white text passes AA */
.card.card-tale,
.card.card-dark-blue,
.card.card-light-blue,
.card.card-light-danger {
  border: 0;
  color: #ffffff;
  box-shadow: var(--flc-shadow-sm);
  transition: transform 220ms var(--flc-ease), box-shadow 220ms var(--flc-ease), background-color 220ms var(--flc-ease);
}

.card.card-tale { background: var(--flc-tile-blue); }
.card.card-dark-blue { background: var(--flc-tile-indigo); }
.card.card-light-blue { background: var(--flc-tile-violet); }
.card.card-light-danger { background: var(--flc-tile-red); }

.card.card-tale:hover { background: #3456bd; }
.card.card-dark-blue:hover { background: #3f3f92; }
.card.card-light-blue:hover { background: #5250c2; }
.card.card-light-danger:hover { background: #b83a44; }

.card.card-tale:hover,
.card.card-dark-blue:hover,
.card.card-light-blue:hover,
.card.card-light-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--flc-shadow-md);
}

.card.card-tale .card-body p:first-child,
.card.card-dark-blue .card-body p:first-child,
.card.card-light-blue .card-body p:first-child,
.card.card-light-danger .card-body p:first-child {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}

.card.card-tale .card-body p:last-child,
.card.card-dark-blue .card-body p:last-child,
.card.card-light-blue .card-body p:last-child,
.card.card-light-danger .card-body p:last-child {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8125rem;
}

.fs-30 {
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* Inner panels on Settings: lighter so they don't read as a card in a card */
.card .border.rounded.bg-light {
  background: var(--flc-surface-sunk) !important;
  border-color: var(--flc-line) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}

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

table,
.table {
  color: var(--flc-ink);
  font-variant-numeric: tabular-nums;
}

.expandable-table thead tr th {
  background: var(--flc-indigo-50);
  color: var(--flc-indigo-700);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 0 !important;
}

.expandable-table tr.odd,
.expandable-table tr.even {
  box-shadow: none;
}

.expandable-table tbody tr td {
  border-bottom: 1px solid var(--flc-line);
  color: var(--flc-ink);
}

.expandable-table tbody tr {
  transition: background-color 120ms var(--flc-ease);
}

.expandable-table tbody tr:hover {
  background: var(--flc-surface-sunk);
}

.expandable-table tbody tr:last-child td {
  border-bottom: 0;
}

/* DataTables chrome */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--flc-line-strong);
  border-radius: 8px;
  background: var(--flc-surface);
  color: var(--flc-ink);
}

.dataTables_wrapper .dataTables_info {
  color: var(--flc-ink-faint);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  color: var(--flc-ink-soft) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--flc-indigo-50) !important;
  color: var(--flc-indigo-700) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--flc-indigo) !important;
  border-color: var(--flc-indigo) !important;
  color: #ffffff !important;
}

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

.badge {
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  padding: 0.35em 0.75em;
  border: 1px solid transparent;
}

.badge-success { background: var(--flc-ok-wash); color: var(--flc-ok); border-color: rgba(31, 122, 77, 0.18); }
.badge-warning { background: var(--flc-warn-wash); color: var(--flc-warn); border-color: rgba(138, 90, 0, 0.18); }
.badge-danger  { background: var(--flc-danger-wash); color: var(--flc-danger); border-color: rgba(180, 35, 47, 0.18); }
.badge-info    { background: var(--flc-info-wash); color: var(--flc-info); border-color: rgba(40, 86, 196, 0.18); }

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

.btn {
  border-radius: var(--flc-radius-control);
  font-weight: 700;
  letter-spacing: 0.005em;
  transition: background-color 160ms var(--flc-ease), border-color 160ms var(--flc-ease),
              box-shadow 160ms var(--flc-ease), transform 120ms var(--flc-ease), color 160ms var(--flc-ease);
}

.btn:active:not(:disabled):not(.disabled) {
  transform: scale(0.97);
}

.btn:focus,
.btn.focus {
  box-shadow: var(--flc-ring);
}

.btn-primary {
  background: var(--flc-indigo);
  border-color: var(--flc-indigo);
  box-shadow: 0 1px 2px rgba(52, 50, 126, 0.25);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
  background: var(--flc-indigo-600);
  border-color: var(--flc-indigo-600);
}

.btn-primary.disabled,
.btn-primary:disabled {
  background: var(--flc-indigo-100);
  border-color: var(--flc-indigo-100);
  color: var(--flc-ink-faint);
  opacity: 1;
  box-shadow: none;
}

.btn-success {
  background: #23845a;
  border-color: #23845a;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(20, 90, 60, 0.25);
}

.btn-success:hover,
.btn-success:focus,
.btn-success:not(:disabled):not(.disabled):active {
  background: #1c714c;
  border-color: #1c714c;
  color: #ffffff;
}

.btn-success:focus {
  box-shadow: 0 0 0 3px rgba(35, 132, 90, 0.3);
}

.btn-outline-danger {
  color: var(--flc-danger);
  border-color: rgba(180, 35, 47, 0.45);
  background: transparent;
}

.btn-outline-danger:hover,
.btn-outline-danger:not(:disabled):not(.disabled):active {
  background: var(--flc-danger);
  border-color: var(--flc-danger);
  color: #ffffff;
}

.btn-outline-danger:focus {
  box-shadow: 0 0 0 3px rgba(180, 35, 47, 0.25);
}

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

label,
.form-label {
  color: var(--flc-ink-soft);
  font-weight: 600;
  font-size: 0.8125rem;
}

.form-control,
select.form-control,
.asColorPicker-input,
.dataTables_wrapper select,
.select2-container--default .select2-selection--single {
  border: 1px solid var(--flc-line-strong);
  border-radius: var(--flc-radius-control);
  background-color: var(--flc-surface);
  color: var(--flc-ink);
  transition: border-color 160ms var(--flc-ease), box-shadow 160ms var(--flc-ease), background-color 160ms var(--flc-ease);
}

.form-control::placeholder {
  color: #8c8ca6;
  opacity: 1;
}

.form-control:hover:not(:focus):not([readonly]):not(:disabled) {
  border-color: #b9b9d3;
}

.form-control:focus,
select.form-control:focus {
  border-color: var(--flc-indigo);
  box-shadow: var(--flc-ring);
  outline: none;
  background-color: var(--flc-surface);
}

.form-control[readonly],
.form-control:disabled {
  background-color: var(--flc-surface-sunk);
  border-color: var(--flc-line);
  color: var(--flc-ink-soft);
}

.form-control:disabled {
  cursor: not-allowed;
}

/* Template draws selects with an outline instead of a border; use the border only */
select.form-control,
select.form-control:focus,
.dataTables_wrapper select,
.dataTables_wrapper select:focus {
  outline: 0;
  color: var(--flc-ink);
}

/* Login inputs: template squares them off and drops the border */
.auth form .form-group .form-control {
  background: var(--flc-surface);
  border: 1px solid var(--flc-line-strong);
  border-radius: var(--flc-radius-control);
}

.auth form .form-group .form-control:focus {
  border-color: var(--flc-indigo);
  box-shadow: var(--flc-ring);
}

/* Readings: number entry gets tabular digits */
input[type="number"].form-control {
  font-variant-numeric: tabular-nums;
}

.form-check-input,
input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--flc-indigo);
}

/* Address search results on the Readings page */
#result .list-group {
  margin-top: 6px;
  border: 1px solid var(--flc-line) !important;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--flc-shadow-md);
  background: var(--flc-surface);
}

#result .dropdown-item {
  padding: 0.6rem 1rem;
  border-radius: 0;
  border-bottom: 1px solid var(--flc-line);
}

#result li:last-child .dropdown-item {
  border-bottom: 0;
}

/* ---------- Alerts ---------- */

.alert {
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  line-height: 1.5;
}

.alert-success { background: var(--flc-ok-wash); color: var(--flc-ok); border-color: rgba(31, 122, 77, 0.2); }
.alert-warning { background: var(--flc-warn-wash); color: var(--flc-warn); border-color: rgba(138, 90, 0, 0.2); }
.alert-danger  { background: var(--flc-danger-wash); color: var(--flc-danger); border-color: rgba(180, 35, 47, 0.2); }
.alert-info    { background: var(--flc-info-wash); color: var(--flc-info); border-color: rgba(40, 86, 196, 0.2); }

hr {
  border-top-color: var(--flc-line);
}

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

.auth .auth-form-light {
  border: 1px solid var(--flc-line);
  border-radius: 20px;
  box-shadow: var(--flc-shadow-md);
}

.auth .auth-form-light h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth .auth-form-light h6 {
  color: var(--flc-ink-faint);
}

.auth .form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 0;
  margin: 0;
}

.auth .form-check .form-check-input {
  position: static;
  margin: 0;
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  cursor: pointer;
}

.auth .form-check-label {
  margin: 0;
  cursor: pointer;
}

.auth .auth-form-btn {
  letter-spacing: 0.06em;
}

/* ---------- Footer ---------- */

.footer {
  background: transparent;
  border-top: 1px solid var(--flc-line);
}

.footer .text-muted {
  font-size: 0.8125rem;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .card:hover,
  .btn:active {
    transform: none !important;
  }
}
