/* ── 02-layout.css ── */

/* Glass card */
.g {
  background: rgba(255, 255, 255, 0.028);
  backdrop-filter: blur(52px) saturate(200%);
  -webkit-backdrop-filter: blur(52px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 32px 72px -16px rgba(0, 0, 0, 0.55),
    0 12px 32px -8px rgba(0, 0, 0, 0.4),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.g::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(255,255,255,0.12) 25%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0.12) 75%, transparent 95%);
  z-index: 1;
  pointer-events: none;
}

.g::after {
  content: '';
  position: absolute;
  top: -20px; left: -20px;
  width: 40%; height: 40%;
  border-radius: 50%;
  background: radial-gradient(circle, hsla(var(--h), 80%, 70%, 0.04), transparent 70%);
  pointer-events: none;
}

.g-inner {
  background: rgba(255, 255, 255, 0.018);
  backdrop-filter: blur(32px) saturate(170%);
  -webkit-backdrop-filter: blur(32px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.055);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

/* Body base */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

img, video, canvas {
  max-width: 100%;
  height: auto;
}

input, button, textarea, select {
  max-width: 100%;
}

/* Sidebar */
aside.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 32px 0 28px;
  background: rgba(6, 3, 15, 0.72);
  backdrop-filter: blur(72px) saturate(220%);
  -webkit-backdrop-filter: blur(72px) saturate(220%);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    6px 0 80px rgba(0, 0, 0, 0.7),
    inset 1px 0 0 rgba(255, 255, 255, 0.05),
    inset -1px 0 0 rgba(0, 0, 0, 0.3);
}

.logo {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 30px;
  margin-bottom: 50px;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.logo-mark {
  width: 38px; height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent), var(--accent-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 28px hsla(var(--h), 72%, 64%, 0.35), 0 1px 0 rgba(255,255,255,0.3) inset;
}

nav {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 22px 30px 8px;
  opacity: 0.7;
}

nav a {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 30px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: all 0.2s ease;
  border-radius: 0 14px 14px 0;
  margin-right: 12px;
}

nav a svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.2s;
}

nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
}

nav a:hover svg { opacity: 0.75; }

nav a.active {
  color: var(--accent);
  background: linear-gradient(90deg, hsla(var(--h), 72%, 64%, 0.1), transparent 90%);
  border-right: 2.5px solid var(--accent);
  box-shadow: inset 4px 0 12px hsla(var(--h), 72%, 64%, 0.06);
}

nav a.active svg { opacity: 1; }

/* La nav scrolla internamente: logo e footer (logout) restano sempre visibili,
   anche su schermi bassi dove prima il logout finiva fuori vista. */
aside.sidebar > nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 20px 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-row:hover { background: rgba(255, 255, 255, 0.03); }

.av {
  width: 38px; height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 3px 18px hsla(var(--h), 72%, 64%, 0.28);
}

.user-name { font-size: 0.9rem; font-weight: 500; }
.user-role { font-size: 0.78rem; color: var(--text-dim); font-style: italic; font-weight: 300; }

/* Main layout */
main.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  width: calc(100% - var(--sidebar-w));
  min-width: 0;
  overflow-x: hidden;
}

/* Header */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: rgba(6, 3, 15, 0.5);
  backdrop-filter: blur(60px) saturate(200%);
  -webkit-backdrop-filter: blur(60px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 13px 20px;
  width: 340px;
  transition: all 0.25s;
}

.search:focus-within {
  border-color: hsla(var(--h), 72%, 64%, 0.28);
  box-shadow: 0 0 0 4px hsla(var(--h), 72%, 64%, 0.1), 0 8px 24px rgba(0,0,0,0.3);
  transform: translateY(-1px);
}

.search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 300;
  width: 100%;
}

.search input::placeholder { color: var(--text-dim); }

.h-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex: 0 0 auto;
}

.avatar-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  flex-shrink: 0;
}

.h-btn {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.h-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Menu burger — nascosto di default, visibile su mobile via responsive */
.menu-btn {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.83rem;
  color: var(--text-dim);
  font-weight: 300;
}

.dot-live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: breathe 2.5s ease-in-out infinite;
}

/* Content area */
.content.page-content {
  padding: 24px;
  width: 100%;
  max-width: 100%;
  margin: 0;
  flex: 1 1 auto;
  align-self: stretch;
  box-sizing: border-box;
}

.page-head { margin-bottom: 42px; }
.page-title { font-size: 1.6rem; font-weight: 400; letter-spacing: -0.025em; margin-bottom: 6px; }
.page-sub { font-size: 0.9rem; color: var(--text-dim); font-weight: 300; }
.page-sub #clock { color: var(--text-dim); }

/* Sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* Misc */
.user-badge {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
}

.user-badge svg { width: 19px; height: 19px; }
.user-badge span { font-size: .95rem; font-weight: 600; }

.page {
  display: none;
}

.page.page-active {
  display: block;
}













  
/* Sostituisci il vecchio CSS della pagina messaggi con questo */
.msg-shell{display:grid;grid-template-columns:380px 1fr;grid-template-rows:auto 1fr;min-height:calc(100vh - 120px);border:1px solid rgba(255,255,255,.08);border-radius:20px;overflow:hidden;background:linear-gradient(180deg,rgba(14,10,28,.92),rgba(7,5,16,.92));box-shadow:0 24px 80px rgba(0,0,0,.28)}
.msg-top{grid-column:1/-1;display:flex;align-items:center;gap:14px;padding:18px 20px;border-bottom:1px solid rgba(255,255,255,.06);background:rgba(255,255,255,.02);backdrop-filter:blur(14px)}
.msg-top h1{font-size:clamp(1.7rem,1.2rem + 1vw,2.2rem);line-height:1;color:#e8e5f2;margin-right:auto;font-weight:600;letter-spacing:-.03em}
.msg-search{position:relative;display:flex;align-items:center;min-width:240px;max-width:340px;flex:1}
.msg-search svg{position:absolute;left:14px;opacity:.42;pointer-events:none;color:#cfc8ee}
.msg-search input{width:100%;padding:10px 14px 10px 38px;border-radius:14px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.05);color:#f2efff;outline:none;font-size:.92rem}
.msg-search input::placeholder{color:#a89ccf}
.msg-tabs{display:flex;gap:8px;padding:4px;border-radius:999px;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.06)}
.msg-tabs button{border:0;background:transparent;color:#b7add8;padding:8px 14px;border-radius:999px;font-size:.86rem;cursor:pointer;transition:.18s ease;white-space:nowrap}
.msg-tabs button.active{background:#f2efff;color:#1a1230;font-weight:600;box-shadow:0 8px 20px rgba(0,0,0,.18)}
.msg-list-col{border-right:1px solid rgba(255,255,255,.06);background:rgba(255,255,255,.02);overflow:auto}
.msg-list{list-style:none;margin:0;padding:0}
.msg-item{display:grid;grid-template-columns:10px 36px 1fr auto;gap:12px;align-items:start;padding:14px 14px;border-bottom:1px solid rgba(255,255,255,.06);cursor:pointer;transition:.15s ease;background:transparent}
.msg-item:hover{background:rgba(255,255,255,.035)}
.msg-item.active{background:rgba(146,102,255,.14)}
.msg-dot{width:8px;height:8px;border-radius:999px;background:#7c5cff;margin-top:8px;box-shadow:0 0 0 4px rgba(124,92,255,.12)}
.msg-item.read .msg-dot{opacity:.15;box-shadow:none}
.msg-avatar{width:36px;height:36px;border-radius:12px;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#7c5cff,#4e2dd8);color:#fff;font-weight:700;font-size:.82rem;flex-shrink:0}
.msg-item-body{min-width:0}
.msg-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:3px}
.msg-sender{font-size:.86rem;color:#cfc8ee;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.msg-date{font-size:.74rem;color:#8f84b8;white-space:nowrap}
.msg-subject{font-size:.95rem;color:#f4f1ff;font-weight:600;line-height:1.25;margin-bottom:3px}
.msg-preview{font-size:.82rem;color:#b0a5d3;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.msg-badge{display:inline-flex;align-items:center;justify-content:center;padding:5px 10px;border-radius:999px;font-size:.68rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;align-self:start}
.msg-badge.info{background:rgba(96,165,250,.16);color:#8ec4ff;border:1px solid rgba(96,165,250,.22)}
.msg-badge.obbligatorio{background:rgba(251,113,133,.14);color:#ffafbd;border:1px solid rgba(251,113,133,.22)}
.msg-detail-col{display:flex;flex-direction:column;overflow:hidden;background:linear-gradient(180deg,rgba(12,8,24,.85),rgba(8,6,15,.96))}
.msg-detail-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:32px;color:#b8aed7}
.msg-detail-empty svg{opacity:.9;margin-bottom:12px;color:#dbcfff}
.msg-detail-empty p{margin:0;font-size:.95rem}
.msg-detail-header{padding:20px 22px 16px;border-bottom:1px solid rgba(255,255,255,.06);background:rgba(255,255,255,.02)}
.msg-detail-back{display:none;border:0;background:transparent;color:#cfc8ee;padding:0;margin:0 0 10px;cursor:pointer;font-size:.9rem}
.msg-detail-subject{font-size:clamp(1.15rem,1rem + .7vw,1.5rem);font-weight:700;color:#f6f3ff;line-height:1.2;margin-bottom:8px;letter-spacing:-.02em}
.msg-detail-meta{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.msg-detail-meta span{font-size:.76rem;color:#b3a8d8}
.msg-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.btn-msg{display:inline-flex;align-items:center;gap:8px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04);color:#f5f2ff;padding:9px 12px;border-radius:12px;cursor:pointer;font-size:.88rem;transition:.18s ease}
.btn-msg:hover{background:rgba(255,255,255,.08);transform:translateY(-1px)}
.btn-msg.primary{background:linear-gradient(135deg,#7c5cff,#4e2dd8);border-color:transparent;color:#fff}
.btn-msg.danger{background:rgba(251,113,133,.12);color:#ffb6c4;border-color:rgba(251,113,133,.22)}
.msg-status{display:inline-flex;align-items:center;font-size:.88rem;font-weight:600;padding:9px 12px;border-radius:12px}
.msg-status.done{background:rgba(52,211,153,.12);color:#34d399;border:1px solid rgba(52,211,153,.28)}
.msg-status.progress{background:rgba(245,158,11,.12);color:#f59e0b;border:1px solid rgba(245,158,11,.26)}
.msg-badge.done{background:rgba(52,211,153,.14);color:#34d399;border:1px solid rgba(52,211,153,.28)}
.msg-detail-body{padding:20px 22px;overflow:auto}
.msg-text{max-width:72ch;color:#e8e5f2;font-size:.96rem;line-height:1.72}
.msg-text p{margin:0 0 12px}
.msg-attachments{margin-top:18px;padding-top:16px;border-top:1px solid rgba(255,255,255,.08)}
.msg-attachments h4{margin:0 0 10px;color:#cfc8ee;font-size:.8rem;text-transform:uppercase;letter-spacing:.08em}
.msg-attachment{display:inline-flex;align-items:center;gap:8px;padding:9px 11px;border-radius:12px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04);color:#f5f2ff;text-decoration:none;font-size:.88rem;margin:0 8px 8px 0}
.msg-empty-list{padding:28px 18px;color:#b8aed7;text-align:center}
.msg-empty-list svg{display:block;margin:0 auto 10px;opacity:.75}
@media (max-width: 980px){.msg-shell{grid-template-columns:1fr;min-height:calc(100vh - 120px)}.msg-list-col{border-right:0;border-bottom:1px solid rgba(255,255,255,.06)}.msg-detail-col{display:none}.msg-detail-col.mobile-open{display:flex;position:fixed;inset:0;z-index:50}.msg-detail-back{display:inline-flex}}

.msg-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 120px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  overflow: hidden;
}

.msg-top {
  grid-column: 1 / -1;
}

.msg-list-col {
  grid-column: 1;
  grid-row: 2;
  overflow: auto;
}

.msg-detail-col {
  grid-column: 2;
  grid-row: 2;
  overflow: auto;
}

/* Ottimizzazioni telefono per la pagina messaggi */
@media (max-width: 640px) {
  .msg-shell {
    min-height: calc(100vh - 90px);
    border-radius: 16px;
  }
  .msg-top {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 10px;
  }
  .msg-top h1 {
    width: 100%;
    margin-right: 0;
    font-size: 1.5rem;
  }
  .msg-search {
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }
  .msg-tabs {
    width: 100%;
  }
  .msg-tabs button {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
  }
  /* Testo del messaggio con più spazio: badge spostato sotto, niente colonna a destra */
  .msg-item {
    grid-template-columns: 8px 32px 1fr;
    padding: 12px;
    gap: 10px;
  }
  .msg-avatar {
    width: 32px;
    height: 32px;
  }
  .msg-item .msg-badge {
    grid-column: 2 / -1;
    justify-self: start;
    margin-top: 2px;
  }
  .msg-preview {
    white-space: normal;
  }
  /* Dettaglio a schermo intero leggibile */
  .msg-detail-col.mobile-open {
    inset: 0;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top);
  }
  .msg-detail-header {
    padding: 16px 16px 12px;
  }
  .msg-detail-body {
    padding: 16px;
  }
  .msg-text {
    font-size: 0.92rem;
  }
}