@import url("https://fonts.googleapis.com/css2?family=Newsreader:wght@400;600&family=Space+Grotesk:wght@400;600&display=swap");

@font-face {
  font-family: "Neocat";
  src: url("/fonts/Neocat-Regular_3.0.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

/* Versione in basso a destra nella pagina di login */
.login-version {
  text-align: right;
  color: #000;
  font-size: 0.88em;
  font-weight: bold;
  margin-top: 12px;
}

/* Fascia rossa versione nelle pagine principali */
.version-banner {
  background-color: #c0392b;
  color: #fff;
  font-weight: bold;
  font-size: 0.9em;
  text-align: right;
  padding: 6px 16px;
  margin-bottom: 16px;
  border-radius: 6px;
}

:root {
  --bg: #f4f1e7;
  --panel: #fff7ee;
  --ink: #2a241f;
  --muted: #6b625a;
  --accent: #c45a2a;
  --accent-dark: #8f3f1d;
  --line: rgba(42, 36, 31, 0.2);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: url("/public/icona.jpg") no-repeat center center fixed, radial-gradient(circle at top left, #fbe7d3, transparent 55%), radial-gradient(circle at bottom right, #f2c4b5, transparent 45%), var(--bg);
  background-size: cover;
  min-height: 100vh;
}

h1 {
  font-family: "Neocat", "Newsreader", "Times New Roman", serif;
  margin: 0;
}

h2 {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-weight: bold;
  margin: 0;
  color: #1f5db6;
}

.cnc-title {
  color: #1f5db6;
}

.page {
  max-width: 1720px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-badge {
  display: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f0d6c8;
  font-weight: 600;
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#status {
  max-width: 50vw;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
}

.view-switch {
  display: flex;
  gap: 12px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}

.view-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.view-switch label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.menu button.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 12px;
  align-items: center;
}

.filters label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

select,
input {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  font-size: 0.95rem;
}

textarea {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  font-size: 0.95rem;
  width: 100%;
  resize: vertical;
}

#diocesiSelect,
#parrocchiaSelect {
  width: 33ch;
  max-width: 100%;
}

input[readonly] {
  background: #f8f1e9;
  color: var(--muted);
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.password-toggle {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.content {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(520px, 2.4fr);
  gap: 20px;
}

.content--single {
  grid-template-columns: 1fr;
}

.sections {
  display: grid;
  gap: 20px;
}

.section-panel {
  display: none;
}

.section-panel.active {
  display: grid;
}

.list {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 420px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.selezione-output-title {
  color: #1f5db6;
}

.list-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0d6c8;
  font-weight: 600;
}

.list-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.list-grid {
  display: grid;
  grid-template-columns: 55px 1.5fr 105px 1.4fr;
  gap: 6px;
  align-items: center;
}

.list-grid--comunita {
  grid-template-columns: 45px 2.2fr 1.4fr 105px 1.3fr 0.9fr;
}

.list-grid--diocesi {
  grid-template-columns: 2fr 1.5fr 110px 1.5fr;
}

.list-grid--parrocchie {
  grid-template-columns: 1.3fr 1.8fr 1.3fr 100px 1.4fr;
}

.list-grid--tappe {
  grid-template-columns: 90px minmax(220px, 1.8fr);
  min-width: 380px;
}

.list-grid--passaggi {
  grid-template-columns: minmax(150px, 1.1fr) minmax(170px, 1.2fr) minmax(
      170px,
      1.2fr
    ) minmax(48px, 0.8fr) 190px minmax(160px, 1fr) 130px minmax(200px, 1.2fr)
    minmax(180px, 1.1fr);
  min-width: 1300px;
}

.list-grid--catechesi {
  grid-template-columns: minmax(180px, 1.3fr) minmax(180px, 1.2fr) 130px 130px
    minmax(160px, 1fr) 130px minmax(200px, 1.2fr) minmax(160px, 1fr) 140px;
  min-width: 1200px;
}

.list-grid--selezione-output {
  grid-template-columns: 45px 2.2fr 1.4fr 105px 1.3fr;
}

.list-grid--missione {
  grid-template-columns: calc(70px + 8ch) 45px 1.4fr 0.9fr 1.2fr 1.2fr 1.6fr;
  min-width: 900px;
}

.list-grid--accessi {
  grid-template-columns: 200px 160px 1fr;
}

.list-grid--log {
  grid-template-columns: calc(135px + 10ch) calc(78px + 10ch) 50px calc(80px + 10ch) calc(35px + 10ch) 1fr 1fr 1fr;
  gap: 4px;
  font-size: 0.75rem;
  min-width: calc(700px + 40ch);
}

.list-grid--log span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Override the general .list-item .list-grid span rule for log entries */
.log-entry .list-grid--log span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-entry__row2 {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 3px 4px 1px 4px;
  border-top: 1px dashed var(--line);
  margin-top: 3px;
  white-space: normal;
  word-break: break-word;
}

/* Sigla operazione colorata */
.log-op {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  border-radius: 4px;
  padding: 1px 5px;
  text-align: center;
  display: inline-block;
}
.log-op--ins  { background: #d4edda; color: #155724; }
.log-op--upd  { background: #fff3cd; color: #856404; }
.log-op--del  { background: #f8d7da; color: #721c24; }
.log-op--del-all { background: #f8d7da; color: #721c24; }

.list-grid--head {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 8px 5px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 4px;
}

.list-grid--head span[data-sort] {
  cursor: pointer;
  text-decoration: underline dotted;
}

.list-item {
  text-align: left;
  border: 1px solid transparent;
  background: #fff;
  padding: 3px 6px;
  border-radius: 8px;
  flex: 1;
  min-width: 0;
}

.list-item-wrapper {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 2px;
}

.list-item .list-grid {
  font-size: 0.8rem;
}

/* Campo Tipo Fratello: mostra sempre tutto il testo, con wrapping e tooltip */
.list-item .list-grid span {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}

/* Solo la prima colonna (Tipo) della lista missione: larghezza minima e wrapping */
.list-grid--missione span:first-child {
  min-width: calc(70px + 8ch);
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}
}

.list-item.active {
  border-color: var(--accent);
  background: #fef1e8;
}

.login-error {
  margin: 12px 0 0;
  color: #9b2c2c;
  font-weight: 600;
  min-height: 1.2em;
}

.empty {
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.details {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.45);
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 20px 20px 24px;
  width: min(980px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions--end {
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-text {
  margin: 0 0 16px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.checks {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: #fbf2ea;
  border: 1px dashed var(--line);
}

.checks-4 {
  grid-template-columns: repeat(4, 1fr);
}

.checks label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.selezione-panel {
  display: grid;
  gap: 18px;
}

.selezione-grid {
  align-items: end;
}

.selezione-output {
  min-height: auto;
}

.selezione-active-filters {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}



@media (max-width: 900px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .content {
    grid-template-columns: 1fr;
  }
}

/* Login Page Styles */
.login-page {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(244, 241, 231, 0.72), rgba(244, 241, 231, 0.72)),
    url("Icona.jpg") center center / cover no-repeat;
  z-index: 2000;
}

.login-page.is-visible {
  display: flex;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px;
  width: min(480px, 90vw);
  box-shadow: var(--shadow);
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: #004aad;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 24px;
  text-align: center;
  color: #004aad;
}

.login-card form {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.login-card input {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  font-size: 0.95rem;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

.login-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.login-links button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
  padding: 10px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

.login-links button:hover {
  background: var(--panel);
}
