/**
 * MyMortgage Design System
 * Allineamento visivo alla sezione MyLeads
 *
 * Variabili, componenti e stili riutilizzabili
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
  /* Layout */
  --app-navbar-height: 56px;
  --app-content-padding: 1rem;
  --app-container-max: 100%;

  /* Shadows */
  --app-shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --app-shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
  --app-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.1);
  --app-shadow-lg: 0 0.5rem 1.5rem rgba(0,0,0,0.12);

  /* Border radius */
  --app-radius-xs: 0.25rem;
  --app-radius-sm: 0.375rem;
  --app-radius: 0.5rem;
  --app-radius-lg: 0.75rem;
  --app-radius-xl: 1rem;

  /* Transitions */
  --app-transition-fast: 0.15s ease;
  --app-transition: 0.2s ease;
  --app-transition-slow: 0.3s ease;
  --app-transition-snappy: 0.3s cubic-bezier(0.16, 1, 0.3, 1);

  /* Status colors (light variants) */
  --app-success-light: rgba(25, 135, 84, 0.1);
  --app-warning-light: rgba(255, 193, 7, 0.1);
  --app-danger-light: rgba(220, 53, 69, 0.1);
  --app-primary-light: rgba(13, 110, 253, 0.1);
  --app-info-light: rgba(23, 162, 184, 0.1);

  /* Spacing */
  --app-gap-xs: 0.25rem;
  --app-gap-sm: 0.5rem;
  --app-gap: 1rem;
  --app-gap-lg: 1.5rem;
  --app-gap-xl: 2rem;
}

[data-bs-theme="dark"] {
  --app-shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --app-shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.25);
  --app-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.3);
  --app-shadow-lg: 0 0.5rem 1.5rem rgba(0,0,0,0.35);

  --app-success-light: rgba(25, 135, 84, 0.15);
  --app-warning-light: rgba(255, 193, 7, 0.12);
  --app-danger-light: rgba(220, 53, 69, 0.15);
  --app-primary-light: rgba(13, 110, 253, 0.15);
  --app-info-light: rgba(23, 162, 184, 0.15);
}


/* ============================================
   TYPOGRAPHY — Inter
   ============================================ */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   FOCUS STATES — Accessibility
   ============================================ */
:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  border-radius: var(--app-radius-xs);
}

.btn:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  box-shadow: none;
}

.form-control:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: -1px;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

[data-bs-theme="dark"] :focus-visible {
  outline-color: #58a6ff;
}

[data-bs-theme="dark"] .form-control:focus-visible,
[data-bs-theme="dark"] .form-select:focus-visible {
  outline-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  box-shadow: var(--app-shadow-sm) !important;
  border-bottom: 1px solid var(--bs-border-color) !important;
  padding: 0.4rem 1rem !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: box-shadow var(--app-transition);
}

.navbar .navbar-brand img {
  transition: opacity var(--app-transition);
}
.navbar .navbar-brand:hover img {
  opacity: 0.8;
}

/* Nav tabs in navbar */
.navbar .navbar-nav .nav-link {
  padding: 0.4rem 0.85rem;
  margin: 0 0.15rem;
  border-radius: var(--app-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--app-transition);
  white-space: nowrap;
}

.navbar .navbar-nav .nav-link:hover {
  background: var(--bs-tertiary-bg);
}

.navbar .navbar-nav .nav-link.active {
  background: var(--bs-primary);
  color: #fff !important;
}

.navbar .navbar-nav .nav-link .badge {
  font-size: 0.65rem;
  padding: 0.2em 0.5em;
  vertical-align: middle;
  margin-left: 0.25rem;
}


/* ============================================
   PAGE HEADER
   ============================================ */
.app-page-header,
#toolbar {
  padding: 0.5rem 0;
  margin-bottom: 0;
}

.app-page-header h5,
.app-page-header h4 {
  font-weight: 600;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-page-header .badge {
  font-size: 0.75rem;
  font-weight: 500;
}


/* ============================================
   CARDS
   ============================================ */
.app-card {
  border: none;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  transition: box-shadow var(--app-transition), transform var(--app-transition);
}

.app-card:hover {
  box-shadow: var(--app-shadow);
}

.app-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color);
  font-weight: 600;
  padding: 0.75rem 1rem;
}

.app-card .card-body {
  padding: 1rem;
}


/* ============================================
   TABLES (allineamento MyLeads)
   ============================================ */

/* Bootstrap Table overrides */
.bootstrap-table .fixed-table-container {
  border: 1px solid var(--bs-border-color) !important;
  border-radius: var(--app-radius);
  overflow: hidden;
}

.bootstrap-table .fixed-table-header {
  border-bottom: 2px solid var(--bs-border-color);
}

.bootstrap-table .fixed-table-header th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--bs-secondary-color);
  padding: 0.6rem 0.5rem !important;
  border: none !important;
  background: var(--bs-body-bg) !important;
}

.bootstrap-table .fixed-table-body td {
  padding: 0.5rem !important;
  vertical-align: middle;
  font-size: 0.875rem;
  border-color: var(--bs-border-color);
}

/* Row hover */
.bootstrap-table .fixed-table-body tr {
  transition: background-color var(--app-transition-fast);
}

.bootstrap-table .fixed-table-body tr:hover td {
  background-color: var(--app-primary-light) !important;
}

/* Striped rows - subtle */
.bootstrap-table .fixed-table-body tr:nth-child(even) td {
  background-color: var(--bs-tertiary-bg);
}
.bootstrap-table .fixed-table-body tr:nth-child(even):hover td {
  background-color: var(--app-primary-light) !important;
}

/* Search bar within Bootstrap Table */
.bootstrap-table .search input.form-control {
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-xs);
  border: 1px solid var(--bs-border-color);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color var(--app-transition), box-shadow var(--app-transition);
}

.bootstrap-table .search input.form-control:focus {
  box-shadow: 0 0 0 0.2rem var(--app-primary-light);
  border-color: var(--bs-primary);
}

/* Footer (totals) — prominent and clearly visible */
.bootstrap-table .fixed-table-footer td {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.75rem 0.5rem !important;
  border-top: 2px solid var(--bs-primary);
  background: var(--bs-tertiary-bg) !important;
  color: var(--bs-body-color);
}

/* Scrollbar styling */
.bootstrap-table .fixed-table-body::-webkit-scrollbar {
  width: 6px;
}
.bootstrap-table .fixed-table-body::-webkit-scrollbar-track {
  background: transparent;
}
.bootstrap-table .fixed-table-body::-webkit-scrollbar-thumb {
  background: var(--bs-secondary-bg);
  border-radius: 3px;
}
.bootstrap-table .fixed-table-body::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary-color);
}


/* ============================================
   BADGES (percentuale completamento)
   ============================================ */
.badge-percent {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.65em;
  border-radius: 50rem;
  min-width: 3rem;
  text-align: center;
}

.badge-percent-danger { background: var(--app-danger-light); color: #dc3545; }
.badge-percent-warning { background: var(--app-warning-light); color: #b45309; }
.badge-percent-primary { background: var(--app-primary-light); color: #0d6efd; }
.badge-percent-success { background: var(--app-success-light); color: #198754; }

[data-bs-theme="dark"] .badge-percent-warning { color: #ffc107; }
[data-bs-theme="dark"] .badge-percent-danger { color: #f87171; }
[data-bs-theme="dark"] .badge-percent-primary { color: #60a5fa; }
[data-bs-theme="dark"] .badge-percent-success { color: #4ade80; }


/* ============================================
   PRACTICE DETAIL — MODULE LIST ITEMS
   ============================================ */

/* Module list container */
#ul1 {
  padding: 0;
}

#ul1 .list-group-item {
  border: none;
  border-left: 3px solid var(--bs-border-color);
  border-radius: var(--app-radius) !important;
  box-shadow: var(--app-shadow-xs);
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  transition: box-shadow var(--app-transition), border-color var(--app-transition);
  background: var(--bs-body-bg);
}

#ul1 .list-group-item:hover {
  box-shadow: var(--app-shadow-sm);
}

/* Complete module: green left border */
#ul1 .list-group-item:has(.bi-check2-all) {
  border-left-color: #198754;
}

/* Incomplete module: amber left border */
#ul1 .list-group-item:has(.bi-x-circle) {
  border-left-color: #dc3545;
}

/* Field name input — more readable */
#ul1 .form-control.epmds {
  background: var(--bs-tertiary-bg) !important;
  border: 1px solid var(--bs-border-color);
  font-weight: 600;
}

#ul1 textarea.form-control.epmds {
  font-weight: 400;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Upload/Download action bar */
#ul1 .idrow .d-flex.justify-content-between {
  margin: 0.5rem 0 !important;
  padding: 0.5rem 0.75rem;
  background: var(--bs-tertiary-bg);
  border-radius: var(--app-radius-sm);
}

#ul1 .idrow .d-flex span[role="button"] {
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--app-radius-sm);
  transition: all var(--app-transition);
}

#ul1 .idrow .d-flex span[role="button"]:hover {
  background: var(--app-primary-light);
}

/* Download button — different color */
#ul1 .idrow .d-flex .total_item_files {
  color: var(--bs-success) !important;
}

#ul1 .idrow .d-flex .total_item_files:hover {
  background: var(--app-success-light) !important;
}

/* File list items */
#ul1 .nfls {
  padding: 0.5rem 0.25rem !important;
  margin-top: 0.25rem !important;
  border-radius: var(--app-radius-xs);
  transition: background var(--app-transition-fast);
  border-top: 1px solid var(--bs-border-color) !important;
}

#ul1 .nfls:hover {
  background: var(--bs-tertiary-bg);
}

/* File link */
#ul1 .nfls a.text-muted {
  font-size: 0.825rem;
  word-break: break-all;
  transition: color var(--app-transition-fast);
}

#ul1 .nfls:hover a.text-muted {
  color: var(--bs-primary) !important;
}

/* View status */
#ul1 .nfls .text-secondary {
  font-size: 0.75rem;
}

#ul1 .nfls .confirm-view {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  background: var(--app-primary-light);
  border-radius: var(--app-radius-xs);
  transition: background var(--app-transition);
}

#ul1 .nfls .confirm-view:hover {
  background: var(--app-primary-light);
  opacity: 0.8;
}

/* Delete button — subtle until hover */
#ul1 .nfls .text-danger[role="button"] {
  font-size: 0.75rem;
  opacity: 0.4;
  transition: opacity var(--app-transition-fast);
}

#ul1 .nfls:hover .text-danger[role="button"] {
  opacity: 1;
}

/* Delete/drag handle column */
#ul1 .col-sm-1 {
  opacity: 0.5;
  transition: opacity var(--app-transition);
}

#ul1 .list-group-item:hover .col-sm-1 {
  opacity: 1;
}

/* Comment textarea in modules */
#ul1 textarea.kptx {
  font-size: 0.85rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--app-radius-sm);
  background: var(--bs-tertiary-bg);
}

/* ============================================
   PRACTICE DETAIL — HEADER BAR
   ============================================ */

/* Fixed sub-header (practice info bar) */
.container-fluid.fixed-top.bg-body {
  box-shadow: var(--app-shadow-xs);
  padding: 0.5rem 1rem !important;
  border-bottom: 1px solid var(--bs-border-color) !important;
}

/* Practice number */
.container-fluid.fixed-top h6,
.container-fluid.fixed-top .h6 {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Navigation tabs in practice header */
.container-fluid.fixed-top .nav-link {
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--app-radius-sm);
  transition: all var(--app-transition);
}

.container-fluid.fixed-top .nav-link:hover {
  background: var(--bs-tertiary-bg);
}

/* Progress percentage badge */
#percent {
  font-weight: 700;
  font-size: 0.9rem;
}


/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  min-width: 260px;
  max-width: 400px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-toast.removing {
  animation: toastOut 0.25s ease-in forwards;
}

.app-toast-success { background: rgba(25, 135, 84, 0.92); }
.app-toast-error { background: rgba(220, 53, 69, 0.92); }
.app-toast-warning { background: rgba(255, 193, 7, 0.92); color: #333; }
.app-toast-info { background: rgba(13, 110, 253, 0.92); }

.app-toast i { font-size: 1.1rem; flex-shrink: 0; }

.app-toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 1rem;
  line-height: 1;
}
.app-toast-close:hover { opacity: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

/* ============================================
   DROPDOWN — Snappy animation
   ============================================ */
.dropdown-menu {
  animation: dropdownIn var(--app-transition-snappy);
  transform-origin: top;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: scaleY(0.95) translateY(-4px); }
  to { opacity: 1; transform: scaleY(1) translateY(0); }
}

/* ============================================
   PROGRESS BAR — Percentage in tables
   ============================================ */
.progress-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 80px;
}

.progress-mini-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bs-border-color);
  overflow: hidden;
  min-width: 45px;
  position: relative;
}

.progress-mini-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-mini-text {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ============================================
   FILE TYPE ICONS
   ============================================ */
.file-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.file-icon-pdf { color: #dc3545; }
.file-icon-img { color: #0d6efd; }
.file-icon-doc { color: #0d6efd; }
.file-icon-xls { color: #198754; }
.file-icon-zip { color: #d97706; }
.file-icon-txt { color: #6c757d; }
.file-icon-default { color: var(--bs-secondary); }

/* ============================================
   PENDING CONFIRMATION BADGE — per module
   ============================================ */
.pending-confirm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 50rem;
}

.pending-confirm-badge .bi {
  font-size: 0.85rem;
}

.pending-confirm-badge .pending-count {
  font-weight: 700;
  font-size: 0.85rem;
}

[data-bs-theme="dark"] .pending-confirm-badge {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.3);
  color: #fbbf24;
}

/* ============================================
   CONFIRM MODAL — Elegant delete confirmation
   ============================================ */
#confirmModal .modal-dialog {
  max-width: 400px;
}

#confirmModal .modal-body {
  text-align: center;
  padding: 1.5rem 1rem;
}

#confirmModal .confirm-icon {
  font-size: 2.5rem;
  color: #dc3545;
  margin-bottom: 0.75rem;
}

#confirmModal .confirm-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

#confirmModal .confirm-text {
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

#confirmModal .modal-footer {
  justify-content: center;
  gap: 0.75rem;
  border-top: none;
  padding-top: 0;
}

/* ============================================
   PAGE LOADER — Full-screen overlay with spinner
   ============================================ */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-body-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Spinner ring */
.page-loader-spinner {
  position: relative;
  width: 48px;
  height: 48px;
}

.page-loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bs-border-color);
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: loaderSpin 0.8s linear infinite;
}

.page-loader-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--bs-primary);
  border-radius: 50%;
  animation: loaderPulse 0.8s ease-in-out infinite alternate;
}

@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}

@keyframes loaderPulse {
  from { opacity: 0.4; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

/* Content reveal after loader */
body.page-ready > *:not(.page-loader):not(#spinner):not(#message) {
  animation: contentReveal 0.35s ease-out;
}

@keyframes contentReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ============================================
   LOADING SKELETON
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bs-tertiary-bg) 25%,
    var(--bs-secondary-bg) 50%,
    var(--bs-tertiary-bg) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--app-radius-xs);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row {
  height: 2.5rem;
  margin-bottom: 0.5rem;
}

.skeleton-text {
  height: 0.875rem;
  width: 60%;
  margin-bottom: 0.5rem;
}

.skeleton-badge {
  height: 1.2rem;
  width: 3rem;
  border-radius: 50rem;
}


/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h6 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 300px;
  margin: 0 auto;
}


/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.3s ease forwards;
}

/* Note: row animations removed — incompatible with virtual-scroll */


/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* ============================================
   LAYOUT — Full viewport, no page scroll
   ============================================ */

/* Dashboard page: fill viewport exactly, no outer scrollbar
   ONLY when showing table lists (not practice detail) */
body.dashboard-page {
  height: 100vh;
  overflow: hidden;
}

/* When practice detail is shown (has #ul1 module list),
   allow scrolling — JS adds this class */
body.dashboard-page.page-scrollable {
  height: auto;
  overflow: auto;
}

/* Free the html element from the inline `html, body {height:100%}` rule
   (inc/header.php) when page scrolling is requested, unless the chat
   sidebar layout is in use (handled separately below). */
html:has(body.page-scrollable):not(:has(.chat-sidebar)) {
  height: auto;
}

/* Content area below fixed navbar */
.app-content {
  margin-top: var(--app-navbar-height);
  padding: 0 var(--app-content-padding);
}

/* Bootstrap Table footer (Totale): visually distinct */
.bootstrap-table .fixed-table-footer {
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  font-weight: 700;
}


/* Practice sub-header bar: position below navbar */
.container-fluid.fixed-top.bg-body[style*="margin-top"] {
  margin-top: var(--app-navbar-height) !important;
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-bottom: 1px solid var(--bs-border-color) !important;
  background-color: var(--bs-body-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Practice detail content: push below navbar (48px) + sub-header bar (~48px) + gap (10px) = 106px */
div[style*="margin-top:117px"],
div[style*="margin-top: 117px"] {
  margin-top: 106px !important;
}

/* Spacer div in practices list page */
div[style="margin-top: 60px;"] {
  margin-top: var(--app-navbar-height) !important;
}

/* Practice detail with chat: no page scroll at all */
html:has(body.page-scrollable .chat-sidebar) {
  overflow: hidden;
}

/* Practice detail: main container fits viewport exactly */
body.page-scrollable .container-fluid.h-100 {
  height: calc(100vh - 104px) !important;
  max-height: calc(100vh - 104px) !important;
  overflow: hidden;
}

/* Modules column scrolls internally when content is long */
body.page-scrollable .container-fluid.h-100 > .row > .col-md-8 {
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-border-color) transparent;
}

body.page-scrollable .container-fluid.h-100 > .row > .col-md-8::-webkit-scrollbar {
  width: 4px;
}
body.page-scrollable .container-fluid.h-100 > .row > .col-md-8::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 2px;
}


/* ============================================
   PRACTICE DETAIL — Module cards restyling
   ============================================ */

/* Module list items: card-like appearance */
#ul1 > .list-group-item {
  border: none !important;
  border-left: 3px solid var(--bs-border-color) !important;
  margin-bottom: 0.75rem;
  border-radius: var(--app-radius-sm) !important;
  background: var(--bs-body-bg);
  box-shadow: var(--app-shadow-xs);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

#ul1 > .list-group-item:hover {
  box-shadow: var(--app-shadow-sm), 0 0 0 1px rgba(13, 110, 253, 0.12);
  border-left-color: var(--bs-primary) !important;
  background: color-mix(in srgb, var(--bs-body-bg) 96%, var(--bs-primary));
  transform: translateX(2px);
}

[data-bs-theme="dark"] #ul1 > .list-group-item:hover {
  background: rgba(13, 110, 253, 0.06);
}

/* Completed module: green left border */
#ul1 > .list-group-item .bi-check2-all {
  color: var(--bs-success) !important;
}

/* Field name input: cleaner look */
#ul1 .form-floating .form-control[readonly] {
  background: transparent !important;
  border: none;
  border-bottom: 1px solid var(--bs-border-color);
  border-radius: 0;
  padding-left: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

#ul1 .form-floating .form-control[readonly]:focus {
  box-shadow: none;
}

/* Description textarea: cleaner */
#ul1 .form-floating textarea.form-control[readonly] {
  background: transparent !important;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--app-radius-sm);
  font-size: 0.85rem;
  resize: none;
}

/* Upload/Download action buttons */
#ul1 .d-flex.justify-content-between.my-3.text-primary span[role="button"] {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--app-radius-sm);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all var(--app-transition);
  border: 1px solid transparent;
}

/* Upload button style */
#ul1 .d-flex.justify-content-between.my-3.text-primary span[role="button"]:first-child {
  background: var(--app-primary-light);
  border-color: rgba(13, 110, 253, 0.2);
}

#ul1 .d-flex.justify-content-between.my-3.text-primary span[role="button"]:first-child:hover {
  background: rgba(13, 110, 253, 0.2);
  border-color: var(--bs-primary);
}

/* Download button style */
#ul1 .d-flex.justify-content-between.my-3.text-primary span[role="button"]:last-child {
  background: var(--app-success-light);
  color: var(--bs-success) !important;
  border-color: rgba(25, 135, 84, 0.2);
}

#ul1 .d-flex.justify-content-between.my-3.text-primary span[role="button"]:last-child:hover {
  background: rgba(25, 135, 84, 0.2);
  border-color: var(--bs-success);
}

/* File list items */
#ul1 .nfls {
  padding: 0.5rem 0 !important;
  margin-top: 0.25rem !important;
  border-top: 1px solid var(--bs-border-color) !important;
  transition: background var(--app-transition);
}

#ul1 .nfls:hover {
  background: var(--bs-tertiary-bg);
  border-radius: var(--app-radius-xs);
}

/* File link */
#ul1 .nfls a.text-muted {
  color: var(--bs-body-color) !important;
  text-decoration: none !important;
  font-size: 0.85rem;
}

#ul1 .nfls a.text-muted:hover {
  color: var(--bs-primary) !important;
}

/* Viewed date */
#ul1 .nfls .text-muted.small,
#ul1 .nfls .text-secondary {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Confirm view button */
#ul1 .confirm-view {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(13, 110, 253, 0.3);
  border-radius: var(--app-radius-sm);
  background: var(--app-primary-light);
  transition: all var(--app-transition);
}

#ul1 .confirm-view:hover {
  background: rgba(13, 110, 253, 0.15);
  border-color: var(--bs-primary);
}

/* Delete button in file list */
#ul1 .nfls .text-danger[role="button"],
#ul1 .nfls span.text-danger {
  font-size: 0.8rem;
  opacity: 0.5;
  transition: all var(--app-transition);
  padding: 0.25rem 0.5rem;
  border-radius: var(--app-radius-sm);
}

#ul1 .nfls .text-danger[role="button"]:hover,
#ul1 .nfls span.text-danger:hover {
  opacity: 1;
  background: rgba(220, 53, 69, 0.1);
}

/* Delete/Remove module icon (X circle) — smaller and subtler */
#ul1 .text-danger .bi-x-circle {
  opacity: 0.5;
  transition: opacity var(--app-transition);
}

#ul1 .text-danger .bi-x-circle:hover {
  opacity: 1;
}

/* Drag handle — subtler */
#ul1 .grip-vertical {
  opacity: 0.3;
  transition: opacity var(--app-transition);
}

#ul1 .list-group-item:hover .grip-vertical {
  opacity: 0.6;
}

/* ============================================
   DRAG & DROP — Module drop zones
   ============================================ */

/* When dragging over a module: highlight border + background */
#ul1 > .list-group-item.drop-active {
  border-left-color: var(--bs-primary) !important;
  border-left-width: 4px !important;
  background: var(--app-primary-light) !important;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25), var(--app-shadow-sm) !important;
  transition: all 0.15s ease;
}

/* Drop zone hint (appears on drag) */
#ul1 > .list-group-item.drop-active .idrow::after {
  content: 'Rilascia il file qui';
  display: block;
  text-align: center;
  padding: 0.75rem;
  margin-top: 0.5rem;
  border: 2px dashed var(--bs-primary);
  border-radius: var(--app-radius-sm);
  color: var(--bs-primary);
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(13, 110, 253, 0.05);
  animation: dropPulse 1.5s ease-in-out infinite;
}

@keyframes dropPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

[data-bs-theme="dark"] #ul1 > .list-group-item.drop-active {
  background: rgba(13, 110, 253, 0.1) !important;
}

/* ============================================
   PENDING FILE — After drop or file picker
   ============================================ */

/* File pending upload: subtle highlight */
.file-pending {
  background: var(--app-primary-light);
  border-left: 3px solid var(--bs-primary) !important;
  border-radius: var(--app-radius-sm);
  padding: 0.5rem 0.75rem !important;
  margin: 0.35rem 0 !important;
  animation: filePendingIn 0.3s ease-out;
}

@keyframes filePendingIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-pending .bi-file-earmark-arrow-up {
  font-size: 1.1rem;
}

/* Uploading state: spinner replaces content */
.file-pending .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15rem;
}

[data-bs-theme="dark"] .file-pending {
  background: rgba(13, 110, 253, 0.1);
}

/* ============================================
   MICRO-INTERACTIONS — Polish
   ============================================ */

/* Module cards: quick subtle fade-in on page load */
body.page-ready #ul1 > .list-group-item {
  animation: moduleSlideIn 0.25s ease-out both;
}

body.page-ready #ul1 > .list-group-item:nth-child(1) { animation-delay: 0s; }
body.page-ready #ul1 > .list-group-item:nth-child(2) { animation-delay: 0.03s; }
body.page-ready #ul1 > .list-group-item:nth-child(3) { animation-delay: 0.06s; }
body.page-ready #ul1 > .list-group-item:nth-child(4) { animation-delay: 0.09s; }
body.page-ready #ul1 > .list-group-item:nth-child(n+5) { animation-delay: 0.12s; }

@keyframes moduleSlideIn {
  from {
    opacity: 0.3;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Checkbox: slightly larger and with pointer */
#ul1 .ck1 {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  margin-top: 0.35rem;
}

/* ============================================
   MODALS — Smooth open/close, no flash
   ============================================ */

/* Backdrop: smoother fade */
.modal-backdrop {
  transition: opacity 0.2s ease !important;
}

.modal-backdrop.show {
  opacity: 0.5 !important;
}

/* Modal dialog: smooth slide-in */
.modal.fade .modal-dialog {
  transition: transform var(--app-transition-snappy), opacity var(--app-transition-snappy) !important;
  transform: translateY(-20px);
  opacity: 0;
}

.modal.show .modal-dialog {
  transform: translateY(0);
  opacity: 1;
}

/* Modal content: clean rounded corners and shadow */
.modal-content {
  border: none;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-lg, 0 1rem 3rem rgba(0,0,0,0.175));
  overflow: hidden;
}

/* Modal header: subtle bottom border */
.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0.85rem 1rem;
}

/* Modal footer: subtle top border */
.modal-footer {
  border-top: 1px solid var(--bs-border-color);
  padding: 0.65rem 1rem;
}

/* Prevent body flash when modal opens */
body.modal-open {
  padding-right: 0 !important;
}

/* AJAX spinner overlay — theme-aware */
.ajax-overlay {
  background: rgba(255, 255, 255, 0.4) !important;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

[data-bs-theme="dark"] .ajax-overlay {
  background: rgba(0, 0, 0, 0.4) !important;
}

/* Button press effect */
#ul1 .btn:active {
  transform: scale(0.96);
}

/* Focus ring — handled globally in FOCUS STATES section */

/* ============================================
   MY DRIVE — File manager styling
   ============================================ */

/* Drive header */
#getDrive {
  margin-top: 0.5rem;
}

/* Folder tree container — nested lists indented */
.dd-list {
  padding-left: 2rem;
  position: relative;
}

/* Tree connector line for nested items */
.dd-list .dd-list {
  border-left: 2px solid var(--bs-border-color);
  margin-left: 0.5rem;
  padding-left: 1.5rem;
}

#folderList {
  padding-left: 0;
  border-left: none;
}

/* Each folder item */
.dd-item {
  margin-bottom: 0.25rem !important;
}

/* Folder button group */
.dd-item .btn-group.bbg {
  border-radius: var(--app-radius-sm) !important;
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
  transition: all var(--app-transition);
  border: 1px solid var(--bs-border-color) !important;
}

.dd-item .btn-group.bbg .bbc {
  border: none !important;
}

.dd-item .btn-group.bbg:hover {
  box-shadow: var(--app-shadow);
  transform: translateX(3px);
  border-color: var(--bs-primary) !important;
}

/* Drag handle */
.dd-item .dd-handle {
  cursor: grab;
  opacity: 0.35;
  font-size: 0.75rem;
  padding: 0.45rem 0.4rem !important;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -1px;
}

.dd-item .btn-group.bbg:hover .dd-handle {
  opacity: 0.7;
}

/* Folder name button */
.dd-item .btn-group .btn:not(.dd-handle):not(.folderIcon) {
  font-weight: 600;
  font-size: 0.82rem;
  text-align: left;
  letter-spacing: 0.01em;
}

/* Folder icon */
.dd-item .folderIcon {
  padding: 0.45rem 0.6rem !important;
}

.dd-item .folderIcon svg {
  color: #d97706;
  width: 18px;
  height: 18px;
}

/* Active/selected folder */
.dd-item .btn-group.bbg .bbc.active,
.dd-item .btn-group.bbg:focus-within {
  border-color: var(--bs-primary) !important;
  background: var(--app-primary-light);
}

/* Expand/collapse button */
.dd-item > button[data-action] {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 24px;
  text-align: center;
  color: var(--bs-secondary);
  cursor: pointer;
  margin-right: 4px;
  vertical-align: middle;
  transition: all var(--app-transition);
  overflow: hidden;
  text-indent: -9999px;
  position: relative;
}

.dd-item > button[data-action]:hover {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: white;
}

/* Show +/- via pseudo-element */
.dd-item > button[data-action]::after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-indent: 0;
  font-size: 1rem;
  font-weight: 700;
  color: inherit;
}

.dd-item > button[data-action="expand"]::after {
  content: '+';
}

.dd-item > button[data-action="collapse"]::after {
  content: '\2212';
}

.dd-item > button[data-action]:hover::after {
  color: white;
}

[data-bs-theme="dark"] .dd-item > button[data-action] {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
}

/* Expand/collapse icons for items with children */
.dd-item > button[data-action] {
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--bs-secondary);
  font-size: 0.75rem;
}

/* Folder content area (right panel) */
#folderbox {
  min-height: 200px;
}

/* Dark mode */
[data-bs-theme="dark"] .dd-item .btn-group.bbg .btn {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .dd-item .folderIcon svg {
  color: #fbbf24;
}

/* ============================================
   SEARCH — Ricerca nelle pratiche
   ============================================ */

/* Search results table */
#results_container {
  border-radius: var(--app-radius-sm);
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
}

#results_container thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary);
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

#results_container tbody tr {
  transition: background var(--app-transition);
}

#results_container tbody tr:hover {
  background: var(--app-primary-light) !important;
}

#results_container tfoot td {
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-top: 2px solid var(--bs-border-color);
}

/* Search filters panel */
#advanced_search {
  box-shadow: var(--app-shadow-sm);
  border-radius: var(--app-radius) !important;
  padding: 1rem !important;
}

#advanced_search .form-floating {
  margin-bottom: 0;
}

#advanced_search .btn-primary {
  border-radius: var(--app-radius-sm);
  padding: 0.5rem 1.5rem;
}

/* ============================================
   PROFESSIONALS — Search & map layout
   ============================================ */

/* Map container */
#map {
  border-radius: var(--app-radius);
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
  min-height: 400px;
}

/* ============================================
   GENERAL FORM IMPROVEMENTS
   ============================================ */

/* Nuova pratica form */
.form-signin .form-control,
.form-signin .form-select,
.form-subscribe .form-control,
.form-subscribe .form-select {
  border-radius: var(--app-radius-sm);
}

/* ============================================
   CALENDAR — MyCalendar polish
   ============================================ */

/* Calendar grid cells */
.calendar-grid td,
table.table td[style*="cursor: pointer"] {
  transition: background var(--app-transition);
}

.calendar-grid td:hover,
table.table td[style*="cursor: pointer"]:hover {
  background: var(--app-primary-light) !important;
}

/* Navigation buttons (< >) */
.calendar-nav .btn-outline-secondary,
a.btn.btn-outline-secondary[title] {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* All modals: smoother backdrop */
.modal.fade .modal-dialog {
  transition: transform var(--app-transition-snappy);
}

.modal-content {
  border-radius: var(--app-radius);
  border: none;
  box-shadow: var(--app-shadow);
}

.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0.8rem 1rem;
}

.modal-footer {
  border-top: 1px solid var(--bs-border-color);
  padding: 0.6rem 1rem;
}

.modal-body.bg-light {
  background: var(--bs-tertiary-bg) !important;
}

/* ============================================
   GENERAL POLISH — All sections
   ============================================ */

/* Page titles (h5 with + buttons) */
h5 .text-decoration-none,
h5 a[data-bs-toggle="modal"] {
  font-size: 1.1rem;
  color: var(--bs-primary);
  transition: opacity var(--app-transition);
}

h5 .text-decoration-none:hover,
h5 a[data-bs-toggle="modal"]:hover {
  opacity: 0.7;
}

/* Inputs and selects: consistent sizing */
.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* All buttons: subtle transition */
.btn {
  transition: all 0.15s ease;
}

/* Text links in tables */
.table a {
  text-decoration: none;
}

.table a:hover {
  text-decoration: underline;
}

/* Empty state message styling */
.text-muted.text-center {
  padding: 2rem;
  font-style: italic;
}

/* Scrollbar styling for all scrollable areas */
.fixed-table-body::-webkit-scrollbar,
#ul1::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.fixed-table-body::-webkit-scrollbar-track,
#ul1::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.fixed-table-body::-webkit-scrollbar-thumb,
#ul1::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

.fixed-table-body::-webkit-scrollbar-thumb:hover,
#ul1::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary-color);
}

/* ============================================
   MODULE FILE LIST — Compact scrollable
   ============================================ */

/* File list container: ~3 full files visible, rest scrollable */
#ul1 .filename.form-text {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-border-color) transparent;
  word-break: break-all;
}

#ul1 .filename.form-text::-webkit-scrollbar {
  width: 4px;
}
#ul1 .filename.form-text::-webkit-scrollbar-track {
  background: transparent;
}
#ul1 .filename.form-text::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 2px;
}

/* File rows: prevent horizontal overflow */
#ul1 .filename.form-text .nfls {
  overflow: hidden;
}

#ul1 .filename.form-text .nfls a {
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Pending confirmation files: subtle left border */
.file-pending-confirm {
  border-left: 3px solid var(--bs-primary) !important;
  padding-left: 0.5rem;
  background: rgba(13, 110, 253, 0.04);
  border-radius: 0 var(--app-radius-sm) var(--app-radius-sm) 0;
}

[data-bs-theme="dark"] .file-pending-confirm {
  background: rgba(13, 110, 253, 0.08);
}

/* Pending confirmation badge */
.pending-confirm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--app-warning-light, #fef3c7);
  color: #92400e;
  border-radius: 50rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.pending-confirm-badge .pending-count {
  background: #d97706;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

[data-bs-theme="dark"] .pending-confirm-badge {
  background: rgba(217, 119, 6, 0.15);
  color: #fbbf24;
}
[data-bs-theme="dark"] .pending-confirm-badge .pending-count {
  background: #b45309;
}

/* ============================================
   RIGHT SIDEBAR — Chat / Messages
   ============================================ */
.col-md-4.bg-light,
.chat-sidebar {
  background: var(--bs-tertiary-bg) !important;
}

/* Chat sidebar layout: fixed height, independent scroll like WhatsApp */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 96px; /* navbar (48px) + practice bar (48px) */
  height: calc(100vh - 104px);
  max-height: calc(100vh - 104px);
  padding-bottom: 0 !important;
  overflow: hidden;
}

.chat-header {
  background: var(--bs-tertiary-bg);
  z-index: 10;
  flex-shrink: 0;
}

.chat-tabs .nav-link {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 50rem;
  color: var(--bs-secondary);
  transition: var(--app-transition);
}

.chat-tabs .nav-link.active {
  background: var(--bs-primary);
  color: white;
}

/* Scrollable messages area — fills space between header and input */
.chat-messages {
  flex: 1;
  min-height: 0; /* critical for flex overflow */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-border-color) transparent;
  /* Smooth scroll for programmatic scrolling */
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 2px;
}

/* Chat container */
.chat-sidebar .tab-content {
  padding: 0.5rem;
}

/* Input fixed at bottom of sidebar */
.chat-input {
  flex-shrink: 0;
  background: var(--bs-tertiary-bg);
  border-top: 1px solid var(--bs-border-color);
  z-index: 10;
}

.chat-input textarea {
  font-size: 0.85rem;
  border-radius: var(--app-radius-sm) !important;
  line-height: 1.4;
  min-height: 48px;
}

.chat-input .btn {
  border-radius: var(--app-radius-sm);
  padding: 0.35rem 0.6rem;
}

/* Chat bubble shared */
.col-md-4 .msgs,
.col-md-4 .msgr,
.col-md-4 .msgl {
  border: none !important;
  padding: 0;
  box-shadow: var(--app-shadow-sm);
}

.col-md-4 .msgs .popover-body,
.col-md-4 .msgr .popover-body,
.col-md-4 .msgl .popover-body {
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Right bubble (my messages) */
.col-md-4 .msgr {
  background: var(--bs-primary) !important;
  color: white !important;
  border-radius: 16px 16px 4px 16px !important;
}

.col-md-4 .msgr .popover-body {
  color: white;
}

/* Left bubble (other's messages) */
.col-md-4 .msgl {
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--bs-border-color) !important;
  border-radius: 16px 16px 16px 4px !important;
}

/* Customer tab bubble (no msgl/msgr class, uses bg-body border-info) */
.col-md-4 .bg-body.border-info {
  border: none !important;
  background: var(--bs-primary) !important;
  color: white !important;
  border-radius: 16px 16px 4px 16px !important;
  box-shadow: var(--app-shadow-sm);
}

.col-md-4 .bg-body.border-info .popover-body {
  color: white;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
}

/* Left side customer bubble */
.col-md-4 .flex-row .bg-body.border-info {
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--bs-border-color) !important;
  border-radius: 16px 16px 16px 4px !important;
}

.col-md-4 .flex-row .bg-body.border-info .popover-body {
  color: var(--bs-body-color);
}

/* Unread message highlight */
.col-md-4 .border-info.border-2 {
  border-left: 3px solid var(--bs-info) !important;
}

/* Timestamp under bubble */
.col-md-4 .d-flex .text-muted.form-text {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 2px;
  padding: 0 4px;
}

/* Remove old popover arrows from chat */
.col-md-4 .pp-right:after,
.col-md-4 .pp-left:before {
  display: none;
}

/* Chat input modal improvements */
#msg_text {
  min-height: 100px;
  border-radius: var(--app-radius-sm);
  resize: vertical;
}

/* Dark mode */
[data-bs-theme="dark"] .col-md-4 .msgl,
[data-bs-theme="dark"] .col-md-4 .flex-row .bg-body.border-info {
  background: var(--bs-dark-bg-subtle) !important;
  border-color: var(--bs-border-color) !important;
}


/* ============================================
   PAGE HEADERS — Toolbar restyling
   ============================================ */

/* Toolbar (contains title + search) */
#toolbar h5 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bs-body-color);
  letter-spacing: -0.01em;
  margin: 0.75rem 0 !important;
}

/* Bootstrap Table toolbar area (search + buttons) */
.bootstrap-table .fixed-table-toolbar {
  padding: 0.5rem 0;
}

/* Search input — rounder, modern */
.bootstrap-table .fixed-table-toolbar .search input {
  border-radius: var(--app-radius) !important;
  border: 1px solid var(--bs-border-color);
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  transition: border-color var(--app-transition), box-shadow var(--app-transition);
}

.bootstrap-table .fixed-table-toolbar .search input:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

[data-bs-theme="dark"] .bootstrap-table .fixed-table-toolbar .search input:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}


/* ============================================
   TABLE ENHANCEMENTS
   ============================================ */

/* Table header: uppercase, smaller, muted */
.bootstrap-table .fixed-table-header th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  border-bottom: 2px solid var(--bs-border-color) !important;
  padding: 0.6rem 0.5rem !important;
}

/* Table rows: smooth hover */
.bootstrap-table .fixed-table-body tr {
  transition: background-color var(--app-transition-fast);
}

.bootstrap-table .fixed-table-body tbody tr:hover {
  background-color: var(--bs-tertiary-bg) !important;
}

/* Alternating row colors (subtle) */
.bootstrap-table .fixed-table-body tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.015);
}

[data-bs-theme="dark"] .bootstrap-table .fixed-table-body tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Table cells: consistent padding */
.bootstrap-table .fixed-table-body td {
  padding: 0.55rem 0.5rem !important;
  vertical-align: middle;
  border-bottom: 1px solid var(--bs-border-color);
}

/* Links in table: cleaner */
.bootstrap-table .fixed-table-body td a {
  text-decoration: none;
  font-weight: 500;
}

.bootstrap-table .fixed-table-body td a:hover {
  text-decoration: underline;
}

/* Edit icon (pencil) — subtler */
.bootstrap-table .fixed-table-body .bi-pencil-square,
.bootstrap-table .fixed-table-body .bi-pencil {
  opacity: 0.4;
  transition: opacity var(--app-transition);
}

.bootstrap-table .fixed-table-body tr:hover .bi-pencil-square,
.bootstrap-table .fixed-table-body tr:hover .bi-pencil {
  opacity: 0.8;
}

/* Settings/Action icons in last column */
.bootstrap-table .fixed-table-body .bi-cloud-download,
.bootstrap-table .fixed-table-body .bi-gear {
  opacity: 0.4;
  transition: opacity var(--app-transition);
}

.bootstrap-table .fixed-table-body tr:hover .bi-cloud-download,
.bootstrap-table .fixed-table-body tr:hover .bi-gear {
  opacity: 0.8;
}

/* Input fields in table (mutuo presunto) */
.bootstrap-table .fixed-table-body input.form-control {
  border-radius: var(--app-radius-sm);
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  transition: border-color var(--app-transition);
}

.bootstrap-table .fixed-table-body input.form-control:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1);
}


/* ============================================
   EMPTY STATE
   ============================================ */
.bootstrap-table .no-records-found td {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--bs-secondary-color);
  font-size: 0.95rem;
}


/* ============================================
   SCROLLBAR — Thin for all scrollable areas
   ============================================ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bs-border-color) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary-color);
}


/* ============================================
   MODAL IMPROVEMENTS
   ============================================ */
.modal-content {
  border-radius: var(--app-radius-lg) !important;
  border: none !important;
  box-shadow: var(--app-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1rem 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--bs-border-color);
  padding: 0.75rem 1.25rem;
}

.modal-title {
  font-weight: 600;
  font-size: 1.05rem;
}


/* ============================================
   FORM IMPROVEMENTS
   ============================================ */
.form-control, .form-select {
  border-radius: var(--app-radius-sm);
  transition: border-color var(--app-transition), box-shadow var(--app-transition);
}

.form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}


/* ============================================
   BADGE IMPROVEMENTS
   ============================================ */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Notification badges on navbar */
.navbar .badge {
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
}


/* ============================================
   SELECTION HIGHLIGHT
   ============================================ */
::selection {
  background: rgba(13, 110, 253, 0.2);
  color: inherit;
}

[data-bs-theme="dark"] ::selection {
  background: rgba(13, 110, 253, 0.35);
}
