/* CRM DN - tema applicativo (sopra Tabler / Bootstrap 5) */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/inter/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/inter/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --tblr-font-sans-serif: "Inter Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --crm-radius: 10px;
  --crm-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --crm-shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12), 0 4px 8px -4px rgba(16, 24, 40, .06);
}

body {
  font-feature-settings: "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}

.card {
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow);
}

.page-header .page-pretitle {
  letter-spacing: .06em;
}

/* ---------- Sidebar ---------- */
.navbar-vertical.navbar-expand-lg {
  border-right: 1px solid var(--tblr-border-color);
}
.navbar-vertical .navbar-brand {
  padding: 1.1rem 0 .9rem;
}
.crm-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--tblr-body-color);
  text-decoration: none;
  max-width: 100%;
}
.crm-brand:hover { text-decoration: none; }
.crm-brand-logo {
  height: 32px;
  max-width: 180px;
  object-fit: contain;
}
.crm-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--tblr-primary), color-mix(in srgb, var(--tblr-primary) 55%, #000));
  color: #fff;
  font-size: 1.1rem;
}
.crm-brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 992px) {
  .navbar-vertical .nav-link {
    border-radius: 8px;
    margin: 1px .75rem;
    padding: .5rem .75rem;
  }
  .navbar-vertical .nav-item.active .nav-link,
  .navbar-vertical .nav-link.active {
    background: color-mix(in srgb, var(--tblr-primary) 10%, transparent);
    color: var(--tblr-primary);
    font-weight: 600;
  }
  .navbar-vertical .nav-item.active .nav-link .nav-link-icon { color: var(--tblr-primary); }
}
.nav-section-title {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tblr-secondary);
  padding: 1rem 1.5rem .35rem;
}
.nav-link .badge { margin-left: auto; }

/* ---------- Header / ricerca ---------- */
.crm-search { position: relative; width: min(480px, 100%); }
.crm-search .form-control { padding-left: 2.4rem; border-radius: 9px; background: var(--tblr-bg-surface-secondary); }
.crm-search .ti-search { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--tblr-secondary); }
.crm-search kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); font-size: .7rem; }
.crm-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1050;
  max-height: 70vh;
  overflow: auto;
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow-lg);
}
.crm-search-results .list-group-item.active { z-index: 0; }

/* ---------- Avatar ---------- */
.avatar-initials { color: #fff; font-weight: 600; }

/* ---------- KPI ---------- */
.kpi-card .kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi-label { color: var(--tblr-secondary); font-size: .8rem; font-weight: 500; }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 220px; }

/* ---------- Kanban ---------- */
.kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
  min-height: calc(100vh - 240px);
  scroll-snap-type: x proximity;
}
.kanban-col {
  flex: 0 0 290px;
  background: var(--tblr-bg-surface-secondary);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
  scroll-snap-align: start;
}
.kanban-col-head {
  padding: .8rem .9rem .6rem;
  border-top: 3px solid var(--stage-color, var(--tblr-primary));
  border-radius: 12px 12px 0 0;
}
.kanban-col-title { font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.kanban-col-total { font-size: .8rem; color: var(--tblr-secondary); }
.kanban-list {
  padding: .25rem .6rem .75rem;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
}
.kanban-card {
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: 10px;
  padding: .7rem .8rem;
  margin-bottom: .55rem;
  cursor: grab;
  box-shadow: var(--crm-shadow);
  transition: box-shadow .15s, transform .15s;
}
.kanban-card:hover { box-shadow: var(--crm-shadow-lg); }
.kanban-card:active { cursor: grabbing; }
.kanban-card-title { font-weight: 600; color: var(--tblr-body-color); display: block; margin-bottom: .15rem; }
.kanban-card-title:hover { color: var(--tblr-primary); text-decoration: none; }
.kanban-card-value { font-weight: 700; }
.kanban-ghost { opacity: .45; background: color-mix(in srgb, var(--tblr-primary) 8%, transparent); border-style: dashed; }
.kanban-drag { transform: rotate(2deg); box-shadow: var(--crm-shadow-lg); }
.kanban-empty { text-align: center; color: var(--tblr-secondary); font-size: .8rem; padding: 1.2rem .5rem; border: 1px dashed var(--tblr-border-color); border-radius: 10px; }
.kanban-list:has(.kanban-card) .kanban-empty { display: none; }

/* ---------- Timeline ---------- */
.crm-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.crm-timeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--tblr-border-color);
}
.crm-timeline-item { position: relative; padding: 0 0 1.1rem 3rem; }
.crm-timeline-icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  border: 3px solid var(--tblr-bg-surface);
}
.crm-timeline-body { background: var(--tblr-bg-surface-secondary); border-radius: 10px; padding: .6rem .8rem; }
.crm-timeline-item.is-system .crm-timeline-body { background: transparent; padding: .45rem 0 0; }
.crm-timeline-desc { white-space: pre-line; margin-top: .25rem; }

/* ---------- Dettaglio entità ---------- */
.entity-header { display: flex; gap: 1rem; align-items: center; }
.entity-header .avatar { flex: 0 0 auto; }
.dl-crm dt { font-weight: 500; color: var(--tblr-secondary); font-size: .8rem; margin-top: .75rem; }
.dl-crm dt:first-child { margin-top: 0; }
.dl-crm dd { margin: 0; word-break: break-word; }

/* ---------- Tabelle ---------- */
.table-crm th a { color: inherit; text-decoration: none; }
.table-crm th a.asc::after { content: " ↑"; }
.table-crm th a.desc::after { content: " ↓"; }
.table-crm td { vertical-align: middle; }
.table-crm tbody tr { transition: background-color .1s; }
.row-link { cursor: pointer; }

.empty-state { padding: 3rem 1rem; text-align: center; }
.empty-state .empty-icon { font-size: 2.6rem; color: var(--tblr-secondary); opacity: .6; }

/* ---------- Attività ---------- */
.activity-check { width: 1.2rem; height: 1.2rem; cursor: pointer; }
.is-done .activity-subject { text-decoration: line-through; color: var(--tblr-secondary); }
.fc .fc-done { opacity: .6; text-decoration: line-through; }
.fc { --fc-border-color: var(--tblr-border-color); --fc-today-bg-color: color-mix(in srgb, var(--tblr-primary) 7%, transparent); }
.fc .fc-button-primary { background: var(--tblr-bg-surface); color: var(--tblr-body-color); border-color: var(--tblr-border-color); }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--tblr-primary); border-color: var(--tblr-primary); color: #fff; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 600; }
.fc-event { cursor: pointer; }
.fc a.fc-daygrid-event, .fc .fc-list-event a, .fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: var(--tblr-body-color); text-decoration: none; }
.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number { color: var(--tblr-secondary); }

/* ---------- Stelle valutazione ---------- */
.rating { color: #f59f00; letter-spacing: -1px; }
.rating .off { color: var(--tblr-border-color); }

/* ---------- Pagine di accesso ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-split { grid-template-columns: minmax(420px, 520px) 1fr; } }
.auth-form-side { display: flex; flex-direction: column; justify-content: center; padding: 3rem clamp(1.5rem, 5vw, 4rem); background: var(--tblr-bg-surface); }
.auth-hero {
  display: none;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(255,255,255,.22), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(0,0,0,.25), transparent 60%),
    linear-gradient(135deg, var(--tblr-primary), color-mix(in srgb, var(--tblr-primary) 45%, #0b1020));
  color: #fff;
  padding: 4rem;
}
@media (min-width: 992px) { .auth-hero { display: flex; flex-direction: column; justify-content: flex-end; } }
.auth-hero h2 { font-size: 2.1rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; max-width: 520px; }
.auth-hero p { opacity: .85; max-width: 480px; font-size: 1.05rem; }
.auth-hero-points { display: grid; gap: .75rem; margin-top: 2rem; }
.auth-hero-points div { display: flex; align-items: center; gap: .6rem; opacity: .95; }
.auth-hero-points i { font-size: 1.3rem; }
.auth-hero-card {
  position: absolute;
  top: 12%;
  right: 8%;
  width: 300px;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-hero-card .bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.85); }

.install-steps .step-item.active { font-weight: 600; }

/* ---------- Varie ---------- */
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cursor-pointer { cursor: pointer; }
.form-label.required::after { content: " *"; color: var(--tblr-danger); }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-control { border-radius: var(--tblr-border-radius); }
.toast-container { z-index: 1090; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media print {
  .navbar-vertical, .page-header .btn-list, header.navbar { display: none !important; }
  .page-wrapper { margin: 0 !important; }
}

/* ---------- Editor preventivo ---------- */
.quote-items-table { min-width: 780px; }
.quote-items-table td { padding-left: .35rem; padding-right: .35rem; }
.quote-items-table th:first-child, .quote-items-table td:first-child { padding-left: .75rem; }
.quote-items-table .form-select-sm { padding-right: 1.6rem; background-position: right .4rem center; }
.quote-items-table textarea { min-width: 180px; }
.ts-dropdown { z-index: 1060; background: var(--tblr-bg-surface); box-shadow: var(--crm-shadow-lg); }
.card-actions .ts-wrapper { position: relative; }
.card-actions .ts-dropdown { width: max(100%, 460px); right: 0; left: auto; }
.card-actions .ts-dropdown .option { white-space: nowrap; }
