.admin-body { background: var(--cream); min-height: 100vh; }

/* L'attributo HTML "hidden" deve sempre vincere, anche sugli elementi che
   più sotto impostano un display esplicito (flex/grid) per il proprio
   stato visibile: senza questa regola .login-screen e .dashboard restano
   visibili contemporaneamente perché "display: flex/grid" in una regola
   d'autore ha precedenza sul default [hidden] { display: none } dello
   user-agent, a prescindere dalla specificità. */
[hidden] { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #e3f5ee, var(--cream) 60%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .brand-mark { margin: 0 auto 18px; width: 48px; height: 48px; }
.login-card .brand-mark svg { width: 24px; height: 24px; }
.login-card h1 { font-size: 1.4rem; }
.login-card label { display: block; text-align: left; font-size: 0.85rem; font-weight: 600; margin: 18px 0 6px; color: var(--green-900); }
.login-card input[type="password"],
.login-card input[type="text"] {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(15,122,92,0.25); font-size: 1rem; font-family: var(--font-body);
}
.btn-block { width: 100%; margin-top: 20px; }
.back-link { display: inline-block; margin-top: 18px; font-size: 0.85rem; color: var(--muted); }
.error-text { color: #c0405a; font-size: 0.85rem; margin-top: 14px; }
.success-text { color: var(--green-700); font-size: 0.85rem; margin-top: 14px; font-weight: 600; }

/* Dashboard layout */
.dashboard { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; align-items: start; }
.admin-sidebar {
  background: var(--green-900);
  color: var(--white);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  /* Resta visibile mentre si scorre il contenuto a destra, così il pulsante
     "Esci" è sempre raggiungibile senza dover risalire la pagina. */
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow-y: auto;
}

/* .btn-ghost di default ha testo verde scuro pensato per sfondi chiari: su
   uno sfondo verde scuro come questa sidebar risulterebbe illeggibile
   (testo verde scuro su sfondo verde scuro). Qui lo rendiamo visibile. */
.admin-sidebar .btn-ghost {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.35);
}
.admin-sidebar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.6);
}
.admin-brand { margin-bottom: 6px; }
.admin-brand .brand-text { color: var(--white); }
.admin-brand .brand-text strong { color: var(--gold); }

.current-user {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  margin-bottom: -8px;
}
.current-user-name { font-size: 0.85rem; font-weight: 700; color: var(--white); word-break: break-word; }
.role-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--green-900);
}
.role-badge.role-redattore { background: #a9d9c6; color: var(--green-900); }

.admin-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.admin-nav-btn {
  text-align: left;
  background: transparent;
  border: none;
  color: #cfe6da;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.admin-nav-btn:hover { background: rgba(255,255,255,0.08); }
.admin-nav-btn.active { background: var(--white); color: var(--green-900); }

.admin-main { padding: 40px 44px; overflow-y: auto; }
.admin-panel .panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 28px; flex-wrap: wrap;
}
.admin-panel h2 { margin: 0; }

/* Forms */
.card-form {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 26px;
  margin-bottom: 26px;
  box-shadow: 0 4px 20px -10px rgba(10,74,56,0.15);
}
.form-row { margin-bottom: 16px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.form-row-inline { display: flex; align-items: center; }
.form-row label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--green-900); }
.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid rgba(15,122,92,0.25); font-size: 0.95rem; font-family: var(--font-body);
  background: var(--white);
}
.form-row textarea { resize: vertical; }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }
.reset-target { font-weight: 600; color: var(--green-900); margin: 0 0 16px; }

/* Lists */
.admin-list { display: flex; flex-direction: column; gap: 14px; }
.admin-item {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 16px -12px rgba(10,74,56,0.2);
  flex-wrap: wrap;
}
.admin-item-main h3 { margin: 0 0 4px; font-size: 1rem; }
.admin-item-main p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.admin-item-meta { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-bottom: 4px; }
.badge-draft { display: inline-block; background: #fde7cf; color: #a5610b; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.badge-role { display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; margin-left: 8px; }
.badge-role.role-amministratore { background: #f6dfa8; color: #7a5a0b; }
.badge-role.role-redattore { background: var(--green-100); color: var(--green-700); }
.badge-role.role-inactive { background: #f3d4da; color: #a53350; }
.admin-item-actions { display: flex; gap: 8px; }
.icon-btn {
  border: none; background: var(--cream); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--green-900);
  font-family: var(--font-body);
}
.icon-btn:hover { background: var(--green-100); }
.icon-btn.danger { color: #c0405a; }
.icon-btn.danger:hover { background: #fbe4e8; }

/* Hours grid */
.hours-form-grid { display: flex; flex-direction: column; gap: 14px; }
.hour-day-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(15,122,92,0.08);
}
.hour-day-row:last-child { border-bottom: none; padding-bottom: 0; }
.hour-day-row .day-label { font-weight: 700; color: var(--green-900); }
.hour-day-row .time-group { display: flex; gap: 6px; align-items: center; font-size: 0.85rem; }
.hour-day-row input[type="time"] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(15,122,92,0.25); font-size: 0.85rem;
}
.hour-day-row label.closed-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .admin-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    min-height: 0;
    overflow-y: visible;
    top: 0;
    z-index: 20;
  }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-main { padding: 24px 18px; }
  .hour-day-row { grid-template-columns: 1fr; gap: 8px; }
}
