/* =============================================================================
 * TIEFFELUCE 2025 - Modern UI Redesign
 * Design: Minimal Clean, Mobile-First
 * Brand Color: #a51329 (Red)
 * =============================================================================*/

/* =============================================================================
 * FASE 1: DESIGN SYSTEM BASE - Variables CSS
 * =============================================================================*/
:root {
  /* Primary Colors */
  --tf-primary: #a51329;
  --tf-primary-hover: #8a0f22;
  --tf-primary-light: rgba(165, 19, 41, 0.08);
  --tf-primary-ring: rgba(165, 19, 41, 0.25);

  /* Neutral Colors */
  --tf-bg: #fafafa;
  --tf-bg-alt: #f5f5f5;
  --tf-card: #ffffff;
  --tf-border: #e5e5e5;
  --tf-border-light: #f0f0f0;

  /* Text Colors */
  --tf-text: #262626;
  --tf-text-muted: #737373;
  --tf-text-light: #a3a3a3;

  /* Status Colors */
  --tf-success: #10b981;
  --tf-success-light: rgba(16, 185, 129, 0.1);
  --tf-warning: #f59e0b;
  --tf-warning-light: rgba(245, 158, 11, 0.1);
  --tf-danger: #ef4444;
  --tf-danger-light: rgba(239, 68, 68, 0.1);
  --tf-info: #3b82f6;
  --tf-info-light: rgba(59, 130, 246, 0.1);

  /* Spacing */
  --tf-space-xs: 4px;
  --tf-space-sm: 8px;
  --tf-space-md: 16px;
  --tf-space-lg: 24px;
  --tf-space-xl: 32px;
  --tf-space-2xl: 48px;

  /* Border Radius */
  --tf-radius-sm: 8px;
  --tf-radius-md: 12px;
  --tf-radius-lg: 14px;
  --tf-radius-xl: 18px;
  --tf-radius-full: 999px;

  /* Shadows */
  --tf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --tf-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --tf-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --tf-shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.12);
  --tf-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --tf-shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);

  /* Transitions */
  --tf-transition-fast: 0.15s ease;
  --tf-transition-base: 0.2s ease;
  --tf-transition-slow: 0.3s ease;

  /* Z-Index */
  --tf-z-dropdown: 1000;
  --tf-z-sticky: 1020;
  --tf-z-modal: 1050;
  --tf-z-toast: 1080;
  --tf-z-fab: 99999;
}

/* =============================================================================
 * FASE 2: TIPOGRAFIA - Font Inter + Stili
 * =============================================================================*/

/* Body & General */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  color: var(--tf-text);
  background: var(--tf-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-weight: 600;
  color: var(--tf-text);
  letter-spacing: -0.02em;
}

h1, .h1 { font-size: 1.875rem; font-weight: 700; }
h2, .h2 { font-size: 1.5rem; font-weight: 600; }
h3, .h3 { font-size: 1.25rem; font-weight: 600; }
h4, .h4 { font-size: 1.125rem; font-weight: 600; }
h5, .h5 { font-size: 1rem; font-weight: 600; }
h6, .h6 { font-size: 0.875rem; font-weight: 600; }

/* Paragraphs & Body Text */
p, span, li, td, th, label, div {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Labels */
label, .form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tf-text);
  margin-bottom: var(--tf-space-sm);
}

/* Muted text */
.text-muted, small, .small {
  color: var(--tf-text-muted) !important;
}

/* =============================================================================
 * FASE 3: CARDS MODERNE
 * =============================================================================*/

.card {
  background: var(--tf-card);
  border: 1px solid var(--tf-border-light);
  border-radius: var(--tf-radius-lg) !important;
  box-shadow: var(--tf-shadow-card);
  transition: box-shadow var(--tf-transition-base), transform var(--tf-transition-base);
  overflow: hidden;
}

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

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--tf-border-light);
  padding: var(--tf-space-lg);
}

.card-header h4,
.card-header h5,
.card-header .card-title {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.card-body {
  padding: var(--tf-space-lg);
}

.card-footer {
  background: var(--tf-bg);
  border-top: 1px solid var(--tf-border-light);
  padding: var(--tf-space-md) var(--tf-space-lg);
}

/* Widget cards (Dashboard KPI) */
.widget-card,
.o-income .card,
.static-top-widget {
  border-radius: var(--tf-radius-lg) !important;
  border: none;
  box-shadow: var(--tf-shadow-card);
}

/* =============================================================================
 * FASE 4: BUTTONS - Stile Moderno
 * =============================================================================*/

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  border-radius: var(--tf-radius-md);
  padding: 10px 20px;
  font-size: 0.875rem;
  transition: all var(--tf-transition-fast);
  border: none;
  box-shadow: none;
}

/* Primary Button */
.btn-primary {
  background: var(--tf-primary) !important;
  border-color: var(--tf-primary) !important;
  color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--tf-primary-hover) !important;
  border-color: var(--tf-primary-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(165, 19, 41, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus {
  box-shadow: 0 0 0 3px var(--tf-primary-ring) !important;
}

/* Success Button override */
.btn-success {
  background-color: var(--tf-primary) !important;
  border-color: var(--tf-primary) !important;
}

.btn-success:hover,
.btn-success:focus {
  background-color: var(--tf-primary-hover) !important;
  border-color: var(--tf-primary-hover) !important;
}

/* Outline Buttons */
.btn-outline-primary {
  color: var(--tf-primary) !important;
  border: 1.5px solid var(--tf-primary) !important;
  background: transparent !important;
}

.btn-outline-primary:hover {
  background: var(--tf-primary) !important;
  color: #fff !important;
  transform: translateY(-1px);
}

.btn-outline-secondary {
  color: var(--tf-text-muted);
  border: 1.5px solid var(--tf-border);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--tf-bg);
  border-color: var(--tf-text-muted);
  color: var(--tf-text);
}

/* Light Button */
.btn-light,
.btn-primary-light {
  background: var(--tf-primary-light) !important;
  color: var(--tf-primary) !important;
  border: none;
}

.btn-light:hover,
.btn-primary-light:hover {
  background: rgba(165, 19, 41, 0.15) !important;
}

/* Icon Buttons */
.btn-icon,
.btn-sm.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tf-radius-md);
}

/* Small Buttons */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
  border-radius: var(--tf-radius-sm);
}

/* Large Buttons */
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--tf-radius-md);
}

/* Button Group */
.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--tf-radius-md) 0 0 var(--tf-radius-md);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--tf-radius-md) var(--tf-radius-md) 0;
}

/* =============================================================================
 * FASE 5: FORMS E INPUT
 * =============================================================================*/

.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
  font-family: 'Inter', sans-serif;
  height: 44px;
  padding: 10px 14px;
  font-size: 0.9375rem;
  border: 1.5px solid var(--tf-border);
  border-radius: var(--tf-radius-md);
  background: var(--tf-card);
  color: var(--tf-text);
  transition: border-color var(--tf-transition-fast), box-shadow var(--tf-transition-fast);
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--tf-primary) !important;
  box-shadow: 0 0 0 3px var(--tf-primary-ring) !important;
  outline: none;
}

.form-control::placeholder,
input::placeholder {
  color: var(--tf-text-light);
}

/* Textarea */
textarea.form-control {
  height: auto;
  min-height: 100px;
}

/* Input Group */
.input-group {
  border-radius: var(--tf-radius-md);
}

.input-group .form-control {
  border-radius: 0 var(--tf-radius-md) var(--tf-radius-md) 0;
}

.input-group-text {
  background: var(--tf-bg);
  border: 1.5px solid var(--tf-border);
  border-right: none;
  border-radius: var(--tf-radius-md) 0 0 var(--tf-radius-md);
  color: var(--tf-text-muted);
  padding: 10px 14px;
}

/* Form Group */
.form-group {
  margin-bottom: var(--tf-space-lg);
}

/* Checkbox & Radio */
.form-check-input {
  width: 18px;
  height: 18px;
  border: 2px solid var(--tf-border);
  border-radius: 4px;
}

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

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--tf-primary-ring);
}

/* Select2 Override */
.select2-container--default .select2-selection--single {
  height: 44px !important;
  border: 1.5px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-md) !important;
  padding: 8px 14px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 26px;
  color: var(--tf-text);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px;
}

.select2-dropdown {
  border: 1.5px solid var(--tf-border);
  border-radius: var(--tf-radius-md);
  box-shadow: var(--tf-shadow-lg);
}

/* iOS Zoom Prevention */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* =============================================================================
 * FASE 6: TABLES - DataTables Override
 * =============================================================================*/

.table {
  font-family: 'Inter', sans-serif;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  background: var(--tf-bg);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tf-text-muted);
  border-bottom: 2px solid var(--tf-border-light);
  padding: 14px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--tf-border-light);
  color: var(--tf-text);
}

.table tbody tr {
  transition: background-color var(--tf-transition-fast);
}

.table tbody tr:hover {
  background-color: var(--tf-bg) !important;
}

/* DataTables Specific */
.dataTables_wrapper {
  font-family: 'Inter', sans-serif;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  height: 38px;
  border: 1.5px solid var(--tf-border);
  border-radius: var(--tf-radius-sm);
  padding: 6px 12px;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--tf-primary);
  box-shadow: 0 0 0 3px var(--tf-primary-ring);
  outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--tf-radius-sm) !important;
  margin: 0 2px;
  padding: 6px 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--tf-primary) !important;
  border-color: var(--tf-primary) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--tf-primary-light) !important;
  border-color: var(--tf-primary-light) !important;
  color: var(--tf-primary) !important;
}

.dataTables_info {
  color: var(--tf-text-muted);
  font-size: 0.875rem;
}

/* Table Card */
.table-responsive {
  border-radius: var(--tf-radius-lg);
  overflow: hidden;
}

/* =============================================================================
 * FASE 7: SIDEBAR - Menu Moderno
 * =============================================================================*/

/* Sidebar Container */
.main-nav,
header.main-nav {
  background: var(--tf-card) !important;
  border-right: 1px solid var(--tf-border-light);
  box-shadow: none;
}

/* Sidebar User */
.sidebar-user {
  padding: var(--tf-space-lg);
  border-bottom: 1px solid var(--tf-border-light);
}

.sidebar-user h6 {
  font-weight: 600;
  color: var(--tf-text);
}

.sidebar-user p {
  color: var(--tf-text-muted);
  font-size: 0.8125rem;
}

/* Main Menu Title */
.sidebar-main-title {
  padding: var(--tf-space-md) var(--tf-space-lg) var(--tf-space-sm);
}

.sidebar-main-title h6 {
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tf-text-light) !important;
}

/* Menu Items */
.nav-menu > li > a,
.nav-menu .nav-link {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tf-text-muted);
  padding: 10px 16px;
  margin: 2px 12px;
  border-radius: var(--tf-radius-md);
  transition: all var(--tf-transition-fast);
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-menu > li > a:hover,
.nav-menu .nav-link:hover {
  background: var(--tf-bg);
  color: var(--tf-text);
}

/* Active State */
.nav-menu > li.active > a,
.nav-menu .nav-link.active,
.page-wrapper.compact-wrapper .page-body-wrapper header.main-nav .main-navbar .nav-menu > li.active .nav-link {
  background: var(--tf-primary-light) !important;
  color: var(--tf-primary) !important;
  font-weight: 600;
}

.nav-menu > li.active > a svg,
.nav-menu .nav-link.active svg {
  stroke: var(--tf-primary);
}

/* Menu Icons */
.nav-menu svg,
.nav-menu i[data-feather] {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: var(--tf-text-muted);
}

.nav-menu > li.active svg,
.nav-menu > li:hover svg {
  color: var(--tf-primary);
}

/* Menu Badges */
.nav-menu .menu-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-menu .menu-title .menu-badges {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--tf-radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
  color: #fff;
  background: var(--tf-primary);
}

.menu-badge.warn {
  background: var(--tf-warning);
}

.menu-badge.success {
  background: var(--tf-success);
}

/* Sidebar scroll */
.page-wrapper.compact-wrapper .page-body-wrapper header.main-nav .main-navbar .nav-menu {
  height: calc(100vh - 255px);
}

/* =============================================================================
 * FASE 8: HEADER - Semplificato e Pulito
 * =============================================================================*/

/* Header Container */
.page-main-header,
.main-header-right {
  background: var(--tf-card) !important;
  border-bottom: 1px solid var(--tf-border-light);
  box-shadow: none;
}

/* Logo Area */
.main-header-left {
  background: var(--tf-primary) !important;
}

.logo-wrapper img {
  max-width: 140px;
}

/* Toggle Button */
.toggle-sidebar {
  cursor: pointer;
  padding: 8px;
  border-radius: var(--tf-radius-sm);
}

.toggle-sidebar:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Search Bar */
.search-form {
  background: transparent !important;
}

.search-form .form-control-plaintext,
.search-form input {
  background: var(--tf-bg);
  border: 1.5px solid transparent;
  border-radius: var(--tf-radius-full);
  padding: 10px 16px 10px 40px;
  font-size: 0.875rem;
  height: 42px;
  transition: all var(--tf-transition-fast);
}

.search-form .form-control-plaintext:focus,
.search-form input:focus {
  background: var(--tf-card);
  border-color: var(--tf-border);
  box-shadow: var(--tf-shadow-sm);
}

.search-bg {
  position: relative;
}

.search-bg .fa-search {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tf-text-muted);
}

/* Nav Right Icons */
.nav-menus > li {
  padding: 0 6px;
}

.nav-menus > li > a,
.nav-menus .notification-box {
  width: 42px;
  height: 42px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: var(--tf-radius-md);
  transition: background var(--tf-transition-fast);
  color: var(--tf-text-muted);
}

.nav-menus > li > a:hover,
.nav-menus .notification-box:hover {
  background: var(--tf-bg);
}

.nav-menus svg {
  width: 20px;
  height: 20px;
}

/* KPI Header */
.nav-kpi {
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--tf-text-muted);
  padding: 8px 12px;
  background: var(--tf-bg);
  border-radius: var(--tf-radius-md);
}

.nav-kpi strong {
  font-weight: 700;
  color: var(--tf-text);
}

@media (max-width: 1400px) {
  .nav-kpi {
    font-size: 0.75rem;
    padding: 6px 10px;
  }
}

/* Notification Dot */
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--tf-danger);
  border-radius: 50%;
  border: 2px solid var(--tf-card);
}

/* Dropdown Menus */
.notification-dropdown,
.onhover-show-div {
  background: var(--tf-card);
  border: 1px solid var(--tf-border-light);
  border-radius: var(--tf-radius-lg) !important;
  box-shadow: var(--tf-shadow-xl);
  padding: var(--tf-space-sm) 0;
  min-width: 320px;
}

.notification-dropdown li {
  padding: var(--tf-space-sm) var(--tf-space-md);
}

.notification-dropdown li:hover {
  background: var(--tf-bg);
}

/* Logout Button */
.btn-primary-light a {
  color: var(--tf-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

/* =============================================================================
 * FASE 8 (cont.): HEADER CART
 * =============================================================================*/

.header-cart-li {
  display: flex;
  align-items: center;
}

.header-cart-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  border-radius: var(--tf-radius-md);
  overflow: visible;
}

.header-cart-icon:hover {
  background: var(--tf-bg);
}

.header-cart-badge {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--tf-radius-full);
  background: var(--tf-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--tf-card);
}

/* Cart Dropdown */
.cart-drop {
  min-width: 400px;
  max-width: 480px;
  padding: var(--tf-space-sm) 0;
}

.cart-drop li {
  padding: var(--tf-space-sm) var(--tf-space-md);
}

.cart-drop .media {
  align-items: flex-start;
}

.cart-code {
  font-weight: 700;
  color: var(--tf-text);
  letter-spacing: 0.01em;
}

.cart-qty-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--tf-radius-full);
  font-weight: 700;
  font-size: 0.75rem;
  background: var(--tf-primary);
  color: #fff;
  white-space: nowrap;
}

.cart-item .cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.cart-lines {
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--tf-text-muted);
  line-height: 1.4;
}

.cart-line {
  margin: 2px 0;
}

.cart-line b {
  color: var(--tf-text);
  font-weight: 600;
}

.cart-drop li.cart-item-li {
  padding: var(--tf-space-md);
}

.cart-drop li.cart-item-li + li.cart-item-li {
  border-top: 1px solid var(--tf-border-light);
}

.cart-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: var(--tf-space-md);
  border-top: 1px solid var(--tf-border-light);
  margin-top: var(--tf-space-sm);
}

.cart-actions .btn {
  white-space: nowrap;
}

/* Empty cart states */
.header-cart-dd .notification-box {
  background: transparent !important;
  box-shadow: none !important;
}

.header-cart-dd.is-empty .header-cart-icon:hover {
  background: transparent !important;
}

#header-cart-wrap .header-cart-dd.is-empty,
#header-cart-wrap .header-cart-dd.is-empty * {
  animation: none !important;
  transition: none !important;
}

@media (max-width: 575px) {
  .cart-drop {
    min-width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }
}

/* =============================================================================
 * FASE 9: MOBILE RESPONSIVE
 * =============================================================================*/

/* Breakpoint: Tablet */
@media (max-width: 991px) {
  /* Cards full width */
  .card {
    margin-bottom: var(--tf-space-md);
  }

  /* Header adjustments */
  .left-menu-header {
    display: none;
  }

  .nav-kpi {
    display: none !important;
  }

  /* Sidebar overlay */
  .main-nav {
    z-index: var(--tf-z-modal);
  }
}

/* Breakpoint: Mobile */
@media (max-width: 575px) {
  :root {
    --tf-space-lg: 16px;
    --tf-space-xl: 24px;
  }

  /* Typography scaling */
  h1, .h1 { font-size: 1.5rem; }
  h2, .h2 { font-size: 1.25rem; }
  h3, .h3 { font-size: 1.125rem; }

  /* Card padding */
  .card-body {
    padding: var(--tf-space-md);
  }

  .card-header {
    padding: var(--tf-space-md);
  }

  /* Touch targets - minimum 44px */
  .btn {
    min-height: 44px;
    padding: 12px 20px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 16px;
  }

  .nav-menus > li > a,
  .nav-menus .notification-box,
  .header-cart-icon {
    width: 44px;
    height: 44px;
  }

  /* Form inputs */
  .form-control,
  .form-select,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px !important; /* Prevent iOS zoom */
  }

  /* Table responsive */
  .table-responsive {
    margin: 0 calc(-1 * var(--tf-space-md));
    padding: 0 var(--tf-space-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Dropdowns full width */
  .notification-dropdown,
  .onhover-show-div {
    min-width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    right: 12px !important;
    left: auto !important;
  }

  /* Mobile menu */
  .nav-menu > li > a,
  .nav-menu .nav-link {
    padding: 12px 16px;
    margin: 2px 8px;
  }

  /* Sidebar user */
  .sidebar-user {
    padding: var(--tf-space-md);
  }
}

/* Touch-friendly spacing */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .form-check-input {
    width: 20px;
    height: 20px;
  }

  .nav-menu > li > a {
    padding: 12px 16px;
  }

  .table tbody td {
    padding: 16px;
  }
}

/* =============================================================================
 * FASE 10: ANIMAZIONI
 * =============================================================================*/

/* Fade-in Cards */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.3s ease-out;
}

/* Hover Lift Effect */
.card-hover-lift:hover,
.btn-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--tf-shadow-lg);
}

/* Pulse Animation for Notifications */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.notif-dot {
  animation: pulse 2s ease-in-out infinite;
}

/* Modern Spinner */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-modern {
  width: 24px;
  height: 24px;
  border: 2px solid var(--tf-border);
  border-top-color: var(--tf-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Loader Override */
.loader-wrapper {
  background: var(--tf-bg);
}

.theme-loader .loader-p {
  border-color: var(--tf-primary) !important;
}

/* Button loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* Skeleton Loading */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--tf-bg) 25%, var(--tf-border-light) 50%, var(--tf-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--tf-radius-sm);
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card {
    animation: none;
  }

  .notif-dot {
    animation: none;
  }
}

/* =============================================================================
 * UTILITY CLASSES
 * =============================================================================*/

/* Status badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--tf-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: var(--tf-success-light);
  color: var(--tf-success);
}

.badge-warning {
  background: var(--tf-warning-light);
  color: var(--tf-warning);
}

.badge-danger {
  background: var(--tf-danger-light);
  color: var(--tf-danger);
}

.badge-info {
  background: var(--tf-info-light);
  color: var(--tf-info);
}

.badge-primary {
  background: var(--tf-primary-light) !important;
  color: var(--tf-primary) !important;
}

/* Text utilities */
.text-primary { color: var(--tf-primary) !important; }
.text-success { color: var(--tf-success) !important; }
.text-warning { color: var(--tf-warning) !important; }
.text-danger { color: var(--tf-danger) !important; }

/* Background utilities */
.bg-primary-light { background: var(--tf-primary-light) !important; }
.bg-success-light { background: var(--tf-success-light) !important; }
.bg-warning-light { background: var(--tf-warning-light) !important; }
.bg-danger-light { background: var(--tf-danger-light) !important; }
.bg-info-light { background: var(--tf-info-light) !important; }

/* Light background badges (Bootstrap override) */
.badge.bg-light-primary,
.notification-bg.bg-light-primary {
  background: var(--tf-primary-light) !important;
  color: var(--tf-primary) !important;
}

.badge.bg-light-success,
.notification-bg.bg-light-success {
  background: var(--tf-success-light) !important;
  color: var(--tf-success) !important;
}

.badge.bg-light-warning,
.notification-bg.bg-light-warning {
  background: var(--tf-warning-light) !important;
  color: #92400e !important;
}

.badge.bg-light-danger,
.notification-bg.bg-light-danger {
  background: var(--tf-danger-light) !important;
  color: var(--tf-danger) !important;
}

.badge.bg-light-info,
.notification-bg.bg-light-info {
  background: var(--tf-info-light) !important;
  color: var(--tf-info) !important;
}

/* Notification backgrounds (sidebar, dropdowns) */
.notification-bg {
  width: 40px;
  height: 40px;
  border-radius: var(--tf-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Spacing utilities */
.gap-1 { gap: var(--tf-space-xs); }
.gap-2 { gap: var(--tf-space-sm); }
.gap-3 { gap: var(--tf-space-md); }
.gap-4 { gap: var(--tf-space-lg); }

/* =============================================================================
 * PAGE-SPECIFIC OVERRIDES
 * =============================================================================*/

/* Page body background */
.page-body {
  background: var(--tf-bg);
  min-height: 100vh;
}

/* Breadcrumb modern */
.breadcrumb {
  background: transparent;
  padding: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: '/';
  color: var(--tf-text-light);
}

.breadcrumb-item a {
  color: var(--tf-text-muted);
}

.breadcrumb-item.active {
  color: var(--tf-text);
}

/* Alert modern */
.alert {
  border: none;
  border-radius: var(--tf-radius-md);
  padding: var(--tf-space-md);
}

.alert-primary {
  background: var(--tf-primary-light);
  color: var(--tf-primary);
}

.alert-success {
  background: var(--tf-success-light);
  color: var(--tf-success);
}

.alert-warning {
  background: var(--tf-warning-light);
  color: #92400e;
}

.alert-danger {
  background: var(--tf-danger-light);
  color: var(--tf-danger);
}

/* Modal modern */
.modal-content {
  border: none;
  border-radius: var(--tf-radius-xl);
  box-shadow: var(--tf-shadow-xl);
}

.modal-header {
  border-bottom: 1px solid var(--tf-border-light);
  padding: var(--tf-space-lg);
}

.modal-body {
  padding: var(--tf-space-lg);
}

.modal-footer {
  border-top: 1px solid var(--tf-border-light);
  padding: var(--tf-space-md) var(--tf-space-lg);
}

/* Toast positioning for mobile */
@media (max-width: 575px) {
  .toast-container,
  .Toastify__toast-container {
    bottom: 20px !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* SweetAlert2 Override */
.swal2-popup {
  border-radius: var(--tf-radius-xl) !important;
  font-family: 'Inter', sans-serif !important;
}

.swal2-confirm {
  background: var(--tf-primary) !important;
  border-radius: var(--tf-radius-md) !important;
}

.swal2-cancel {
  border-radius: var(--tf-radius-md) !important;
}

/* Dropzone modern */
.dropzone {
  border: 2px dashed var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  background: var(--tf-bg) !important;
  transition: all var(--tf-transition-fast);
}

.dropzone:hover {
  border-color: var(--tf-primary) !important;
  background: var(--tf-primary-light) !important;
}

.dropzone .dz-message {
  color: var(--tf-text-muted);
  font-weight: 500;
}

/* =============================================================================
 * TIEFFEAI CHAT WIDGET (preserved from original)
 * =============================================================================*/

.tai-panel, .tai-panel * {
  box-sizing: border-box !important;
  font-family: 'Inter', sans-serif !important;
  letter-spacing: normal !important;
}

.tai-panel {
  text-align: left !important;
}

.tai-panel p, .tai-panel h1, .tai-panel h2, .tai-panel h3, .tai-panel h4, .tai-panel h5, .tai-panel h6 {
  margin: 0 !important;
  text-align: left !important;
}

.tai-panel button {
  line-height: 1 !important;
  text-transform: none !important;
}

.tai-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: var(--tf-radius-full);
  background: var(--tf-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(165, 19, 41, 0.3);
  cursor: pointer;
  z-index: var(--tf-z-fab);
  border: 0;
  font-size: 1.25rem;
  transition: all var(--tf-transition-fast);
}

.tai-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(165, 19, 41, 0.4);
}

.tai-fab .unread {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--tf-success);
  border-radius: var(--tf-radius-full);
  box-shadow: 0 0 0 2px #fff;
}

.tai-panel {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 560px;
  max-width: calc(100vw - 32px);
  height: 700px;
  max-height: 80vh;
  display: none;
  flex-direction: column;
  background: var(--tf-card);
  border: 1px solid var(--tf-border-light);
  border-radius: var(--tf-radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: var(--tf-z-fab);
}

.tai-panel.open {
  display: flex;
}

.tai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--tf-bg);
  border-bottom: 1px solid var(--tf-border-light);
}

.tai-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tai-brand .logo {
  width: 36px;
  height: 36px;
  border-radius: var(--tf-radius-full);
  background: var(--tf-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex: 0 0 36px;
}

.tai-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
  color: var(--tf-text);
}

.tai-mini {
  font-size: 0.8125rem;
  color: var(--tf-text-muted);
  line-height: 1.2;
}

.tai-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--tf-radius-md);
  padding: 0;
  color: var(--tf-text-muted);
  transition: all var(--tf-transition-fast);
}

.tai-close:hover {
  background: var(--tf-bg);
  color: var(--tf-text);
}

.tai-close svg {
  width: 18px;
  height: 18px;
  display: block;
}

.tai-body {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 1rem 1rem;
  background: var(--tf-bg);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-align: left !important;
}

.tai-row {
  display: flex;
  margin: 0.6rem 0;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
}

.tai-row.me {
  justify-content: flex-end;
}

.tai-row:first-child {
  margin-top: 1rem;
}

.tai-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--tf-radius-lg);
  background: var(--tf-card);
  box-shadow: var(--tf-shadow-sm);
  white-space: pre-line;
  word-break: break-word;
  text-align: left;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--tf-text);
}

.tai-bubble.me {
  background: var(--tf-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(165, 19, 41, 0.2);
}

.tai-foot {
  border-top: 1px solid var(--tf-border-light);
  background: var(--tf-card);
  padding: 0.75rem;
}

.tai-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tai-input input {
  flex: 1;
  border: 1.5px solid var(--tf-border);
  border-radius: var(--tf-radius-md);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  height: 44px;
  background: var(--tf-card);
}

.tai-input input:focus {
  border-color: var(--tf-primary);
  box-shadow: 0 0 0 3px var(--tf-primary-ring);
  outline: none;
}

.tai-input button {
  border: 0;
  border-radius: var(--tf-radius-md);
  background: var(--tf-primary);
  color: #fff;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  height: 44px;
  cursor: pointer;
  transition: all var(--tf-transition-fast);
}

.tai-input button:hover {
  background: var(--tf-primary-hover);
}

@media (max-width: 575px) {
  .tai-fab {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }

  .tai-panel {
    width: calc(100vw - 20px);
    height: 70vh;
    right: 10px;
    bottom: 90px;
  }
}
