/* ═══════════════════════════════════════════════════
   AREA CLIENTI — AUTODEMO
   Tema: Refined Industrial · Charcoal + Forest Green + Gold
   Font: Syne (headers) + DM Sans (body)
═══════════════════════════════════════════════════ */

:root {
  --green:      #2d6a4f;
  --green-dark: #1b4332;
  --green-light:#40916c;
  --green-pale: #d8f3dc;
  --gold:       #d4a017;
  --gold-pale:  #fef9e7;
  --charcoal:   #1c1c1e;
  --charcoal-2: #2c2c2e;
  --mid:        #6b7280;
  --border:     #e5e7eb;
  --bg:         #f8f6f2;
  --bg-card:    #ffffff;
  --text:       #1c1c1e;
  --text-2:     #4b5563;
  --text-3:     #9ca3af;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:  0 4px 24px rgba(0,0,0,.10);
  --transition: 0.18s cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── TYPOGRAPHY ─────────────────────────────────── */
h1, h2, h3, .syne { font-family: 'Syne', sans-serif; }

/* ── AUTH PAGE ──────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.auth-bg__shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
}
.auth-bg__shape--1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #2d6a4f40, transparent);
  top: -150px; right: -100px;
}
.auth-bg__shape--2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #d4a01730, transparent);
  bottom: -100px; left: -80px;
}
.auth-bg__shape--3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #40916c25, transparent);
  top: 40%; left: 40%;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 24px 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.auth-brand__text {
  display: flex;
  flex-direction: column;
}
.auth-brand__name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--charcoal);
  line-height: 1;
}
.auth-brand__sub {
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,.06);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.5;
}

.auth-divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
  color: var(--text-3);
  font-size: 0.82rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 28px);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.link-forgot {
  float: right;
  font-size: 0.8rem;
  color: var(--green);
  text-decoration: none;
  font-weight: 500;
}
.link-forgot:hover { text-decoration: underline; }

.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0;
  margin-bottom: 20px;
  display: block;
  font-family: 'DM Sans', sans-serif;
}
.btn-back:hover { text-decoration: underline; }

/* ── FORMS ──────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  overflow: hidden;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,106,79,.12);
  background: white;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--green);
  margin-top: 2px;
  flex-shrink: 0;
}
.form-check label { font-size: 0.84rem; color: var(--text-2); line-height: 1.5; }

.input-wrap { position: relative; }
.input-wrap .form-input { padding-right: 44px; }
.btn-eye {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity var(--transition);
}
.btn-eye:hover { opacity: 1; }

/* ── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary {
  background: var(--green);
  color: white;
}
.btn--primary:hover:not(:disabled) {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(45,106,79,.3);
}
.btn--ghost {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--green-pale);
}
.btn--outline {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn--outline:hover:not(:disabled) { background: var(--bg); }
.btn--danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}
.btn--danger:hover:not(:disabled) { background: #fecaca; }
.btn--sm { padding: 7px 14px; font-size: 0.82rem; }
.btn--full { width: 100%; }
.btn--loading { position: relative; color: transparent !important; }
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ALERTS ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 18px;
  line-height: 1.5;
}
.alert--error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert--success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert--warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert--info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.link { color: var(--green); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ── APP SHELL ──────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--charcoal);
  flex-shrink: 0;
}
.topbar__menu {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-right: auto;
}
.topbar__menu span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--charcoal);
  border-radius: 2px;
  transition: all var(--transition);
}
.topbar__user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.topbar__user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.topbar__user-info > span:first-child {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}
.topbar__email { font-size: 0.75rem; color: var(--text-3); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-logout:hover { color: #dc2626; background: #fee2e2; }

/* ── SIDEBAR ────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  overflow-y: auto;
}

.nav-section { flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active {
  background: var(--green-pale);
  color: var(--green-dark);
  font-weight: 600;
}
.nav-link.active svg { opacity: 1; }

.nav-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.nav-contact__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.nav-contact__phone {
  font-size: 0.88rem;
  color: var(--green);
  text-decoration: none;
  font-weight: 500;
  display: block;
}
.nav-contact__phone:hover { text-decoration: underline; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 49;
}

/* ── MAIN CONTENT ───────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  min-height: 0;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-3);
  font-size: 0.9rem;
}

/* ── PAGE HEADER ────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.2;
}
.page-header__sub {
  font-size: 0.88rem;
  color: var(--text-2);
  margin-top: 4px;
}
.page-header__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── CARDS ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card__title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── KPI GRID ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}
.kpi-card__label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.kpi-card__value {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1;
}
.kpi-card__trend {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 4px;
}
.kpi-card--green .kpi-card__value { color: var(--green); }
.kpi-card--gold .kpi-card__value { color: var(--gold); }

/* ── BADGE ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.badge--green   { background: var(--green-pale); color: var(--green-dark); }
.badge--yellow  { background: #fef3c7; color: #92400e; }
.badge--red     { background: #fee2e2; color: #b91c1c; }
.badge--gray    { background: #f3f4f6; color: #6b7280; }
.badge--blue    { background: #dbeafe; color: #1e40af; }

/* ── TABLE ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.data-table td strong { color: var(--text); font-weight: 600; }

/* ── EMPTY STATE ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state__title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.empty-state__text { font-size: 0.85rem; }

/* ── DASHBOARD WELCOME ──────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  border-radius: var(--radius);
  padding: 28px 32px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.welcome-banner::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.welcome-banner::after {
  content: '';
  position: absolute;
  right: 60px; bottom: -60px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.welcome-banner__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
  position: relative;
}
.welcome-banner__sub {
  font-size: 0.9rem;
  opacity: 0.82;
  position: relative;
}
.welcome-banner__cta {
  margin-top: 20px;
  position: relative;
}
.welcome-banner .btn--outline {
  background: rgba(255,255,255,.15);
  color: white;
  border-color: rgba(255,255,255,.3);
  backdrop-filter: blur(10px);
}
.welcome-banner .btn--outline:hover {
  background: rgba(255,255,255,.25);
}

/* ── PRENOTA FORM ───────────────────────────────── */
.prenota-steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: white;
}
.prenota-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-3);
  border-right: 1px solid var(--border);
  transition: all var(--transition);
}
.prenota-step:last-child { border-right: none; }
.prenota-step__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--transition);
}
.prenota-step.active {
  color: var(--green-dark);
  background: var(--green-pale);
}
.prenota-step.active .prenota-step__num {
  background: var(--green);
  color: white;
}
.prenota-step.done .prenota-step__num {
  background: var(--green);
  color: white;
}
.prenota-step.done .prenota-step__num::after { content: '✓'; }
.prenota-step.done .prenota-step__label { text-decoration: line-through; opacity: .6; }

/* ── DOCUMENTI ──────────────────────────────────── */
.doc-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: all var(--transition);
}
.doc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-card__icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--green-pale);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.doc-card__info { flex: 1; min-width: 0; }
.doc-card__name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-card__meta { font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }

/* ── PROFILO ────────────────────────────────────── */
.profilo-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}
.profilo-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.profilo-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--charcoal);
}
.profilo-email { font-size: 0.88rem; color: var(--text-3); margin-top: 2px; }

/* ── TOAST ──────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s ease;
  pointer-events: all;
  max-width: 320px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast--success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.toast--error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.toast--info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 768px) {
  .topbar__menu { display: flex; }
  .topbar__user-info { display: none; }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 60px;
    bottom: 0;
    z-index: 50;
    width: 240px;
    transition: left var(--transition);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; }

  .main-content { padding: 16px; }
  .auth-card { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .prenota-steps { flex-direction: column; }
  .prenota-step { border-right: none; border-bottom: 1px solid var(--border); }
  .prenota-step:last-child { border-bottom: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .welcome-banner { padding: 20px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
