/* ============================================================
   MAGIX CRM — Titanium Edition 2026
   ============================================================ */

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

/* ============================================================
   DARK THEME (default)
   ============================================================ */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1c2333;
  --surface-3:   #21262d;
  --border:      rgba(240,246,252,0.10);
  --border-2:    rgba(240,246,252,0.06);
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-subtle: #484f58;
  --accent:      #2f81f7;
  --accent-2:    #58a6ff;
  --accent-glow: rgba(47,129,247,0.35);
  --green:       #3fb950;
  --red:         #f85149;
  --orange:      #d29922;
  --purple:      #bc8cff;
  --sidebar-w:   228px;
  --header-h:    56px;
  --r:           8px;
  --r-lg:        12px;
  --shadow:      0 8px 32px rgba(0,0,0,.5);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.3);
  --t:           all .15s ease;
}

/* ============================================================
   LIGHT THEME — specificità massima con html[data-theme="light"]
   ============================================================ */
html[data-theme="light"] {
  --bg:          #f6f8fa;
  --surface:     #ffffff;
  --surface-2:   #f6f8fa;
  --surface-3:   #eef1f4;
  --border:      #d0d7de;
  --border-2:    #e8ecf0;
  --text:        #1f2328;
  --text-muted:  #656d76;
  --text-subtle: #9198a1;
  --accent:      #0969da;
  --accent-2:    #0550ae;
  --accent-glow: rgba(9,105,218,0.2);
  --green:       #1a7f37;
  --red:         #d1242f;
  --orange:      #9a6700;
  --purple:      #8250df;
  --shadow:      0 4px 16px rgba(0,0,0,.10);
  --shadow-sm:   0 1px 4px rgba(0,0,0,.06);
}

/* Badge light: testi più scuri e leggibili */
html[data-theme="light"] .bg-primary   { background: rgba(9,105,218,.10) !important; color: #0969da !important; }
html[data-theme="light"] .bg-success,
html[data-theme="light"] .bg-green     { background: rgba(26,127,55,.10) !important; color: #1a7f37 !important; }
html[data-theme="light"] .bg-danger    { background: rgba(209,36,47,.10) !important; color: #d1242f !important; }
html[data-theme="light"] .bg-warning   { background: rgba(154,103,0,.10) !important; color: #9a6700 !important; }
html[data-theme="light"] .bg-secondary { background: rgba(101,109,118,.10) !important; color: #656d76 !important; }
html[data-theme="light"] .bg-blue-lt   { background: rgba(9,105,218,.08) !important; color: #0969da !important; }
html[data-theme="light"] .bg-purple    { background: rgba(130,80,223,.10) !important; color: #8250df !important; }
html[data-theme="light"] .bg-indigo    { background: rgba(80,80,220,.10) !important; color: #5050dc !important; }
html[data-theme="light"] .bg-azure,
html[data-theme="light"] .bg-info      { background: rgba(0,150,210,.10) !important; color: #0096d2 !important; }
html[data-theme="light"] .bg-teal      { background: rgba(26,127,55,.10) !important; color: #1a7f37 !important; }
html[data-theme="light"] .bg-dark      { background: rgba(0,0,0,.06) !important; color: #1f2328 !important; }

/* Tabella light */
html[data-theme="light"] .table thead th { background: #f6f8fa !important; color: #656d76 !important; }
html[data-theme="light"] .table-hover tbody tr:hover td { background: #f6f8fa !important; }

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* ============================================================
   LAYOUT
   ============================================================ */
.wrapper { display: flex; min-height: 100vh; }
.page-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  transition: background .25s ease;
}
.page-body {
  flex: 1;
  padding: 24px 28px;
  animation: fadeUp .2s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.magix-sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200; overflow: hidden;
  transition: background .25s ease, border-color .25s ease;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; flex-shrink: 0;
  transition: border-color .25s ease;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #2f81f7, #6e40f7);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800; font-size: 14px; color: #fff;
  flex-shrink: 0; box-shadow: 0 4px 10px rgba(47,129,247,.4);
}
.sidebar-logo-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800; font-size: 14.5px;
  color: var(--text); letter-spacing: -.3px; line-height: 1.2;
}
.sidebar-logo-ver {
  font-size: 10px; font-weight: 500;
  color: var(--text-muted); font-family: 'Inter', sans-serif;
}
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 10px;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-subtle);
  padding: 10px 8px 4px;
}
.nav-item-magix {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r);
  color: var(--text-muted); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: var(--t); margin-bottom: 1px; position: relative;
}
.nav-item-magix:hover { background: var(--surface-2); color: var(--text); }
.nav-item-magix.active {
  background: var(--surface-3); color: var(--accent-2); font-weight: 600;
}
.nav-item-magix.active::before {
  content: ''; position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  flex-shrink: 0; color: inherit;
}
.nav-item-magix.active .nav-icon { color: var(--accent-2); }
.nav-label { flex: 1; }
.sidebar-user {
  flex-shrink: 0; padding: 10px;
  border-top: 1px solid var(--border);
  transition: border-color .25s ease;
}
.sidebar-user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  background: var(--surface-2); border-radius: var(--r);
  border: 1px solid var(--border-2);
  transition: background .25s ease;
}
.sidebar-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), #6e40f7);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }
.sidebar-user-actions { display: flex; gap: 4px; }
.sidebar-action-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: transparent; border: none;
  cursor: pointer; color: var(--text-muted); transition: var(--t);
  text-decoration: none;
}
.sidebar-action-btn:hover { background: var(--surface-3); color: var(--text); }
.sidebar-action-danger:hover { background: rgba(248,81,73,.12); color: var(--red) !important; }

/* Icona tema: sole in dark, luna in light */
.icon-sun  { display: none; }
.icon-moon { display: block; }
html[data-theme="light"] .icon-sun  { display: block; }
html[data-theme="light"] .icon-moon { display: none; }

/* ============================================================
   HEADER
   ============================================================ */
.magix-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  transition: background .25s ease, border-color .25s ease;
}
.magix-header-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px; font-weight: 800;
  color: var(--text); flex: 1; letter-spacing: -.3px;
}
.magix-header-actions { display: flex; align-items: center; gap: 10px; }
.badge-sede {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted);
}
.header-date { font-size: 12px; color: var(--text-muted); display: none; }
@media(min-width:1024px) { .header-date { display: block; } }
.btn-header-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px;
  background: var(--accent); color: #fff !important;
  border-radius: var(--r); font-size: 12.5px; font-weight: 600;
  transition: var(--t); border: none; cursor: pointer;
}
.btn-header-cta:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
  color: #fff !important;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  font-size: 18px !important; font-weight: 800 !important;
  color: var(--text) !important; letter-spacing: -.4px !important;
  margin: 0 !important;
}
.text-muted { color: var(--text-muted) !important; }
.breadcrumb { background: none !important; padding: 0 !important; margin: 0 !important; }
.breadcrumb-item, .breadcrumb-item a { font-size: 12px; color: var(--text-muted) !important; }
.breadcrumb-item a:hover { color: var(--accent) !important; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-subtle) !important; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: none !important;
  color: var(--text) !important;
  transition: background .25s ease, border-color .25s ease !important;
}
.card:hover { border-color: rgba(47,129,247,.25) !important; }
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 20px !important;
  font-size: 13px !important; font-weight: 600 !important;
  color: var(--text) !important;
}
.card-body { padding: 20px !important; background: transparent !important; }
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--border) !important;
  padding: 12px 20px !important;
  color: var(--text) !important;
}
.kpi-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  padding: 20px !important; transition: var(--t) !important;
}
.kpi-card:hover {
  border-color: rgba(47,129,247,.3) !important;
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-sm) !important;
}
.kpi-number {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 28px; font-weight: 800;
  line-height: 1; margin-bottom: 4px; color: var(--text);
}
.kpi-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.kpi-icon-wrap {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

/* ============================================================
   TABELLE
   ============================================================ */
.table { color: var(--text) !important; border-color: var(--border) !important; }
.table thead th {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important; font-weight: 600 !important;
  text-transform: uppercase !important; letter-spacing: .06em !important;
  border-color: var(--border) !important; padding: 10px 16px !important;
}
.table tbody td {
  border-color: var(--border-2) !important;
  padding: 11px 16px !important; vertical-align: middle !important;
  font-size: 13px !important; color: var(--text) !important;
  background: transparent !important;
}
.table-hover tbody tr:hover td { background: var(--surface-2) !important; }

/* ============================================================
   FORM
   ============================================================ */
.form-control, .form-select {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--r) !important;
  font-size: 13px !important; padding: 8px 12px !important;
  transition: var(--t) !important;
}
.form-control:focus, .form-select:focus {
  background: var(--surface-2) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
  color: var(--text) !important; outline: none !important;
}
.form-control::placeholder { color: var(--text-subtle) !important; }
.form-select option { background: var(--surface-2); color: var(--text); }
.form-label {
  font-size: 12px !important; font-weight: 600 !important;
  color: var(--text-muted) !important; margin-bottom: 5px !important;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: var(--r) !important; font-size: 13px !important;
  font-weight: 600 !important; padding: 7px 14px !important;
  transition: var(--t) !important; display: inline-flex !important;
  align-items: center !important; gap: 6px !important;
  cursor: pointer !important; border: none !important;
  line-height: 1.4 !important;
}
.btn-primary { background: var(--accent) !important; color: #fff !important; }
.btn-primary:hover { background: var(--accent-2) !important; color: #fff !important; box-shadow: 0 4px 12px var(--accent-glow) !important; transform: translateY(-1px); }
.btn-success { background: var(--green) !important; color: #fff !important; }
.btn-success:hover { opacity: .9 !important; }
.btn-danger  { background: var(--red) !important;   color: #fff !important; }
.btn-danger:hover  { opacity: .9 !important; }
.btn-outline-secondary {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
}
.btn-outline-secondary:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.btn-outline-success { background: transparent !important; border: 1px solid var(--green) !important; color: var(--green) !important; }
.btn-outline-success:hover { background: rgba(63,185,80,.1) !important; }
.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }
.btn-lg { padding: 10px 20px !important; font-size: 14px !important; }
.btn-ghost-primary { background: rgba(47,129,247,.08) !important; color: var(--accent-2) !important; border: 1px solid rgba(47,129,247,.2) !important; }
.btn-ghost-primary:hover { background: rgba(47,129,247,.15) !important; }
.btn-ghost-secondary { background: var(--surface-2) !important; color: var(--text-muted) !important; border: 1px solid var(--border) !important; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: 11px !important; font-weight: 600 !important;
  padding: 3px 7px !important; border-radius: 5px !important;
  display: inline-flex !important; align-items: center !important;
}
.bg-primary    { background: rgba(47,129,247,.15)  !important; color: #79c0ff !important; }
.bg-success, .bg-green { background: rgba(63,185,80,.15) !important; color: #56d364 !important; }
.bg-danger     { background: rgba(248,81,73,.15)   !important; color: #ff7b72 !important; }
.bg-warning    { background: rgba(210,153,34,.15)  !important; color: #e3b341 !important; }
.bg-info       { background: rgba(88,166,255,.12)  !important; color: #79c0ff !important; }
.bg-secondary  { background: rgba(125,133,144,.12) !important; color: #8b949e !important; }
.bg-purple     { background: rgba(188,140,255,.15) !important; color: #d2a8ff !important; }
.bg-azure      { background: rgba(56,189,248,.12)  !important; color: #7dd3fc !important; }
.bg-indigo     { background: rgba(129,140,248,.12) !important; color: #a5b4fc !important; }
.bg-teal       { background: rgba(57,211,83,.12)   !important; color: #39d353 !important; }
.bg-blue-lt    { background: rgba(47,129,247,.1)   !important; color: #79c0ff !important; }
.bg-dark       { background: rgba(255,255,255,.08) !important; color: var(--text-muted) !important; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border-radius: var(--r) !important; font-size: 13px !important;
  padding: 12px 16px !important; border: 1px solid !important;
}
.alert-success { background: rgba(63,185,80,.08)  !important; border-color: rgba(63,185,80,.25)  !important; color: var(--green) !important; }
.alert-danger  { background: rgba(248,81,73,.08)  !important; border-color: rgba(248,81,73,.25)  !important; color: var(--red) !important; }
.alert-warning { background: rgba(210,153,34,.08) !important; border-color: rgba(210,153,34,.25) !important; color: var(--orange) !important; }
.alert-info    { background: rgba(47,129,247,.08) !important; border-color: rgba(47,129,247,.25) !important; color: var(--accent-2) !important; }

/* ============================================================
   FOOTER
   ============================================================ */
.magix-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-muted);
  transition: border-color .25s ease;
}
.magix-footer strong { color: var(--accent); }

/* ============================================================
   PROGRESS / PAGINATION / LIST / DROPDOWN
   ============================================================ */
.progress { background: var(--surface-2) !important; border-radius: 4px !important; height: 5px !important; }
.progress-bar { background: var(--accent) !important; }
.page-link {
  background: var(--surface) !important; border-color: var(--border) !important;
  color: var(--text-muted) !important; border-radius: 6px !important;
  margin: 0 2px !important; font-size: 12.5px !important;
}
.page-link:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.page-item.active .page-link { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.list-group-item {
  background: transparent !important; border-color: var(--border-2) !important;
  color: var(--text) !important; font-size: 13px !important; padding: 10px 16px !important;
}
.dropdown-menu {
  background: var(--surface-2) !important; border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important; box-shadow: var(--shadow) !important; padding: 6px !important;
}
.dropdown-item { color: var(--text-muted) !important; font-size: 13px !important; border-radius: 6px !important; padding: 7px 10px !important; }
.dropdown-item:hover { background: var(--surface-3) !important; color: var(--text) !important; }
.dropdown-divider { border-color: var(--border) !important; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline::before { background: var(--border) !important; }
.timeline-body {
  background: var(--surface-2) !important;
  border: 1px solid var(--border-2) !important;
  border-radius: var(--r) !important; padding: 11px 14px !important;
}
.timeline-dot { background: var(--surface) !important; border-color: var(--accent) !important; }

/* ============================================================
   INFO ROW
   ============================================================ */
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-2); padding: 9px 0; font-size: 13px;
}
.info-row:last-child { border: none; }
.info-row span:first-child { color: var(--text-muted); font-size: 12px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-bg {
  min-height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
  transition: background .25s ease;
}
.login-bg::before {
  content:''; position: absolute; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(47,129,247,.1) 0%, transparent 70%);
  top: -150px; right: -150px; pointer-events: none;
}
.login-card {
  width: 100%; max-width: 390px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  position: relative; z-index: 1; overflow: hidden;
  transition: background .25s ease, border-color .25s ease;
}
.login-top {
  padding: 32px 30px 24px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.login-icon {
  width: 50px; height: 50px;
  background: linear-gradient(135deg, var(--accent), #6e40f7);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 14px;
  box-shadow: 0 6px 16px var(--accent-glow);
}
.login-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px; font-weight: 800; color: var(--text); margin: 0 0 4px;
}
.login-sub { font-size: 12.5px; color: var(--text-muted); }
.login-body { padding: 26px 30px; }

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: 12px;
}

/* ============================================================
   MISC
   ============================================================ */
hr { border-color: var(--border) !important; }
.font-monospace { font-family: 'SF Mono','Consolas',monospace !important; font-size: 12px !important; }
.small { font-size: 11.5px !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.opacity-50 { opacity: .45 !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }

/* Mobile */
@media (max-width: 768px) {
  .magix-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .magix-sidebar.open { transform: translateX(0); }
  .page-wrapper { margin-left: 0; }
  .page-body { padding: 16px; }
}