/* ================================================================
   A176lab — pannello di amministrazione
   ================================================================ */

:root {
  --bg: #f4f2ee;
  --ink: #101112;
  --ink-soft: #4a4a48;
  --accent: #8a6b44;        /* bronzo per testi/hover su fondo chiaro */
  --accent-bright: #d2b48c; /* tan per gli elementi sulla sidebar scura */
  --line: #d8d4cc;
  --white: #f9f8f5;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

a { color: inherit; text-decoration: none; }

/* ---------- Sidebar ---------- */
.admin-side {
  width: 230px;
  flex-shrink: 0;
  background: var(--ink);
  color: #a9a7a1;
  display: flex;
  flex-direction: column;
  padding: 28px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  padding: 0 24px 24px;
  border-bottom: 1px solid #2a2b2c;
}
.admin-logo span { color: var(--accent-bright); }
.admin-logo em {
  display: block;
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #6a6a68;
  margin-top: 2px;
}
.admin-side nav {
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex: 1;
}
.admin-side nav a {
  padding: 12px 24px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.25s, background 0.25s;
}
.admin-side nav a:hover { color: var(--white); background: #17181a; }
.admin-side nav a.active {
  color: var(--white);
  border-left-color: var(--accent-bright);
  background: #17181a;
}
.admin-side-foot {
  padding: 16px 24px 0;
  border-top: 1px solid #2a2b2c;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.88rem;
}
.admin-side-foot a:hover { color: var(--white); }
.admin-side-foot .logout { color: #e0907f; }

/* ---------- Main ---------- */
.admin-main {
  flex: 1;
  padding: 40px 48px 80px;
  max-width: 1100px;
}
.admin-main h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 28px 32px;
  margin-bottom: 28px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.toolbar { margin-bottom: 24px; }

/* ---------- Form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}
.form-grid .span2 { grid-column: span 2; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="password"],
.form-grid select,
.form-grid textarea {
  font: inherit;
  font-weight: 400;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  transition: border-color 0.25s;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-grid input[type="file"] { font-size: 0.88rem; }
.form-grid .checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.form-actions { display: flex; gap: 12px; align-items: center; }

.btn-primary {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--ink);
  color: var(--white);
  border: 0;
  border-radius: 100px;
  padding: 12px 30px;
  cursor: pointer;
  transition: background 0.25s;
}
.btn-primary:hover { background: var(--accent); }
.btn-ghost {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
  padding: 12px 8px;
}
.btn-ghost:hover { color: var(--accent); }

.hint { font-size: 0.85rem; color: var(--ink-soft); font-weight: 400; }

.current-img {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.current-img img {
  height: 64px;
  width: 96px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.gallery-item img,
.gallery-item video {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.gallery-item span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Tabelle ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table .thumb img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
}
.data-table .title { font-weight: 600; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a {
  font-weight: 600;
  color: var(--ink);
  margin-right: 14px;
}
.row-actions a:hover { color: var(--accent); }
.row-actions form { display: inline; }
.link-danger {
  background: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  color: #b03a2e;
  cursor: pointer;
}
.link-danger:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: 100px;
}
.badge.on { background: #dcecdc; color: #1e6b32; }
.badge.off { background: #eee6d8; color: #8a6d1a; }

/* ---------- Flash ---------- */
.flash {
  padding: 12px 18px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 0.92rem;
}
.flash-ok { background: #dcecdc; color: #1e6b32; }
.flash-err { background: #f4d9d3; color: #932d19; }

/* ---------- Login / setup ---------- */
.auth-card {
  max-width: 420px;
  margin: 8vh auto 0;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 36px 38px 40px;
}
.auth-card .auth-intro {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 22px;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}
.auth-card input {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}
.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-card .btn-primary { margin-top: 6px; }
.auth-back { margin-top: 18px; text-align: center; }
.auth-back a:hover { color: var(--accent); }

/* Senza sidebar (login/setup) il main occupa tutto */
body > .admin-main:first-child { max-width: none; }
body > .admin-main:first-child h1 {
  text-align: center;
  margin-top: 4vh;
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  body { flex-direction: column; }
  .admin-side {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px;
  }
  .admin-logo { padding: 0 16px 0 0; border: 0; }
  .admin-side nav { flex-direction: row; padding: 0; }
  .admin-side nav a { padding: 8px 12px; border-left: 0; }
  .admin-side-foot { border: 0; padding: 0; flex-direction: row; margin-left: auto; }
  .admin-main { padding: 24px 16px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .data-table th:nth-child(4), .data-table td:nth-child(4),
  .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; }
}

.link-plain {
  background: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  margin-right: 14px;
}
.link-plain:hover { color: var(--accent); text-decoration: underline; }
