/* Administration Le Semeur — même palette que le site public. */

:root {
  --gold: #c79533;
  --brown: #371409;
  --amber: #a66311;
  --ink: #160201;
  --cream: #ebeae5;
  --line: rgba(55, 20, 9, 0.14);
  --line-strong: rgba(55, 20, 9, 0.3);
  --muted: rgba(22, 2, 1, 0.62);
  --radius: 4px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

img {
  display: block;
  max-width: 100%;
}

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

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--brown);
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
}

/* ------------------------------------------------------------- connexion */

.login-page {
  display: grid;
  min-height: 100svh;
  place-items: center;
  background: var(--brown);
  padding: 1.5rem;
}

.login-card {
  display: grid;
  gap: 1rem;
  width: min(23rem, 100%);
  border-radius: var(--radius);
  background: var(--cream);
  padding: 2.5rem 2rem;
  box-shadow: 0 30px 80px rgba(22, 2, 1, 0.45);
  text-align: center;
}

.login-card img {
  width: 64px;
  margin: 0 auto;
}

.login-card h1 {
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
}

.muted-link {
  color: var(--muted);
  font-size: 0.813rem;
}

/* ----------------------------------------------------------- formulaires */

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.6);
  padding: 0.55rem 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(199, 149, 51, 0.22);
  outline: none;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  padding: 0 1rem;
  font-size: 0.813rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--brown);
  color: var(--cream);
}

.btn.primary:hover {
  background: var(--ink);
}

.btn.gold {
  background: var(--gold);
  color: var(--ink);
}

.btn.ghost {
  border-color: var(--line-strong);
  color: var(--brown);
}

.btn.ghost:hover {
  background: var(--brown);
  color: var(--cream);
}

.btn.danger {
  border-color: rgba(166, 99, 17, 0.5);
  color: var(--amber);
}

.btn.danger:hover {
  background: var(--amber);
  color: var(--cream);
}

.btn.small {
  min-height: 34px;
  padding: 0 0.7rem;
  font-size: 0.75rem;
}

.icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

/* ------------------------------------------------------------ structure */

.admin-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  padding: 0.75rem 1.25rem;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 700;
}

.admin-brand img {
  width: 38px;
}

.admin-brand small {
  display: block;
  color: var(--muted);
  font-size: 0.688rem;
  font-weight: 600;
}

.admin-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-top-actions form {
  margin: 0;
}

.menu-btn {
  display: none;
}

.admin-body {
  display: grid;
  grid-template-columns: 15rem 1fr;
  align-items: start;
  min-height: calc(100svh - 62px);
}

.admin-nav {
  position: sticky;
  top: 62px;
  display: grid;
  gap: 0.15rem;
  align-content: start;
  border-right: 1px solid var(--line);
  padding: 1rem 0.75rem;
  max-height: calc(100svh - 62px);
  overflow-y: auto;
}

.admin-nav button {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  padding: 0.65rem 0.7rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.admin-nav button:hover {
  background: rgba(199, 149, 51, 0.16);
}

.admin-nav button.active {
  background: var(--brown);
  color: var(--cream);
}

.admin-nav .ico {
  color: var(--gold);
  text-align: center;
}

.admin-nav .count {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.admin-nav button.active .count {
  color: rgba(235, 234, 229, 0.7);
}

.admin-main {
  padding: clamp(1.25rem, 3vw, 2.25rem);
  max-width: 78rem;
}

.loading {
  color: var(--muted);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: clamp(1.4rem, 2.6vw, 2rem);
}

.page-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 46rem;
}

.hint {
  border-left: 3px solid var(--gold);
  background: rgba(199, 149, 51, 0.12);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.alert {
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
}

.alert.error {
  background: rgba(166, 99, 17, 0.15);
  color: var(--amber);
}

/* ------------------------------------------------------------- autres */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.metric-card,
.other-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.58);
}

.metric-card {
  display: grid;
  gap: 0.3rem;
  padding: 0.95rem 1rem;
}

.metric-label {
  color: var(--amber);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.metric-value {
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  line-height: 1;
}

.metric-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.other-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.other-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.other-panel h2 {
  font-size: 1rem;
}

.rank-list {
  display: grid;
  gap: 0.45rem;
}

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.55rem;
}

.rank-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.rank-row span {
  color: var(--brown);
  font-size: 0.875rem;
  font-weight: 600;
}

.rank-row strong {
  color: var(--amber);
  font-size: 0.875rem;
}

.toggle-grid {
  display: grid;
  gap: 0.65rem;
}

.toggle-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.46);
  padding: 0.85rem;
}

.toggle-item strong {
  display: block;
  font-size: 0.875rem;
}

.toggle-item small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.other-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.other-actions {
  gap: 0.6rem;
}

/* ---------------------------------------------------------------- listes */

.item-list {
  display: grid;
  gap: 0.6rem;
}

.item {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.55);
  padding: 0.75rem;
}

.item.sermon-item {
  grid-template-columns: minmax(7.5rem, 9rem) 1fr auto;
}

.item:hover {
  border-color: var(--gold);
}

.item-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: var(--brown);
}

.item-thumb.wide {
  aspect-ratio: 16 / 9;
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item h3 {
  font-size: 1rem;
}

.item .meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.688rem;
  font-weight: 700;
}

.badge.on {
  background: rgba(199, 149, 51, 0.25);
  color: var(--amber);
}

.badge.off {
  background: rgba(22, 2, 1, 0.1);
  color: var(--muted);
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 2.5rem 1rem;
  text-align: center;
}

/* --------------------------------------------------------- grilles média */

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.slot {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.55);
  overflow: hidden;
}

.slot .preview {
  aspect-ratio: 4 / 3;
  background: var(--brown);
  display: grid;
  place-items: center;
  color: rgba(235, 234, 229, 0.6);
  font-size: 0.75rem;
}

.slot .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-body {
  display: grid;
  gap: 0.5rem;
  padding: 0.8rem;
}

.slot-body strong {
  font-size: 0.875rem;
}

/* --------------------------------------------------------------- modales */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(22, 2, 1, 0.72);
  padding: clamp(0.5rem, 2vw, 1.5rem);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease;
}

.modal {
  position: relative;
  display: flex;
  width: min(46rem, 100%);
  max-height: 92svh;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: 0 30px 90px rgba(22, 2, 1, 0.5);
  animation: rise 0.25s ease;
}

.modal.wide {
  width: min(64rem, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 1.35rem;
}

.modal-head h2 {
  font-size: 1.1rem;
}

.modal-content {
  overflow-y: auto;
  padding: 1.35rem;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.35rem;
}

.modal-foot .left {
  margin-right: auto;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field > label,
.field-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.field small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.lang-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.lang-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  font-size: 0.813rem;
  font-weight: 700;
  color: var(--muted);
}

.lang-tabs button.active {
  border-bottom-color: var(--gold);
  color: var(--brown);
}

.lang-pane[hidden] {
  display: none;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ---------------------------------------------------- sélecteur d'image */

.image-field {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.85rem;
  align-items: start;
}

.image-field .preview {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--brown);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgba(235, 234, 229, 0.6);
  font-size: 0.688rem;
}

.image-field .preview.wide {
  aspect-ratio: 16 / 9;
}

.image-field .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.url-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.url-tools input {
  flex: 1 1 16rem;
  min-width: 0;
}

.url-tools .btn {
  flex: 0 0 auto;
}

.picker-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.picker-tabs button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.picker-tabs button.active {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--cream);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.6rem;
}

.media-grid button {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(55, 20, 9, 0.08);
  cursor: pointer;
  padding: 0;
}

.media-grid button:hover {
  border-color: var(--gold);
}

.media-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-grid .label {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(22, 2, 1, 0.72);
  color: var(--cream);
  padding: 0.25rem 0.35rem;
  font-size: 0.625rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.813rem;
}

.breadcrumb button {
  border: 0;
  background: none;
  color: var(--amber);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
}

.folder-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.folder-list button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.6);
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  font-size: 0.813rem;
  font-weight: 600;
  text-align: left;
}

.folder-list button:hover {
  border-color: var(--gold);
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 0.5rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone.over {
  border-color: var(--gold);
  background: rgba(199, 149, 51, 0.12);
}

/* ---------------------------------------------------------------- textes */

.text-group {
  margin-bottom: 2rem;
}

.text-group h2 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
}

.text-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(235, 234, 229, 0.5);
  padding: 0.85rem;
  margin-bottom: 0.6rem;
}

.text-row .key {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.688rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.text-row label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.688rem;
  font-weight: 700;
  color: var(--amber);
}

.sticky-save {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  background: var(--cream);
  padding: 0.85rem 0;
  margin-top: 1rem;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 200;
  border-radius: 999px;
  background: var(--brown);
  color: var(--cream);
  padding: 0.7rem 1.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  transform: translateX(-50%);
  box-shadow: 0 16px 40px rgba(22, 2, 1, 0.35);
  animation: rise 0.25s ease;
}

.toast.error {
  background: var(--amber);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .menu-btn {
    display: grid;
  }

  .admin-body {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: fixed;
    top: 62px;
    bottom: 0;
    left: 0;
    z-index: 45;
    width: 15rem;
    border-right: 1px solid var(--line);
    background: var(--cream);
    box-shadow: 0 20px 60px rgba(22, 2, 1, 0.25);
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    max-height: none;
  }

  .admin-nav.open {
    transform: none;
  }

  .row,
  .text-row {
    grid-template-columns: 1fr;
  }

  .item {
    grid-template-columns: 4rem 1fr;
  }

  .item.sermon-item {
    grid-template-columns: minmax(5.5rem, 7rem) 1fr;
  }

  .item-actions {
    grid-column: 1 / -1;
  }

  .admin-top-actions .btn {
    padding: 0 0.6rem;
    font-size: 0.75rem;
  }

  .stats-grid,
  .other-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .image-field {
    grid-template-columns: 1fr;
  }

  .url-tools .btn {
    width: 100%;
  }

  .modal-foot {
    justify-content: stretch;
  }

  .modal-foot .btn {
    flex: 1;
  }

  .stats-grid,
  .other-grid {
    grid-template-columns: 1fr;
  }
}
