/* ==========================================================================
   PANNELLO DI CONTROLLO 2026 - EXECUTIVE BORDEAUX & SLATE DESIGN SYSTEM
   Architettura Duale: /master (SuperAdmin) & /client-panel (Singolo Sito)
   Zero tagli laterali (Flexbox Nativo) + 100% Responsive Desktop/Tablet/Mobile
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  --bg-body: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #881337;
  --primary-hover: #7f1d1d;
  --primary-soft: rgba(136, 19, 55, 0.09);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.12);
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --sidebar-bg: #0f172a;
  --sidebar-surface: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.07), 0 4px 10px -4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 35px -10px rgba(15, 23, 42, 0.15);
  --bs-primary: #881337;
  --bs-primary-rgb: 136, 19, 55;
}

[data-bs-theme="dark"] {
  --bg-body: #090d16;
  --bg-surface: #111827;
  --bg-surface-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1f2937;
  --primary: #be123c;
  --primary-hover: #e11d48;
  --primary-soft: rgba(190, 18, 60, 0.2);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100vh;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.91rem;
  line-height: 1.55;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.18s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* Override Bootstrap primary utilities to Bordeaux */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.bg-primary-subtle { background-color: #fff1f2 !important; color: #881337 !important; }
.border-primary, .border-primary-subtle { border-color: #fecdd3 !important; }

/* ==========================================================================
   LAYOUT ANTITAGLIO: SIDEBAR + MAIN CONTENT IN FLEXBOX NATIVO
   Impedisce qualsiasi sovrapposizione tra sidebar e tabelle
   ========================================================================== */
#container {
  display: block;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: var(--topbar-height);
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-brand .brand-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #fff;
  font-weight: 700;
  font-size: 0.98rem;
  text-decoration: none;
  min-width: 0;
}

.sidebar-brand .brand-logo-img {
  height: 36px;
  max-width: 96px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  padding: 3px 6px;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #881337;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.sidebar-section-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 0 0.65rem;
  margin-bottom: 0.45rem;
  margin-top: 1rem;
}

.sidebar-section-label:first-child {
  margin-top: 0;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-menu .nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.85rem;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 0.87rem;
  transition: all 0.16s ease;
}

.sidebar-menu .nav-item .nav-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  color: #94a3b8;
  flex-shrink: 0;
}

.sidebar-menu .nav-item .nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.sidebar-menu .nav-item .nav-link:hover i {
  color: #fda4af;
}

.sidebar-menu .nav-item .nav-link.active {
  background: #881337;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(136, 19, 55, 0.35);
}

.sidebar-menu .nav-item .nav-link.active i {
  color: #ffffff;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  gap: 0.5rem;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #881337;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: #94a3b8;
  font-size: 0.7rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   TOPBAR & MAIN CONTENT (CON !IMPORTANT CONTRO REGOLE LEGACY)
   ========================================================================== */
.app-topbar {
  position: fixed !important;
  top: 0 !important;
  left: var(--sidebar-width) !important;
  right: 0 !important;
  z-index: 1030;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

[data-bs-theme="dark"] .app-topbar {
  background: rgba(17, 24, 39, 0.95);
}

#main-content,
body.full-width #main-content {
  margin-left: var(--sidebar-width) !important;
  width: calc(100% - var(--sidebar-width)) !important;
  max-width: calc(100% - var(--sidebar-width)) !important;
  padding-top: var(--topbar-height) !important;
  min-height: calc(100vh - 56px);
  display: block !important;
  position: relative;
  overflow-x: hidden;
}

.wrapper,
body.full-width .wrapper {
  padding: 1.5rem 1.75rem !important;
  margin-top: 0 !important;
  width: 100% !important;
  max-width: 1600px;
  margin-left: auto !important;
  margin-right: auto !important;
  display: block !important;
}

.site-footer,
body.full-width .site-footer {
  margin-left: var(--sidebar-width) !important;
  width: calc(100% - var(--sidebar-width)) !important;
  padding: 1rem 1.75rem !important;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1040;
}

body.sidebar-open .sidebar-overlay {
  display: block;
}

/* ==========================================================================
   MASTER IMPERSONATION BANNER (Quando SuperAdmin #1 gestisce un Sito Cliente)
   ========================================================================== */
.master-impersonation-bar {
  background: linear-gradient(90deg, #0f172a 0%, #7f1d1d 60%, #881337 100%);
  color: #ffffff;
  padding: 0.55rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.84rem;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   DASHBOARD KPI GRID & INFO GRID
   ========================================================================== */
.kpi-grid-2026 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.35rem;
  width: 100%;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.kpi-content {
  min-width: 0;
  flex: 1;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.kpi-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.info-grid-2026 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.9rem;
  width: 100%;
}

.info-box-2026 {
  padding: 1rem 1.15rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.info-box-2026 .info-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-box-2026 .info-main {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-main);
  word-break: break-word;
}

.info-box-2026 .info-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  word-break: break-word;
}

/* ==========================================================================
   CARDS, FORMS, BUTTONS & TABLES (100% RESPONSIVE SENZA TAGLI)
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.35rem;
  width: 100%;
  overflow: hidden;
}

.card-header,
.card-heading {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.35rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-body {
  padding: 1.35rem;
}

.breadcrumb {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.95rem;
  margin-bottom: 0;
  font-size: 0.82rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-horizontal .form-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-left: -0.65rem;
  margin-right: -0.65rem;
}

.form-horizontal .form-group > label,
.form-horizontal .form-group > .control-label {
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  padding-top: 0.5rem;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-main);
}

.form-horizontal .form-group > div[class^="col-"] {
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.form-control,
.form-select {
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  background-color: var(--bg-surface);
  color: var(--text-main);
  width: 100%;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn-xs {
  padding: 0.3rem 0.6rem;
  font-size: 0.76rem;
  border-radius: 6px;
}

.btn-sm {
  padding: 0.4rem 0.82rem;
  font-size: 0.82rem;
  border-radius: 7px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-white,
.btn-default {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-white:hover,
.btn-default:hover {
  background: var(--bg-surface-subtle);
  border-color: #cbd5e1;
  color: var(--primary);
}

/* Tables & Auto Search Toolbar (Padding Corretto Anche Dentro p-0) */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0 !important;
}

.card-body:not(.p-0) .table-toolbar {
  padding: 0 0 0.85rem 0;
  border-bottom: none;
}

.table-search-box {
  position: relative;
  min-width: 240px;
  flex: 1;
  max-width: 360px;
}

.table-search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.table-search-box input {
  padding-left: 34px;
  border-radius: 8px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: 0;
  vertical-align: middle;
  color: var(--text-main);
  border-color: var(--border-color);
}

.table > thead > tr > th {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.86rem;
}

.table > tbody > tr:hover > * {
  background-color: var(--primary-soft) !important;
}

.table td img {
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   LOGIN PAGE (default.asp) - STILE ESECUTIVO BORDEAUX & ANTRACITE
   ========================================================================== */
body.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, rgba(136, 19, 55, 0.28), transparent 45%),
    linear-gradient(135deg, #090d16 0%, #0f172a 60%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card-2026 {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 4px solid #881337;
  border-radius: 18px;
  padding: 2.25rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  color: #f8fafc;
}

.login-card-2026 .form-control {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 0.72rem 1rem 0.72rem 2.65rem;
  border-radius: 10px;
}

.login-card-2026 .form-control:focus {
  border-color: #be123c;
  background: rgba(30, 41, 59, 0.98);
  box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.25);
}

.login-input-wrap {
  position: relative;
  margin-bottom: 1.1rem;
}

.login-input-wrap .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.98rem;
  pointer-events: none;
}

.login-input-wrap .toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
}

.btn-login-2026 {
  width: 100%;
  padding: 0.78rem 1.2rem;
  border-radius: 10px;
  background: #881337;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.94rem;
  box-shadow: 0 8px 20px -4px rgba(136, 19, 55, 0.5);
}

.btn-login-2026:hover {
  background: #9f1239;
  color: #fff;
  transform: translateY(-1px);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (TABLET & SMARTPHONE)
   ========================================================================== */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
  }
  .app-topbar {
    left: 0 !important;
    padding: 0 1rem;
  }
  #main-content,
  body.full-width #main-content,
  .site-footer,
  body.full-width .site-footer {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .wrapper,
  body.full-width .wrapper {
    padding: 1.15rem 1rem !important;
  }
  .form-horizontal .form-group > label,
  .form-horizontal .form-group > .control-label,
  .form-horizontal .form-group > div[class^="col-"] {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  .wrapper,
  body.full-width .wrapper {
    padding: 0.9rem 0.75rem !important;
  }
  .card-header,
  .card-heading,
  .card-body {
    padding: 0.95rem 1rem;
  }
  .kpi-grid-2026,
  .info-grid-2026 {
    grid-template-columns: 1fr;
  }
  .table-search-box {
    min-width: 100%;
    max-width: 100%;
  }
}
