/* ============================================================
   Doxa — Base stylesheet
   Layout, componenti e tipografia condivisi da tutti i tenant.
   I colori sono CSS variables: ogni tenant le sovrascrive
   nel proprio static/<slug>/css/style.css
   ============================================================ */

/* ── Variables (default: tema Poste Italiane) ─────────────── */
:root {
  --color-primary:        #0047BB;
  --color-primary-dark:   #003494;
  --color-accent:         #eedc00;
  --color-accent-dark:    #d4c500;
  --color-text:           #222427;
  --color-text-muted:     #6b7280;
  --color-bg:             #f6f6f6;
  --color-surface:        #ffffff;
  --color-border:         #e5e7eb;
  --color-danger:         #dc2626;
  --color-danger-hover:   #b91c1c;

  --font-family:          'Inter', system-ui, -apple-system, sans-serif;
  --max-width:            1100px;
  --radius:               6px;
  --shadow:               0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:            0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--color-primary);
  border-bottom: 4px solid var(--color-accent);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
}

.site-header__logo {
  height: 36px;
  width: auto;
  display: block;
}

.site-header__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-header__user {
  color: rgba(255,255,255,.85);
  font-size: .875rem;
}

.site-header__user strong {
  color: #fff;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: #1a1f2e;
  color: #adb5bd;
  font-size: .8125rem;
  margin-top: auto;
  border-top: 4px solid var(--color-accent);
}

.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  text-align: center;
}

.site-footer__links {
  display: flex;
  gap: 1.5rem;
}

.site-footer__links a {
  color: #adb5bd;
  font-size: .8125rem;
}

.site-footer__links a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

/* ── Main content wrapper ─────────────────────────────────── */
.main-content {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* ── Page header (titolo pagina + azioni) ─────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: .25rem;
}

.page-header a {
  font-size: .8125rem;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-bottom: .25rem;
}

.page-header a:hover { color: var(--color-primary); text-decoration: none; }

.page-header__actions {
  display: flex;
  gap: .75rem;
  align-items: center;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  background: var(--color-accent);
  color: var(--color-text);
}

.btn:hover { background: var(--color-accent-dark); text-decoration: none; color: var(--color-text); }

.btn--secondary {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.4);
}

.btn--secondary:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-color: rgba(255,255,255,.7);
}

/* btn secondario fuori dall'header (sfondo chiaro) */
.main-content .btn--secondary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.main-content .btn--secondary:hover {
  background: var(--color-primary);
  color: #fff;
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--danger:hover { background: var(--color-danger-hover); color: #fff; }

.btn--small {
  padding: .25rem .625rem;
  font-size: .75rem;
}

/* Logout nel header */
.btn--logout {
  background: transparent;
  color: rgba(255,255,255,.8);
  border: 1.5px solid rgba(255,255,255,.35);
  padding: .375rem .875rem;
}

.btn--logout:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
}

/* ── Item list (progetti, topic) ──────────────────────────── */
.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.item-list__row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .75rem;
  transition: box-shadow .15s, border-color .15s, opacity .15s;
}

.item-list__row:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.item-list__content {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex: 1;
  min-width: 0;
}

.item-list__row a {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.item-list__row a:hover { color: var(--color-primary); text-decoration: none; }

.item-list__row p {
  font-size: .875rem;
  color: var(--color-text-muted);
  margin: 0;
}

.item-list__row small {
  font-size: .8rem;
  color: var(--color-text-muted);
}

/* ── Drag & drop ─────────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  user-select: none;
  line-height: 1;
  padding: .25rem;
  flex-shrink: 0;
}
.drag-handle:hover { color: var(--color-text); }
.drag-handle:active { cursor: grabbing; }

.item-list__row.dragging {
  opacity: .4;
}
.item-list__row.drag-over {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge--private  { background: #fee2e2; color: #b91c1c; }
.badge--closed   { background: #fef3c7; color: #92400e; }
.badge--hidden       { background: #f3f4f6; color: #6b7280; }
.badge--constrained  { background: #ede9fe; color: #5b21b6; }
.badge--replied      { background: #dcfce7; color: #166534; }

/* ── Topic body ───────────────────────────────────────────── */
.topic-body {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  line-height: 1.7;
}

/* ── Replies ──────────────────────────────────────────────── */
.replies { margin-bottom: 2rem; }

.replies h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 1rem;
}

.reply {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
}

.reply--hidden {
  opacity: .6;
  border-style: dashed;
}

.reply__header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .625rem;
  flex-wrap: wrap;
}

.reply__header strong { font-size: .9375rem; }

.reply__header time {
  font-size: .8rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.reply__body { font-size: .9375rem; line-height: 1.65; }

/* Annidamento risposte */
.reply__children {
  margin-top: .75rem;
  margin-left: 1.25rem;
  padding-left: 1rem;
  border-left: 2px solid var(--color-border);
}

/* ── Topic number ─────────────────────────────────────────── */
.topic-number {
  display: inline-block;
  font-weight: 700;
  color: var(--color-primary);
  margin-right: .25rem;
}

/* ── Reply-to indicator ───────────────────────────────────── */
.reply-to-indicator {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: .75rem;
}

.reply-form__notice {
  font-size: .875rem;
  color: var(--color-text-muted);
  margin-bottom: .75rem;
}

/* ── Reply form ───────────────────────────────────────────── */
.reply-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.reply-form h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .875rem;
}

/* ── Forms ────────────────────────────────────────────────── */
.form { max-width: 640px; }

.form__field {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  margin-bottom: 1.125rem;
}

.form__field label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

.form__field small {
  font-size: .8rem;
  color: var(--color-text-muted);
}

.form__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form__actions a {
  font-size: .875rem;
  color: var(--color-text-muted);
}

.form-input,
.form-textarea,
select,
input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: .9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,71,187,.12);
}

.form-textarea { resize: vertical; min-height: 100px; }

/* ── Table (membri) ───────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th {
  background: var(--color-primary);
  color: #fff;
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .75rem 1rem;
  text-align: left;
}

.table td {
  padding: .75rem 1rem;
  font-size: .9rem;
  border-bottom: 1px solid var(--color-border);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; }

/* ── Error messages ───────────────────────────────────────── */
.error {
  color: var(--color-danger);
  font-size: .8125rem;
  margin-top: .25rem;
}

/* ── Import results ───────────────────────────────────────── */
.import-results {
  margin-top: 2rem;
}
.import-results h3 {
  margin-bottom: .75rem;
}
.import-errors {
  list-style: disc;
  padding-left: 1.5rem;
  color: var(--color-danger);
  font-size: .875rem;
}
.import-errors li {
  margin-bottom: .25rem;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.login-card__header {
  background: var(--color-primary);
  border-bottom: 4px solid var(--color-accent);
  padding: 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.login-card__logo { height: 52px; width: auto; }

.login-card__title {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.login-card__subtitle {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
}

.login-card__body {
  padding: 2rem;
}

.login-card__body .form__field { margin-bottom: 1rem; }

.login-card__body .btn {
  width: 100%;
  justify-content: center;
  padding: .75rem;
  font-size: 1rem;
  margin-top: .5rem;
}

.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: rgba(255,255,255,.6);
  font-size: .8rem;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header__title { font-size: .95rem; }
  .main-content { padding: 1.25rem 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .reply__header time { margin-left: 0; width: 100%; }
}

/* ── CKEditor content rendering ───────────────────────────── */
.ck-content h2 { font-size: 1.375rem; font-weight: 700; margin: 1.25rem 0 .5rem; }
.ck-content h3 { font-size: 1.125rem; font-weight: 600; margin: 1rem 0 .375rem; }
.ck-content p  { margin: .625rem 0; line-height: 1.7; }
.ck-content ul,
.ck-content ol { margin: .625rem 0 .625rem 1.5rem; }
.ck-content li { margin: .25rem 0; line-height: 1.65; }
.ck-content a  { color: var(--color-primary); text-decoration: underline; }
.ck-content blockquote {
  border-left: 4px solid var(--color-accent);
  margin: 1rem 0;
  padding: .5rem 1rem;
  color: var(--color-text-muted);
  background: #fafafa;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.ck-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .875rem;
  line-height: 1.6;
}
.ck-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.ck-content figure { margin: 1rem 0; }
.ck-content figcaption {
  font-size: .8125rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: .375rem;
}
.ck-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.ck-content th,
.ck-content td {
  border: 1px solid var(--color-border);
  padding: .5rem .75rem;
  font-size: .9rem;
}
.ck-content th { background: var(--color-primary); color: #fff; }

/* ── Video embed (YouTube / Vimeo) ────────────────────────── */
.video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  margin: 1rem 0;
}
.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ── Barra impersonate (solo superuser) ───────────────────── */
.impersonate-bar {
  background: #1a1f2e;
  color: rgba(255,255,255,.85);
  font-size: .8125rem;
}

/* Mentre si naviga come un altro utente la barra deve saltare all'occhio */
.impersonate-bar--active {
  background: var(--color-danger);
  color: #fff;
}

.impersonate-bar__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: .375rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
}

.impersonate-bar__form {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
}

.impersonate-bar__form input {
  padding: .25rem .5rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  width: 14rem;
  max-width: 50vw;
}

.impersonate-bar__error {
  color: var(--color-accent);
  font-weight: 600;
}
