/* ── Design System — Portale Clienti marcobagiacchi.it ── v2 ── */

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Instrument+Serif:ital@1&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variabili CSS ──────────────────────────────────────────── */
:root {
  /* Colori */
  --bg:          #0D0E12;
  --surface-1:   #13151C;
  --surface-2:   #1A1D27;
  --surface-3:   #20243200;

  --accent:      #7C6FEC;
  --accent-2:    #4FC3C8;
  --gradient:    linear-gradient(135deg, #7C6FEC, #4FC3C8);
  --gradient-text: linear-gradient(90deg, #7C6FEC, #4FC3C8);

  --text-primary:   #E8E9EE;
  --text-secondary: #B0B3C1;
  --text-muted:     #6B7080;

  --border:      rgba(255, 255, 255, 0.08);
  --border-focus: rgba(124, 111, 236, 0.5);

  /* Tipografia */
  --font-sans:  'Space Grotesk', system-ui, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  /* Border radius */
  --radius-sm:   8px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-pill: 999px;

  /* Spacing */
  --sidebar-w: 260px;

  /* Transizioni */
  --transition: 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }

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

ul, ol { list-style: none; }

button, input, select, textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
}

/* ── Utility ────────────────────────────────────────────────── */
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT PORTALE
══════════════════════════════════════════════════════════════ */

.portal-layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-logo .logo-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin-top: 4px;
}

.sidebar-logo .logo-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  background: linear-gradient(135deg, rgba(124,111,236,0.2), rgba(79,195,200,0.2));
  border: 1px solid rgba(124,111,236,0.3);
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.06em;
}

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

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 24px 8px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 2px solid transparent;
  position: relative;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  border-left-color: var(--border);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(124,111,236,0.08);
  border-left-color: var(--accent);
}

.sidebar-nav .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-nav a.active .nav-icon { opacity: 1; }

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-user-info .user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(255, 80, 80, 0.1);
  border-color: rgba(255, 80, 80, 0.3);
  color: #ff6b6b;
}

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

.page-header {
  padding: 36px 40px 0;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: 6px;
  font-size: 0.9rem;
}

.page-body {
  padding: 28px 40px 48px;
  flex: 1;
}

/* ── Topbar mobile ──────────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ══════════════════════════════════════════════════════════════
   COMPONENTI UI
══════════════════════════════════════════════════════════════ */

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.card-sm { padding: 16px 20px; }
.card-lg { padding: 32px; }

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Card con bordo gradiente */
.card-accent {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  padding: 24px;
  position: relative;
}

.card-accent::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 1px;
  background: var(--gradient);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ── Grid cards ─────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.cards-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

/* ── Badge / Stato ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-attivo    { background: rgba(79,195,200,0.15); color: #4FC3C8; border: 1px solid rgba(79,195,200,0.3); }
.badge-scadenza  { background: rgba(255,183,77,0.15);  color: #FFB74D; border: 1px solid rgba(255,183,77,0.3); }
.badge-scaduto   { background: rgba(239,83,80,0.15);   color: #EF5350; border: 1px solid rgba(239,83,80,0.3); }
.badge-sospeso   { background: rgba(176,179,193,0.1);  color: var(--text-muted); border: 1px solid var(--border); }
.badge-futura    { background: rgba(124,111,236,0.15); color: var(--accent); border: 1px solid rgba(124,111,236,0.3); }
.badge-imminente { background: rgba(255,183,77,0.15);  color: #FFB74D; border: 1px solid rgba(255,183,77,0.3); }
.badge-completata{ background: rgba(102,187,106,0.15); color: #66BB6A; border: 1px solid rgba(102,187,106,0.3); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ── Bottoni ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 2px 16px rgba(124,111,236,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(124,111,236,0.45);
  color: white;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--surface-1);
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239,83,80,0.15);
  border: 1px solid rgba(239,83,80,0.3);
  color: #EF5350;
}

.btn-danger:hover {
  background: rgba(239,83,80,0.25);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ── Form ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}

select.form-control { cursor: pointer; }

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

.form-error {
  display: block;
  color: #EF5350;
  font-size: 0.78rem;
  margin-top: 5px;
}

.form-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 5px;
}

.form-control-error {
  border-color: rgba(239, 83, 80, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.12) !important;
}

/* ── Details/Summary accordion ──────────────────────────────── */
details summary::-webkit-details-marker { display: none; }

details[open] .details-chevron {
  transform: rotate(180deg);
}

details summary { user-select: none; }

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

.alert-error   { background: rgba(239,83,80,0.1);   border-color: rgba(239,83,80,0.3);   color: #EF5350; }
.alert-success { background: rgba(102,187,106,0.1); border-color: rgba(102,187,106,0.3); color: #66BB6A; }
.alert-info    { background: rgba(124,111,236,0.1); border-color: rgba(124,111,236,0.3); color: var(--accent); }
.alert-warning { background: rgba(255,183,77,0.1);  border-color: rgba(255,183,77,0.3);  color: #FFB74D; }

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

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

.table th {
  text-align: left;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Timeline scadenze ──────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 28px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -23px;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--border);
  z-index: 1;
}

.timeline-item.imminente .timeline-dot { border-color: #FFB74D; background: rgba(255,183,77,0.2); }
.timeline-item.futura     .timeline-dot { border-color: var(--accent); background: rgba(124,111,236,0.2); }
.timeline-item.completata .timeline-dot { border-color: #66BB6A; background: rgba(102,187,106,0.2); }
.timeline-item.scaduta    .timeline-dot { border-color: #EF5350; background: rgba(239,83,80,0.2); }

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.timeline-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,111,236,0.12) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-glow-2 {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,195,200,0.08) 0%, transparent 70%);
  bottom: -100px;
  left: -80px;
  pointer-events: none;
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .logo-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.login-divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════════════ */

.welcome-banner {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: radial-gradient(ellipse at right center, rgba(124,111,236,0.12), transparent 60%);
  pointer-events: none;
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.welcome-sub {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 6px;
}

.together-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 4px 12px;
  background: rgba(124,111,236,0.12);
  border: 1px solid rgba(124,111,236,0.25);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--accent);
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-accent  { background: rgba(124,111,236,0.15); color: var(--accent); }
.stat-icon-cyan    { background: rgba(79,195,200,0.15);  color: #4FC3C8; }
.stat-icon-amber   { background: rgba(255,183,77,0.15);  color: #FFB74D; }
.stat-icon-green   { background: rgba(102,187,106,0.15); color: #66BB6A; }

.stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Sezione con header ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════
   ADMIN — stili extra
══════════════════════════════════════════════════════════════ */

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(239,83,80,0.15);
  border: 1px solid rgba(239,83,80,0.3);
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: #EF5350;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    display: flex;
  }

  .page-header { padding: 24px 20px 0; }
  .page-body   { padding: 20px 20px 40px; }

  .cards-grid   { grid-template-columns: 1fr 1fr; }
  .cards-grid-2 { grid-template-columns: 1fr; }

  .login-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .welcome-title { font-size: 1.2rem; }
}

/* ── Overlay mobile sidebar ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ── Scrollbar custom ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
