/* =====================================================================
   Back office — shell admin (sidebar + topbar) e componenti
   Dipende dai token di app.css.
   ===================================================================== */

/* ---------- Login / auth ---------- */
.auth-body{ min-height:100vh; margin:0; display:grid; place-items:center;
  background:
    radial-gradient(800px 400px at 80% -10%, color-mix(in srgb,var(--brand) 18%, transparent), transparent 70%),
    radial-gradient(600px 300px at 0% 110%, color-mix(in srgb,var(--accent) 12%, transparent), transparent 70%),
    #eef2f6;
  padding:24px; }
.auth-wrap{ width:100%; max-width:420px; }
.auth-card{ padding:32px 30px; }
.auth-head{ text-align:center; margin-bottom:22px; }
.auth-head .brand-mark{ margin:0 auto 12px; }
.auth-head h1{ font-size:1.4rem; margin:0; }

/* ---------- Layout admin ---------- */
:root{ --sidebar-w: 248px; }
body.admin{ background:#f4f6f9; }
.admin-sidebar{
  position:fixed; top:0; left:0; bottom:0; width:var(--sidebar-w);
  background:#0f172a; color:#cbd5e1; display:flex; flex-direction:column; z-index:60;
}
.admin-brand{ display:flex; align-items:center; gap:10px; padding:18px 20px; color:#fff; font-weight:700; border-bottom:1px solid #1e293b; }
.admin-brand:hover{ text-decoration:none; }
.admin-brand-name{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.admin-nav{ flex:1; overflow-y:auto; padding:12px 12px; display:flex; flex-direction:column; gap:2px; }
.admin-nav-item{ display:flex; align-items:center; gap:12px; padding:10px 14px; border-radius:10px; color:#cbd5e1; font-weight:500; font-size:.95rem; }
.admin-nav-item:hover{ background:#1e293b; color:#fff; text-decoration:none; }
.admin-nav-item.active{ background:var(--brand); color:#fff; }
.admin-nav-item .ico{ width:22px; text-align:center; font-size:1.05rem; }
.admin-sidebar-foot{ padding:12px; border-top:1px solid #1e293b; }

.admin-main{ margin-left:var(--sidebar-w); min-height:100vh; display:flex; flex-direction:column; }
.admin-topbar{ position:sticky; top:0; z-index:40; height:64px; background:rgba(255,255,255,.9); backdrop-filter:blur(8px); border-bottom:1px solid var(--border); display:flex; align-items:center; gap:14px; padding:0 24px; }
.admin-title{ font-size:1.2rem; margin:0; flex:1; }
.admin-user{ display:flex; align-items:center; gap:12px; }
.admin-user-name{ font-weight:600; font-size:.92rem; color:var(--muted); }
.admin-burger{ display:none; width:42px; height:40px; border:1px solid var(--border); background:#fff; border-radius:var(--r-sm); cursor:pointer; }
.admin-burger span,.admin-burger span::before,.admin-burger span::after{ content:""; display:block; width:18px; height:2px; background:var(--text); margin:0 auto; position:relative; }
.admin-burger span::before{ position:absolute; top:-6px; } .admin-burger span::after{ position:absolute; top:6px; }
.admin-content{ padding:26px 24px; flex:1; max-width:1200px; width:100%; }

/* ---------- Badge menu + campanella ---------- */
.nav-badge{ margin-left:auto; background:var(--danger); color:#fff; font-size:.7rem; font-weight:700; min-width:18px; height:18px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center; padding:0 5px; }
.bell{ position:relative; }
.bell-btn{ position:relative; width:42px; height:40px; border:1px solid var(--border); background:#fff; border-radius:var(--r-sm); cursor:pointer; color:var(--text); font-size:1.05rem; }
.bell-btn:hover{ background:var(--surface-2); }
.bell-count{ position:absolute; top:-6px; right:-6px; background:var(--danger); color:#fff; font-size:.66rem; font-weight:700; min-width:17px; height:17px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center; padding:0 4px; }
.bell-menu{ position:absolute; right:0; top:50px; width:330px; max-width:90vw; background:#fff; border:1px solid var(--border); border-radius:var(--r); box-shadow:var(--shadow-lg); z-index:80; overflow:hidden; }
.bell-head{ padding:12px 16px; font-weight:700; border-bottom:1px solid var(--border); }
.bell-empty{ padding:26px 16px; text-align:center; color:var(--muted); }
.bell-item{ display:flex; gap:12px; padding:11px 16px; border-bottom:1px solid var(--border); color:inherit; }
.bell-item:last-child{ border-bottom:none; }
.bell-item:hover{ background:var(--surface-2); text-decoration:none; }
.bell-item.unread{ background:color-mix(in srgb,var(--brand) 7%, #fff); }
.bell-item > i{ color:var(--brand); margin-top:3px; }

/* ---------- Tema scuro (solo back office) ---------- */
.theme-toggle{ width:42px; height:40px; border:1px solid var(--border); background:#fff; border-radius:var(--r-sm); cursor:pointer; color:var(--text); font-size:1rem; }
.theme-toggle:hover{ background:var(--surface-2); }
html.theme-dark body.admin{
  --bg:#0f172a; --surface:#1e293b; --surface-2:#172033;
  --border:#2c3a4f; --border-strong:#3f5170;
  --text:#e6edf6; --muted:#9fb0c3; --muted-2:#6b7c91;
  background:var(--bg);
}
html.theme-dark .admin-topbar{ background:rgba(15,23,42,.92); }
html.theme-dark .input, html.theme-dark .select, html.theme-dark .textarea,
html.theme-dark .btn-outline, html.theme-dark .bell-btn, html.theme-dark .theme-toggle,
html.theme-dark .cal-nav, html.theme-dark .slot, html.theme-dark .cal-day{ background:var(--surface-2); color:var(--text); border-color:var(--border-strong); }
html.theme-dark .input::placeholder, html.theme-dark .textarea::placeholder{ color:var(--muted-2); }
html.theme-dark .data-table, html.theme-dark .cal-month, html.theme-dark .bell-menu{ background:var(--surface); }
html.theme-dark .cal-month-head{ background:var(--surface-2); }
html.theme-dark .cal-cell.out{ background:#131c2e; }
html.theme-dark .cal-ev{ background:var(--surface-2); }
html.theme-dark .badge-gray{ background:#33415a; color:#cbd5e1; }
html.theme-dark input[type="date"], html.theme-dark input[type="time"]{ color-scheme:dark; }

/* ---------- Impostazioni a tab ---------- */
.settings-tabs{ display:flex; gap:2px; flex-wrap:wrap; border-bottom:1px solid var(--border); margin-bottom:22px; }
.settings-tab{ padding:11px 16px; background:none; border:none; border-bottom:3px solid transparent; font-weight:600; color:var(--muted); cursor:pointer; font-size:.95rem; font-family:inherit; }
.settings-tab:hover{ color:var(--text); }
.settings-tab.active{ color:var(--brand-dark); border-bottom-color:var(--brand); }
.settings-pane{ display:none; }
.settings-pane.active{ display:block; }

/* ---------- Ottimizzazioni mobile back office ---------- */
@media (max-width: 640px){
  .admin-topbar{ padding:0 12px; gap:8px; }
  .admin-user-name{ display:none; }
  .admin-title{ font-size:1.05rem; }
  .admin-content{ padding:16px 12px; }
  .card-pad, .card-body{ padding:16px; }
  .settings-tab{ padding:10px 12px; font-size:.9rem; }
  .stat-card{ padding:14px 16px; }
  .bell-menu{ position:fixed; left:8px; right:8px; top:64px; width:auto; }
}

/* ---------- Dashboard ---------- */
.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:18px; margin-bottom:22px; }
.stat-card{ padding:18px 20px; display:flex; align-items:center; gap:16px; }
.stat-icon{ width:50px; height:50px; border-radius:14px; display:grid; place-items:center; font-size:1.4rem; color:#fff; flex:0 0 auto; }
.stat-value{ font-size:1.9rem; font-weight:800; line-height:1; }
.stat-label{ font-size:.88rem; color:#475569; margin-top:3px; }
.dash-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }

/* ---------- Tabelle/azioni admin riutilizzabili ---------- */
.toolbar{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:18px; }
.toolbar .spacer{ flex:1; }
.page-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.data-table{ width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--border); border-radius:var(--r-lg); overflow:hidden; }
.data-table th,.data-table td{ padding:12px 16px; text-align:left; border-bottom:1px solid var(--border); font-size:.93rem; }
.data-table th{ background:var(--surface-2); color:var(--muted); font-size:.76rem; text-transform:uppercase; letter-spacing:.04em; }
.data-table tbody tr:hover{ background:var(--surface-2); }
.data-table .row-actions{ display:flex; gap:6px; justify-content:flex-end; }

/* ---------- Vista mensile agenda ---------- */
.cal-month{ background:#fff; border:1px solid var(--border); border-radius:var(--r-lg); overflow:hidden; }
.cal-month-head{ display:grid; grid-template-columns:repeat(7,1fr); background:var(--surface-2); }
.cal-month-head>div{ padding:9px; text-align:center; font-size:.72rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
.cal-month-row{ display:grid; grid-template-columns:repeat(7,1fr); }
.cal-cell{ min-height:108px; border-top:1px solid var(--border); border-left:1px solid var(--border); padding:5px; display:flex; flex-direction:column; gap:3px; }
.cal-cell:nth-child(7n+1){ border-left:none; }
.cal-cell.out{ background:var(--surface-2); }
.cal-cell.out .cal-cell-day{ color:var(--muted-2); }
.cal-cell.today .cal-cell-day{ background:var(--brand); color:#fff; }
.cal-cell-day{ align-self:flex-start; min-width:24px; height:24px; padding:0 6px; display:inline-flex; align-items:center; justify-content:center; border-radius:7px; font-weight:700; font-size:.85rem; color:var(--text); text-decoration:none; }
.cal-cell-day:hover{ background:var(--surface-2); text-decoration:none; }
.cal-cell-events{ display:flex; flex-direction:column; gap:2px; overflow:hidden; }
.cal-ev{ font-size:.74rem; padding:2px 6px; background:var(--surface-2); border-radius:4px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-ev:hover{ background:color-mix(in srgb,var(--brand) 14%,#fff); text-decoration:none; }
.cal-ev-time{ font-weight:700; color:var(--brand-dark); }
.cal-more{ font-size:.72rem; color:var(--muted); padding:1px 6px; }
.cal-more:hover{ color:var(--brand); }
@media (max-width:760px){ .cal-cell{ min-height:74px; } .cal-ev{ font-size:.68rem; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px){
  .dash-grid{ grid-template-columns:1fr; }
  .admin-sidebar{ transform:translateX(-100%); transition:transform .2s ease; box-shadow:var(--shadow-lg); }
  .admin-sidebar.open{ transform:translateX(0); }
  .admin-main{ margin-left:0; }
  .admin-burger{ display:block; }
}
