/* ============================================================
   CineVolt Fleet Manager — Design System
   fleet.cinevolt.it
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --arancio:      #E05A1A;
  --arancio-hover:#C94E14;
  --arancio-soft: rgba(224,90,26,.12);

  /* Superfici */
  --bg:           #2A2A2A;
  --surface:      #323232;
  --surface-2:    #3A3A3A;
  --surface-3:    #424242;
  --border:       rgba(255,255,255,.08);
  --border-focus: rgba(224,90,26,.6);

  /* Testo */
  --testo:        #E8E6E0;
  --testo-2:      #A8A5A0;
  --testo-3:      #6E6B66;

  /* Badge / stato */
  --verde:        #22C55E;
  --verde-soft:   rgba(34,197,94,.14);
  --giallo:       #EAB308;
  --giallo-soft:  rgba(234,179,8,.14);
  --rosso:        #EF4444;
  --rosso-soft:   rgba(239,68,68,.14);
  --blu:          #3B82F6;
  --blu-soft:     rgba(59,130,246,.14);
  --grigio-soft:  rgba(255,255,255,.08);

  /* Layout */
  --sidebar-w:    240px;
  --header-h:     60px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:    0 4px 16px rgba(0,0,0,.5);

  /* Transizioni */
  --t:            150ms ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--testo);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--arancio); text-decoration: none; }
a:hover { color: var(--arancio-hover); }

img { max-width: 100%; display: block; }

/* ── Tipografia ───────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--testo);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: .9375rem; font-weight: 600; }

.overline {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--arancio);
  display: block;
  margin-bottom: 4px;
}

/* ── Login ────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo img { height: auto; width: 260px; max-width: 100%; }

.login-app-name {
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--testo-2);
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--testo-2);
  font-size: .875rem;
  margin-bottom: 28px;
}

.login-footer {
  font-size: .75rem;
  color: var(--testo-3);
  text-align: center;
}

.totp-back {
  text-align: center;
  margin-top: 20px;
  font-size: .875rem;
}

.input-totp {
  text-align: center;
  font-size: 1.75rem !important;
  font-family: 'Barlow', monospace !important;
  font-weight: 700 !important;
  letter-spacing: .3em;
}

/* ── Layout dashboard (sidebar + main) ────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img { height: 32px; width: auto; }

.sidebar-logo-label {
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: .6875rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--testo-3);
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-section {
  padding: 12px 16px 4px;
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--testo-3);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--testo-2);
  border-radius: 0;
  transition: background var(--t), color var(--t);
  position: relative;
}

.sidebar-link svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--testo);
}

.sidebar-link.active {
  background: var(--arancio-soft);
  color: var(--arancio);
}

/* Badge notifica nella sidebar */
.nav-badge {
  margin-left: auto;
  background: var(--rosso, #e53e3e);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--arancio);
  border-radius: 0 2px 2px 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  transition: background var(--t);
}

.sidebar-user:hover { background: var(--surface-2); }

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--arancio);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: .8125rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--testo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: .6875rem;
  color: var(--testo-3);
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-header {
  padding: 24px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-title { margin-bottom: 2px; }

.page-sub {
  color: var(--testo-2);
  font-size: .875rem;
}

.page-body {
  padding: 24px 32px 48px;
  flex: 1;
}

/* ── Schede (stat cards) ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--testo-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Barlow', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--testo);
  line-height: 1;
}

.stat-value.arancio { color: var(--arancio); }
.stat-value.verde   { color: var(--verde); }
.stat-value.giallo  { color: var(--giallo); }

.stat-sub {
  font-size: .75rem;
  color: var(--testo-3);
  margin-top: 4px;
}

/* ── Card generica ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-family: 'Barlow', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.card-body { padding: 20px; }

/* ── Flotta — stato veicoli ───────────────────────────────── */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--t);
}

.vehicle-card:hover { border-color: var(--border-focus); }

.vehicle-card.stato-disponibile  { border-left: 3px solid var(--verde); }
.vehicle-card.stato-in_noleggio  { border-left: 3px solid var(--arancio); }
.vehicle-card.stato-manutenzione { border-left: 3px solid var(--giallo); }
.vehicle-card.stato-fuori_servizio { border-left: 3px solid var(--rosso); }

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.vehicle-targa {
  font-family: 'Barlow', sans-serif;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: .04em;
}

.vehicle-modello {
  font-size: .8125rem;
  color: var(--testo-2);
  margin-top: 2px;
}

.vehicle-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.vehicle-stat-item { font-size: .8125rem; color: var(--testo-2); }
.vehicle-stat-item strong { display: block; color: var(--testo); font-weight: 600; }

/* ── Tabelle ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--testo-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 13px 16px;
  color: var(--testo);
  vertical-align: middle;
}

tbody td.muted { color: var(--testo-2); }

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}

.badge-verde  { background: var(--verde-soft);  color: var(--verde); }
.badge-giallo { background: var(--giallo-soft); color: var(--giallo); }
.badge-rosso  { background: var(--rosso-soft);  color: var(--rosso); }
.badge-arancio{ background: var(--arancio-soft);color: var(--arancio); }
.badge-blu    { background: var(--blu-soft);    color: var(--blu); }
.badge-grigio { background: var(--grigio-soft); color: var(--testo-2); }
.badge-scuro  { background: rgba(0,0,0,.3);     color: var(--testo-3); }

/* ── Form ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--testo-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-link {
  font-weight: 400;
  font-size: .75rem;
  color: var(--arancio);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="tel"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .875rem;
  font-family: 'Inter', sans-serif;
  color: var(--testo);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  appearance: none;
}

input::placeholder, textarea::placeholder { color: var(--testo-3); }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(224,90,26,.15);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6B66' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: .75rem;
  color: var(--testo-3);
  margin-top: 4px;
}

.form-section {
  border-top: 1px solid var(--border);
  margin: 24px 0 20px;
  padding-top: 20px;
}

.form-section-title {
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: .9375rem;
  color: var(--testo);
  margin-bottom: 16px;
}

.input-password-wrap {
  position: relative;
}

.input-password-wrap input { padding-right: 44px; }

.btn-mostra-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--testo-3);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--t);
}

.btn-mostra-pw:hover { color: var(--testo-2); }
.btn-mostra-pw svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.75; }

/* ── Pulsanti ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--testo);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--testo-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--testo); }

.btn-danger {
  background: transparent;
  color: var(--rosso);
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover { background: var(--rosso-soft); }

.btn-sm { padding: 6px 12px; font-size: .8125rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Alert ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert-error   { background: var(--rosso-soft);  color: var(--rosso);  border-color: rgba(239,68,68,.25); }
.alert-warning { background: var(--giallo-soft); color: var(--giallo); border-color: rgba(234,179,8,.25); }
.alert-success { background: var(--verde-soft);  color: var(--verde);  border-color: rgba(34,197,94,.25); }
.alert-info    { background: var(--blu-soft);    color: var(--blu);    border-color: rgba(59,130,246,.25); }

/* ── Preventivo / calcolo prezzi ──────────────────────────── */
.price-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 8px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: .875rem;
  color: var(--testo-2);
}

.price-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 14px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--testo);
}

.price-row.total .price-val { color: var(--arancio); font-family: 'Barlow', sans-serif; font-size: 1.5rem; }

/* ── ESG Widget ───────────────────────────────────────────── */
.esg-widget {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.esg-item {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.esg-value {
  font-family: 'Barlow', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--verde);
  line-height: 1;
  margin-bottom: 4px;
}

.esg-label {
  font-size: .6875rem;
  color: var(--testo-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ── Telemetria input ─────────────────────────────────────── */
.tele-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.tele-row:last-child { border-bottom: none; }

/* ── Calendario mini ──────────────────────────────────────── */
.calendar-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Stili FullCalendar override */
.fc { --fc-border-color: var(--border); --fc-page-bg-color: transparent; }
.fc .fc-toolbar-title { font-family: 'Barlow', sans-serif; font-size: 1.125rem; font-weight: 700; color: var(--testo); }
.fc .fc-button { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--testo) !important; font-size: .8125rem !important; }
.fc .fc-button:hover { background: var(--surface-3) !important; }
.fc .fc-button-active { background: var(--arancio) !important; border-color: var(--arancio) !important; }
.fc .fc-col-header-cell { background: var(--surface-2); }
.fc .fc-col-header-cell-cushion { color: var(--testo-2); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.fc .fc-daygrid-day-number { color: var(--testo-2); font-size: .8125rem; }
.fc .fc-daygrid-day.fc-day-today { background: var(--arancio-soft) !important; }
.fc-event { border-radius: 4px !important; border: none !important; font-size: .75rem !important; font-weight: 600 !important; }

/* ── Divisori e layout interno ────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--testo-3);
}

.empty-state svg {
  width: 40px; height: 40px;
  stroke: currentColor; fill: none;
  stroke-width: 1.25;
  margin: 0 auto 12px;
  opacity: .5;
}

.empty-state p { font-size: .875rem; margin-top: 8px; }

/* ── Utility ──────────────────────────────────────────────── */
.text-muted  { color: var(--testo-2); }
.text-small  { font-size: .8125rem; }
.text-right  { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }

/* ── Responsivo ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--t);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }

  .form-row,
  .form-row-3 { grid-template-columns: 1fr; }
  .esg-widget { grid-template-columns: 1fr 1fr; }
  .tele-row { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .stat-grid { grid-template-columns: 1fr; }
  .esg-widget { grid-template-columns: 1fr; }
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--testo-1);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--testo-3);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius);
  transition: color var(--t), background var(--t);
}
.modal-close:hover { color: var(--testo-1); background: var(--surface-2); }
