:root {
  --bg: #f4f4f4;
  --text: #232222;
  --bloc-bg: #fff;
  --cell-bg: #cdcbcb;
  --cell-hover-bg: #232222;
  --cell-hover-text: #fff;
  --border-light: #eee;
  --input-bg: #fff;
  --table-header-bg: #fafafa;
  --label: #555;
  --bloc-title: #a11726;
  --btn-submit-bg: #cc2131;
  --btn-submit-hover: #a11726;
  --erreur-bg: #fdecea;
  --erreur-border: #cc2131;
  --erreur-text: #a11726;
}
.dark {
  --bg: #16162b;
  --text: #d0d0e0;
  --bloc-bg: #252545;
  --cell-bg: #2d2d5e;
  --cell-hover-bg: #3d3d7e;
  --cell-hover-text: #fff;
  --border-light: #3a3a6e;
  --input-bg: #1e1e3a;
  --table-header-bg: #2a2a50;
  --label: #a0a0b8;
  --bloc-title: #cc7a84;
  --btn-submit-bg: #a11726;
  --btn-submit-hover: #cc2131;
  --erreur-bg: #3a1a1e;
  --erreur-border: #cc2131;
  --erreur-text: #e88;
}

body {
  margin: 0;
  padding: 1px;
  font-family: 'Inter', sans-serif;
  position: relative;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

.bloc, .tuile, input, select, th, td {
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("images/back.svg");
  background-size: cover;
  opacity: 0.4;
  z-index: -1;
}

.entete {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 5px 24px;
  background: linear-gradient(90deg, #16213e 0%, #1a3a5c 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 2;
}

.entete img {
  height: 46px;
  width: 46px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.entete h1 {
  margin: 0;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.entete .trait {
  width: 4px;
  height: 32px;
  background: #fff;
  opacity: 0.5;
  border-radius: 2px;
  flex-shrink: 0;
}

.entete .soustitre {
  color: #c0c8d0;
  font-size: 0.8em;
  margin-top: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.entete .signature {
  position: absolute;
  right: 10px;
  font-family: 'Caveat', cursive;
  font-size: 1em;
  color: #c0c8d0;
  user-select: none;
  text-decoration: none;
  cursor: pointer;
}

@media (max-width: 640px) {
  .entete { gap: 8px; padding: 5px 10px; }
  .entete img { height: 32px; width: 32px; }
  .entete h1 { font-size: 1.1em; }
  .entete .trait { height: 24px; }
  .entete .soustitre { font-size: 0.65em; }
  .entete-actions { gap: 6px; margin-right: 40px; }
  .action-icone { width: 30px; height: 30px; }
  .action-icone svg { width: 16px; height: 16px; }
  .recherche-header input:focus { width: 140px; }
}

.grille {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(var(--nb), var(--cell-width));
  grid-auto-rows: var(--cell-height);
}

.cellule {
  width: var(--cell-width);
  height: var(--cell-height);
  box-sizing: border-box;
  padding: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tuile {
  box-sizing: border-box;
  border-radius: 10%;
  background-color: var(--cell-bg);
  font-size: 0.9em;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tuile:hover {
  background-color: var(--cell-hover-bg);
  color: var(--cell-hover-text);
  transform: scale(1.08);
  z-index: 1;
  position: relative;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}
.dark .tuile:hover {
  box-shadow: 0 8px 25px rgba(0,0,0,0.6);
}
.tuile:active {
  transform: scale(0.95);
  transition-duration: 0.05s;
}

.cat-autre {
  border: 4px solid #2565dd;
}
.cat-oney {
  border: 4px solid #8cbe01;
}
.cat-sav {
  border: 4px solid #ffff00;
}
.cat-accueil {
  border: 4px solid #cc2131;
}
.cat-autre2 {
  border: 4px solid #656363;
}

.tuile-img {
  flex: 0 0 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding:2px 1px 0px 1px;box-sizing: border-box;
}

.tuile-texte {
  flex: 0 0 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 2px 1px;
  box-sizing: border-box;
}

.tuile-texte span {
  display: block;
  width: 100%;
  line-height: 1.2;
  word-break: break-word;
}

img{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.entete-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  margin-right: 50px;
}

.action-icone {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  transition: background 0.2s ease;
  border: none;
  cursor: pointer;
  padding: 0;
}
.action-icone:hover {
  background: rgba(255,255,255,0.35);
}

.action-icone svg {
  width: 19px;
  height: 19px;
}
.icone-soleil { display: none; }
.dark .icone-soleil { display: block; }
.dark .icone-lune { display: none; }

.contenu {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.bloc {
  background: var(--bloc-bg);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  padding: 18px 22px;
  margin-bottom: 24px;
}

.bloc h2 {
  margin-top: 0;
  font-size: 1.1em;
  color: var(--bloc-title);
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 8px;
}

.message {
  background: #e6f4ea;
  border: 1px solid #8cbe01;
  color: #2d5016;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.erreur {
  background: #fdecea;
  border: 1px solid #cc2131;
  color: #a11726;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.erreur form {
  margin-top: 8px;
}

form.formulaire-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

input[type="file"] {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 8px 10px;
  background: var(--input-bg);
  color: var(--text);
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  font-size: 0.9em;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}

.btn-principal {
  background: #cc2131;
  color: #fff;
}
.btn-principal:hover { background: #a11726; }

.btn-secondaire {
  background: #e0e0e0;
  color: #232222;
}
.btn-secondaire:hover { background: #cacaca; }
.dark .btn-secondaire {
  background: #3a3a6e;
  color: #d0d0e0;
}
.dark .btn-secondaire:hover { background: #4a4a7e; }

.grille-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.carte-image {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background: var(--bloc-bg);
}

.carte-image img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  margin-bottom: 8px;
}

.carte-image .nom-fichier {
  font-size: 0.78em;
  word-break: break-all;
  color: #555;
  margin-bottom: 4px;
}

.carte-image .utilisation {
  font-size: 0.72em;
  color: #999;
  margin-bottom: 8px;
}

.carte-image .utilisation.utilisee {
  color: #a11726;
  font-weight: 600;
}

.carte-image form {
  margin: 0;
}

small.aide {
  display: block;
  color: var(--label);
  margin-top: 8px;
  font-size: 0.82em;
}

form.formulaire {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}

form.formulaire .champ-full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.85em;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--label);
}

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.95em;
  background: var(--input-bg);
  color: var(--text);
}

.actions-form {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  background: var(--bloc-bg);
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

th {
  background: var(--table-header-bg);
  font-size: 0.85em;
  text-transform: uppercase;
  color: #777;
}

td.lien-cellule a {
  color: inherit;
  text-decoration: none;
}
td.lien-cellule a:visited {
  color: inherit;
}
.lien-cellule {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miniature {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.78em;
  font-weight: 600;
  color: #fff;
}
.badge-accueil { background: #cc2131; }
.badge-oney { background: #8cbe01; }
.badge-sav { background: #b8b800; }
.badge-autre { background: #2565dd; }
.badge-autre2 { background: #656363; }

.col-actions {
  white-space: nowrap;
}

.col-actions form {
  display: inline;
}

.table-wrap {
  overflow-x: auto;
}

.recherche-admin {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.95em;
  margin-bottom: 12px;
  background: var(--input-bg);
  color: var(--text);
}

@media (max-width: 640px) {
  .grille-images {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }
}

.modal-confirm {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-confirm.visible {
  display: flex;
}
.modal-confirm .boite {
  background: var(--bloc-bg);
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.modal-confirm .boite p {
  margin: 0 0 20px;
  font-size: 1em;
  color: var(--text);
}
.modal-confirm .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-confirm .actions button {
  min-width: 90px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
}
