/* public/admin/admin.css — coerente con la palette del sito pubblico */

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

:root {
  --ink: #16232E;
  --rule: #0F1B24;
  --cobalt: #E8720C;
  --cobalt-dim: #C25F09;
  --amber: #E8720C;
  --mist: #F4F6F8;
  --paper: #FFFFFF;
  --edge: #E1E5E9;
  --white: #FFFFFF;
  --text-secondary: #5C6670;
  --success: #1C8A4B;
  --danger: #C23B3B;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--cobalt); }

/* --- LAYOUT LOGIN / RESET (centrato) --- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 32px rgba(26,26,46,0.08);
}
.auth-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--rule);
  text-align: center;
  margin-bottom: 0.3rem;
}
.auth-logo span { color: var(--amber); }
.auth-sub {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

/* --- FORM ELEMENTS --- */
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--rule);
  margin-bottom: 0.35rem;
}
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--edge);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 1.1rem;
  background: var(--white);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--cobalt);
}
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.3rem;
  border-radius: 8px;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: var(--cobalt); color: var(--white); width: 100%; }
.btn-primary:hover { background: var(--cobalt-dim); }
.btn-secondary { background: var(--mist); color: var(--rule); }
.btn-amber { background: var(--amber); color: var(--white); }
.btn-danger { background: var(--white); color: var(--danger); border: 1px solid var(--danger); }
.btn-ghost { background: none; color: var(--cobalt); padding: 0.4rem 0.6rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.link-small {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--cobalt);
  text-decoration: none;
  cursor: pointer;
}

.msg { font-size: 0.82rem; margin-bottom: 1rem; padding: 0.6rem 0.8rem; border-radius: 8px; }
.msg-error { background: #FBEAEA; color: var(--danger); }
.msg-success { background: #E7F5EC; color: var(--success); }

/* --- APP SHELL --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--rule);
  color: var(--white);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
}
.sidebar-logo span { color: var(--amber); }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.sidebar-nav a, .sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.5rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}
.sidebar-nav a.active, .sidebar-nav a:hover, .sidebar-nav button:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.sidebar-footer { padding: 1rem 1.5rem 0; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 1rem; }
.sidebar-user { font-size: 0.78rem; color: rgba(255,255,255,0.5); margin-bottom: 0.6rem; }

.main-content { flex: 1; padding: 2rem 2.5rem; max-width: 1100px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--rule);
}

/* --- TABS --- */
.tabs { display: flex; gap: 0.3rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab {
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--mist);
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.tab.active { background: var(--cobalt); color: var(--white); }

/* --- TABLE / LIST --- */
.data-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: 10px; overflow: hidden; border: 1px solid var(--edge); }
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 0.8rem 1rem;
  background: var(--mist);
  border-bottom: 1px solid var(--edge);
}
.data-table tbody tr:hover { background: var(--mist); }

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--mist);
  font-size: 0.88rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-bozza { background: #FFF3E0; color: var(--amber); }
.badge-pubblicato { background: #E7F5EC; color: var(--success); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* --- CARDS / FORM SECTIONS (editor wizard) --- */
.card {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rule);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title .step-num {
  width: 22px; height: 22px;
  background: var(--cobalt);
  color: var(--white);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
}

.tipo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; margin-bottom: 0.5rem; }
.tipo-option {
  border: 2px solid var(--edge);
  border-radius: 10px;
  padding: 1rem 0.5rem;
  text-align: center;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.tipo-option.selected { border-color: var(--cobalt); background: #EEF2FB; color: var(--cobalt); }

.btn-benvenuto:hover { border-color: var(--cobalt) !important; background: #EEF2FB !important; transform: translateY(-2px); transition: all 0.15s; }

.editor-toolbar {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem;
  background: var(--mist);
  border: 1px solid var(--edge);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.editor-toolbar button {
  border: none;
  background: var(--white);
  border-radius: 5px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--rule);
}
.editor-toolbar button:hover { background: var(--edge); }
.editor-body {
  border: 1px solid var(--edge);
  border-radius: 0 0 8px 8px;
  padding: 1rem;
  min-height: 220px;
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 1.1rem;
}
.editor-body:focus { outline: none; border-color: var(--cobalt); }
.editor-body h2 { font-size: 1.1rem; color: var(--rule); margin: 0.5rem 0; }

.import-docx-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--mist); border: 1px dashed var(--cobalt); color: var(--cobalt);
  padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; margin-bottom: 1.25rem;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }

.attachment-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem; background: var(--mist); border-radius: 8px; margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.wizard-actions {
  display: flex; justify-content: flex-end; gap: 0.7rem;
  padding-top: 1rem;
}

.loading-overlay {
  position: fixed; inset: 0; background: rgba(250,250,250,0.7);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--text-secondary); z-index: 999;
}

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 50; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: visible; padding: 0.6rem 0.75rem; }
  .sidebar-logo { display: none; }
  .sidebar-nav { flex-direction: row; flex: 0 0 auto; }
  .sidebar-nav a, .sidebar-nav button { padding: 0.5rem 0.8rem; white-space: nowrap; }
  .sidebar-footer {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0;
    border-top: none;
    flex-shrink: 0;
  }
  .sidebar-user { display: none; } /* troppo lungo per stare in una barra orizzontale */
  .sidebar-footer a { margin-bottom: 0; white-space: nowrap; padding: 0.5rem 0.6rem; font-size: 0.75rem; }
  .sidebar-footer .btn { width: auto; padding: 0.5rem 0.9rem; white-space: nowrap; }
  .main-content { padding: 1.25rem; }
}
