/* Pannello admin: si appoggia ai token e ai componenti di style.css */
.muted { color: var(--muted); }
.admin { background: var(--bg); min-height: 100vh; }

/* ---------- accesso ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px); padding: 36px 28px; display: grid; gap: 14px;
  text-align: center; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font: 700 1.6rem var(--font-display); }
.login-card p { margin: 0; }
.login-mark { width: 48px; height: 48px; margin: 0 auto 4px; }
.btn-discord { background: #5865f2; color: #fff; justify-content: center; gap: 10px; display: inline-flex; align-items: center; }
.btn-discord:hover { background: #4752c4; }
.btn-discord svg { width: 20px; height: 20px; }
.back-link { font-size: 0.9rem; color: var(--muted); }

/* ---------- barra utente ---------- */
.user-box { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-alt); object-fit: cover; }
.user-meta { display: grid; line-height: 1.2; }
.user-meta strong { font-size: 0.9rem; }
.role-badge { font-size: 0.72rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 520px) { .user-meta { display: none; } }

/* ---------- tab ---------- */
.admin-main { padding-block: 24px 64px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 16px; margin-bottom: -1px;
  font: 600 0.95rem var(--font-body); color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; margin-left: 4px; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 4px; font: 700 1.4rem var(--font-display); }
.panel-head p { margin: 0; }
.inline-filter { display: flex; align-items: center; gap: 8px; }
.inline-filter select { width: auto; }

/* ---------- liste ---------- */
.admin-list { display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.item-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--bg-alt); display: grid; place-items: center; color: var(--muted); }
.item-thumb svg { width: 30px; height: 30px; }
.item-main { min-width: 0; display: grid; gap: 4px; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 0.85rem; color: var(--muted); }
.item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px;
  padding: 4px 10px; font-size: 0.76rem; font-weight: 600; cursor: pointer;
}
.toggle[aria-pressed='true'] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.toggle:disabled { opacity: 0.5; cursor: progress; }
@media (max-width: 720px) {
  .item { grid-template-columns: 56px 1fr; }
  .item-thumb { width: 56px; height: 56px; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ordini */
.order { grid-template-columns: 1fr auto; align-items: start; }
.order .item-main { gap: 6px; }
.order-msg { white-space: pre-wrap; background: var(--bg-alt); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; margin: 4px 0 0; }
.order-contact { font-weight: 600; word-break: break-all; }
.status-select { width: auto !important; padding: 7px 10px !important; font-size: 0.85rem; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-alt); color: var(--muted); }
.status-pill[data-status='nuovo'] { background: var(--accent-soft); color: var(--accent); }
.status-pill[data-status='completato'] { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-pill[data-status='annullato'] { text-decoration: line-through; }
@media (max-width: 720px) { .order { grid-template-columns: 1fr; } }

/* ---------- impostazioni ---------- */
.settings-form, .editor-body { display: grid; gap: 16px; }
.settings-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .row, .row.three { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.form-actions .form-status, .editor-foot .form-status { margin: 0 auto 0 0; }

/* ---------- editor ---------- */
.admin-dialog {
  width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.editor-form { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.editor-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.editor-head h2 { margin: 0; font: 700 1.25rem var(--font-display); }
.editor-head .dialog-close { position: static; }
.editor-body { padding: 20px; overflow-y: auto; }
.editor-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.field { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.field legend { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; padding: 0; }
.drop {
  display: grid; place-items: center; border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center; cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s;
}
.drop.small { padding: 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.image-manager { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.image-manager:empty { display: none; }
.img-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-alt); }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-tile.cover { outline: 2px solid var(--accent); outline-offset: 1px; }
.img-tile .tag { position: absolute; left: 6px; top: 6px; background: var(--accent); color: var(--accent-ink); font-size: 0.66rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.img-tile .tag.new { background: var(--text); color: var(--surface); }
.tile-actions { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgb(0 0 0 / .55)); }
.tile-actions button {
  width: 28px; height: 28px; border-radius: 8px; border: 0; cursor: pointer;
  background: rgb(255 255 255 / .9); color: #111; font-size: 0.9rem; line-height: 1;
}
.tile-actions button:disabled { opacity: .35; cursor: default; }
.tile-actions .rm { color: var(--danger); }

.model-box:empty { display: none; }
.model-row { display: flex; align-items: center; gap: 10px; background: var(--bg-alt); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }
.model-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast.err { background: var(--danger); color: #fff; }
