/* ==============================================================
   Lucid.Web — High-Density Azure-Themed Tenant Portal
   Overrides Bootstrap 5 CSS variables for enterprise styling.
   ============================================================== */

/* ── Bootstrap CSS Variable Overrides ────────────────────────── */
:root {
  /* Primary Azure Blue (Midnight Navy) */
  --bs-primary: var(--tenant-primary, #001e3b);
  --bs-primary-rgb: 0, 30, 59;

  /* Secondary Slate */
  --bs-secondary: var(--tenant-secondary, #4A5568);
  --bs-secondary-rgb: 74, 85, 104;

  /* Dark — Midnight Navy Sidebar */
  --bs-dark: #001e3b;
  --bs-dark-rgb: 0, 30, 59;

  /* Semantic Colors */
  --bs-success: var(--tenant-success, #107C10);
  --bs-success-rgb: 16, 124, 16;
  --bs-danger: var(--tenant-danger, #D13438);
  --bs-danger-rgb: 209, 52, 56;
  --bs-warning: var(--tenant-warning, #D83B01);
  --bs-warning-rgb: 216, 59, 1;
  --bs-info: var(--tenant-info, #038387);
  --bs-info-rgb: 3, 131, 135;

  /* Tenant-themeable custom properties (non-Bootstrap) */
  --tenant-primary: #001e3b;
  --tenant-primary-hover: #002b52;
  --tenant-secondary: #4A5568;
  --tenant-success: #107C10;
  --tenant-danger: #D13438;
  --tenant-warning: #D83B01;
  --tenant-info: #038387;
  --tenant-border: #D1D5DB;

  /* Global Backgrounds & Text */
  --bs-body-bg: #f8f9fa;
  --bs-body-color: #111827;

  /* Sidebar Palette (theme-driven — resolves lazily against data-theme) */
  --bs-sidebar-bg: var(--lucid-theme);
  --bs-sidebar-text-active: var(--lucid-theme-contrast);
  --bs-sidebar-text-inactive: color-mix(in srgb, var(--lucid-theme-contrast) 82%, var(--lucid-theme));
  --bs-sidebar-text-hover: var(--lucid-theme-contrast);
  --bs-sidebar-bg-active: color-mix(in srgb, var(--lucid-theme) 70%, var(--lucid-theme-contrast));
  --bs-sidebar-border-active: var(--lucid-theme-contrast);

  /* ── UI Theme (personalization) ────────────────────────────── */
  --lucid-theme: #001e3b;               /* base theme color (Azure default) */
  --lucid-theme-contrast: #ffffff;      /* readable text on the theme color */
  --lucid-title-color: color-mix(in srgb, var(--lucid-theme) 62%, #111827);
}

/* ── Theme palettes ────────────────────────────────────────────
   Each theme sets the base color, its contrast text, and re-points
   Bootstrap's primary accent so buttons/links/active states follow it. */
:root[data-theme="Azure"] {
  --lucid-theme: #001E3B;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #001E3B;
  --tenant-primary: #001E3B;
  --bs-primary-rgb: 0, 30, 59;
}
:root[data-theme="Indigo"] {
  --lucid-theme: #0D3D56;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #0D3D56;
  --tenant-primary: #0D3D56;
  --bs-primary-rgb: 13, 61, 86;
}
:root[data-theme="Sophia"] {
  --lucid-theme: #0F5B78;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #0F5B78;
  --tenant-primary: #0F5B78;
  --bs-primary-rgb: 15, 91, 120;
}
:root[data-theme="Skye"] {
  --lucid-theme: #117899;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #117899;
  --tenant-primary: #117899;
  --bs-primary-rgb: 17, 120, 153;
}
:root[data-theme="Alice"] {
  --lucid-theme: #1496BB;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #1496BB;
  --tenant-primary: #1496BB;
  --bs-primary-rgb: 20, 150, 187;
}
:root[data-theme="Jade"] {
  --lucid-theme: #5CA794;
  --lucid-theme-contrast: #111827;
  --bs-primary: #5CA794;
  --tenant-primary: #5CA794;
  --bs-primary-rgb: 92, 167, 148;
}
:root[data-theme="Kelly"] {
  --lucid-theme: #A3B86C;
  --lucid-theme-contrast: #111827;
  --bs-primary: #A3B86C;
  --tenant-primary: #A3B86C;
  --bs-primary-rgb: 163, 184, 108;
}
:root[data-theme="Daisy"] {
  --lucid-theme: #EBC944;
  --lucid-theme-contrast: #111827;
  --bs-primary: #EBC944;
  --tenant-primary: #EBC944;
  --bs-primary-rgb: 235, 201, 68;
}
:root[data-theme="Amber"] {
  --lucid-theme: #EDAA38;
  --lucid-theme-contrast: #111827;
  --bs-primary: #EDAA38;
  --tenant-primary: #EDAA38;
  --bs-primary-rgb: 237, 170, 56;
}
:root[data-theme="April"] {
  --lucid-theme: #F08C2D;
  --lucid-theme-contrast: #111827;
  --bs-primary: #F08C2D;
  --tenant-primary: #F08C2D;
  --bs-primary-rgb: 240, 140, 45;
}
:root[data-theme="Coral"] {
  --lucid-theme: #F26D21;
  --lucid-theme-contrast: #111827;
  --bs-primary: #F26D21;
  --tenant-primary: #F26D21;
  --bs-primary-rgb: 242, 109, 33;
}
:root[data-theme="Rowan"] {
  --lucid-theme: #D94E20;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #D94E20;
  --tenant-primary: #D94E20;
  --bs-primary-rgb: 217, 78, 32;
}
:root[data-theme="Ruby"] {
  --lucid-theme: #C02F1D;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #C02F1D;
  --tenant-primary: #C02F1D;
  --bs-primary-rgb: 192, 47, 29;
}
:root[data-theme="Raven"] {
  --lucid-theme: #373D3F;
  --lucid-theme-contrast: #ffffff;
  --bs-primary: #373D3F;
  --tenant-primary: #373D3F;
  --bs-primary-rgb: 55, 61, 63;
}
:root[data-theme="Stone"] {
  --lucid-theme: #8C979A;
  --lucid-theme-contrast: #111827;
  --bs-primary: #8C979A;
  --tenant-primary: #8C979A;
  --bs-primary-rgb: 140, 151, 154;
}

/* ── Density: Base Typography (13px) ─────────────────────────── */
html { font-size: 13px; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

/* ── Button Hover States (dynamic, no SCSS needed) ───────────── */
.btn-primary {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  color: var(--lucid-theme-contrast);
}
.btn-primary:hover {
  filter: brightness(0.85);
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.btn-success { background-color: var(--bs-success); border-color: var(--bs-success); }
.btn-success:hover { filter: brightness(0.85); background-color: var(--bs-success); border-color: var(--bs-success); }
.btn-danger { background-color: var(--bs-danger); border-color: var(--bs-danger); }
.btn-danger:hover { filter: brightness(0.85); background-color: var(--bs-danger); border-color: var(--bs-danger); }
.btn-warning { background-color: var(--bs-warning); border-color: var(--bs-warning); color: #111827; }
.btn-warning:hover { filter: brightness(0.85); background-color: var(--bs-warning); border-color: var(--bs-warning); }

/* ── Density: Spacing Compression ────────────────────────────── */
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 0.75rem !important; }
.p-4 { padding: 1rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mt-3 { margin-top: 0.75rem !important; }
.my-3 { margin: 0.75rem 0 !important; }
.g-3 { --bs-gutter-y: 0.75rem; --bs-gutter-x: 0.75rem; }

/* ── Density: Cards ──────────────────────────────────────────── */
.card {
  border-radius: 0.1875rem;
  border-color: var(--tenant-border, #D1D5DB);
}
.card-header {
  padding: 0.6rem 1rem;
  font-weight: 600;
  border-bottom: 2px solid var(--bs-primary, #001e3b);
}
.card-body {
  padding: 0.75rem 1rem;
}

/* ── Density: Tables ─────────────────────────────────────────── */
.table { font-size: 0.8125rem; }
.table > :not(caption) > * > * {
  padding: 0.35rem 0.5rem;
}
.table-sm > :not(caption) > * > * {
  padding: 0.2rem 0.35rem;
}
.table thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: #6B7280;
  background-color: #F9FAFB;
  border-bottom-width: 2px;
}

/* ── Density: Forms ──────────────────────────────────────────── */
.form-control,
.form-select {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  border-radius: 0.1875rem;
  border-color: var(--tenant-border, #D1D5DB);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--bs-primary, #001e3b);
  box-shadow: 0 0 0 0.15rem rgba(0, 128, 255, 0.25);
}
.form-label {
  margin-bottom: 0.2rem;
  font-weight: 500;
  font-size: 0.8125rem;
  color: #374151;
}
.form-check-input { margin-top: 0.35rem; }
.form-switch .form-check-input {
  width: 2.25em;
  height: 1.15em;
}

/* ── Density: Buttons ────────────────────────────────────────── */
.btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  border-radius: 0.1875rem;
  font-weight: 500;
}
.btn-sm {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}

/* ── Density: Nav / Dropdown / Alert / Badge ─────────────────── */
.nav-link { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }
.dropdown-item { padding: 0.2rem 1rem; font-size: 0.8125rem; }
.alert { padding: 0.5rem 0.75rem; font-size: 0.8125rem; border-radius: 0.1875rem; }
.badge { font-size: 0.6875rem; font-weight: 600; }
.count-badge {
  background-color: var(--lucid-theme);
  color: var(--lucid-theme-contrast);
}
.modal-header { padding: 0.75rem; }
.modal-body { padding: 0.75rem; }
.modal-footer { padding: 0.5rem 0.75rem; }

/* ── Page Heading ────────────────────────────────────────────── */
.page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--lucid-title-color, #1F2937);
  margin-bottom: 0.5rem;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  min-height: 100vh;
  flex-shrink: 0;
  transition: width 0.25s ease;
  position: relative;
  z-index: 1020;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--bs-sidebar-bg) !important;
}

.sidebar-brand {
  color: var(--bs-sidebar-text-active) !important;
}

.sidebar-divider {
  border: none;
  border-top: 3px double var(--bs-sidebar-text-active, #ffffff);
  opacity: 1;
  margin: 0 0 1rem;
}

/* Sidebar collapsed — icon-only narrow bar */
.sidebar.collapsed,
html.sidebar-collapsed .sidebar {
  width: 60px;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-item-text,
.sidebar.collapsed .sidebar-chevron,
.sidebar.collapsed hr,
.sidebar.collapsed .sidebar-brand-icon-full,
html.sidebar-collapsed .sidebar .sidebar-brand-text,
html.sidebar-collapsed .sidebar .sidebar-item-text,
html.sidebar-collapsed .sidebar .sidebar-chevron,
html.sidebar-collapsed .sidebar hr,
html.sidebar-collapsed .sidebar .sidebar-brand-icon-full {
  display: none;
}

.sidebar.collapsed .sidebar-brand,
html.sidebar-collapsed .sidebar .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .sidebar-brand .sidebar-brand-icon,
html.sidebar-collapsed .sidebar .sidebar-brand .sidebar-brand-icon {
  margin-right: 0 !important;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .btn-toggle,
html.sidebar-collapsed .sidebar .nav-link,
html.sidebar-collapsed .sidebar .btn-toggle {
  justify-content: center;
  padding: 0.5rem 0;
  text-align: center;
}

.sidebar.collapsed .nav-link i,
.sidebar.collapsed .btn-toggle i:not(.sidebar-chevron),
html.sidebar-collapsed .sidebar .nav-link i,
html.sidebar-collapsed .sidebar .btn-toggle i:not(.sidebar-chevron) {
  margin-right: 0 !important;
}

.sidebar.collapsed .nav-item,
html.sidebar-collapsed .sidebar .nav-item {
  position: relative;
}

/* Hamburger toggle button inside the sidebar */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: color-mix(in srgb, var(--lucid-theme-contrast) 70%, transparent);
  font-size: 1.35rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  z-index: 1021;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.sidebar-toggle:hover {
  color: var(--lucid-theme-contrast);
  background-color: color-mix(in srgb, var(--lucid-theme-contrast) 10%, transparent);
}

.sidebar.collapsed .sidebar-toggle,
html.sidebar-collapsed .sidebar .sidebar-toggle {
  right: 50%;
  transform: translateX(50%);
}

/* Push sidebar menu down to clear the hamburger toggle (collapsed mode only) */
.sidebar.collapsed #sidebar-menu,
html.sidebar-collapsed .sidebar #sidebar-menu {
  margin-top: 42px;
}

/* ── Sidebar Flyout Dropdown (collapsed mode) ────────────────── */
.sidebar-flyout {
  display: none;
  position: fixed;
  left: 60px;
  z-index: 1050;
  background-color: var(--bs-sidebar-bg, #001e3b);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-left: none;
  border-radius: 0 6px 6px 0;
  min-width: 200px;
  padding: 0.5rem 0;
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-flyout.show {
  display: block;
}

.sidebar-flyout .flyout-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 1rem;
  color: color-mix(in srgb, var(--lucid-theme-contrast) 85%, var(--lucid-theme));
  text-decoration: none;
  font-size: 0.8125rem;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.sidebar-flyout .flyout-item:hover {
  background-color: color-mix(in srgb, var(--lucid-theme-contrast) 8%, transparent);
  color: var(--lucid-theme-contrast);
}

.sidebar-flyout .flyout-item.active {
  background-color: var(--bs-sidebar-bg-active, #002b52);
  color: var(--lucid-theme-contrast);
  font-weight: 600;
  border-left: 3px solid var(--bs-sidebar-border-active, var(--bs-primary));
}

.sidebar-flyout .flyout-item i {
  margin-right: 0.5rem;
  font-size: 1rem;
}

/* Hide the old floating toggle (no longer needed) */
.sidebar-float-toggle {
  display: none !important;
}

.sidebar-nav-item {
  color: var(--bs-sidebar-text-inactive);
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  border-left: 3px solid transparent;
  transition: all 0.2s ease-in-out;
}
.sidebar-nav-item:hover {
  color: var(--bs-sidebar-text-hover);
  background-color: color-mix(in srgb, var(--lucid-theme-contrast) 5%, transparent);
}
.sidebar-nav-item.active {
  color: var(--bs-sidebar-text-active);
  background-color: var(--bs-sidebar-bg-active);
  border-left-color: var(--bs-sidebar-border-active);
  font-weight: 600;
}

.sidebar .nav-link {
  border-radius: 0.25rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--bs-sidebar-text-inactive, #ffffff) !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar .nav-link:hover {
  background-color: color-mix(in srgb, var(--lucid-theme-contrast) 5%, transparent);
  color: var(--bs-sidebar-text-hover, #ffffff) !important;
}
.sidebar .nav-link.active {
  background-color: var(--bs-sidebar-bg-active) !important;
  color: var(--bs-sidebar-text-active) !important;
  font-weight: 600;
  border-left: 3px solid var(--bs-sidebar-border-active, var(--bs-primary));
}

/* ── Sidebar collapsible toggle ──────────────────────────────── */
.btn-toggle {
  background: transparent;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.25rem;
  transition: background-color 0.15s ease;
  cursor: pointer;
  color: var(--bs-sidebar-text-inactive, #ffffff) !important;
}
.btn-toggle:hover {
  background-color: color-mix(in srgb, var(--lucid-theme-contrast) 5%, transparent);
  color: var(--bs-sidebar-text-hover, #ffffff) !important;
}
.btn-toggle::after { display: none; }

/* Chevron rotation — points down when collapsed, flips up when expanded */
.sidebar [data-bs-toggle="collapse"] .bi-chevron-down,
.btn-toggle .bi-chevron-down {
  transition: transform 0.2s ease;
}
.sidebar [data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down,
.btn-toggle:not(.collapsed) .bi-chevron-down {
  transform: rotate(180deg);
}

/* ── Top Nav ─────────────────────────────────────────────────── */
.top-nav {
  z-index: 1030;
  background-color: #FFFFFF;
  border-bottom: 3px solid var(--bs-primary, #001e3b);
}

.tenant-logo {
  height: 24px;
  max-width: 140px;
  object-fit: contain;
  vertical-align: middle;
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  background-color: #F3F2F1;
}

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
}

/* ── Utility Classes ─────────────────────────────────────────── */
.text-truncate-cell {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Notification System ─────────────────────────────────────── */

/* Bell badge pulse on new notification */
.notification-badge {
  font-size: 0.55rem;
  padding: 0.15em 0.35em;
  animation: badge-pulse 0.6s ease-out;
}
@@keyframes badge-pulse {
  0% { transform: translate(30%, -50%) scale(1.4); }
  100% { transform: translate(30%, -50%) scale(1); }
}

/* Notification panel items */
.notification-item {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #eee;
  cursor: default;
  transition: background-color 0.15s ease;
}
.notification-item:hover {
  background-color: #f8f9fa;
}
.notification-item.unread {
  background-color: #eef6ff;
  border-left: 3px solid var(--bs-primary, #001e3b);
}
.notification-item.unread:hover {
  background-color: #dceeff;
}

/* Clickable notification body */
.notification-body {
  cursor: pointer;
}

/* Notification action buttons (tick / trash) */
.notification-actions {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex-shrink: 0;
}
.notification-actions .btn {
  font-size: 1rem;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast animation */
.notification-toast {
  animation: slide-in-right 0.3s ease-out;
}
@@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Toast header compact */
.notification-toast .toast-header {
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}
.notification-toast .toast-body {
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}

/* ── Theme Picker (shared by login page + top nav) ───────────── */
.theme-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background-color: var(--lucid-theme, #001e3b);
  flex-shrink: 0;
}

.theme-menu {
  max-height: 320px;
  overflow-y: auto;
  min-width: 180px;
}

.theme-option,
.theme-option-nav {
  font-size: 0.8125rem;
}

.theme-option.active,
.theme-option-nav.active {
  background-color: #e9ecef;
}