/* Potichat — feuille de style unique */

:root {
  --bg: #f6f3ee;
  --bg-elevated: #ffffff;
  --bg-sunken: #ece7df;
  --border: #ddd5c9;
  --border-strong: #c9bfae;
  --text: #23201c;
  --text-muted: #6f6759;
  --accent: #b4531f;
  --accent-soft: #f6e5d8;
  --accent-text: #ffffff;
  --ok: #2e6b45;
  --ok-soft: #dcefe2;
  --warn: #8a6410;
  --warn-soft: #faeecd;
  --danger: #a32b26;
  --danger-soft: #f8ddd9;
  --shadow: 0 1px 2px rgba(35, 32, 28, 0.06), 0 8px 24px -12px rgba(35, 32, 28, 0.25);
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --bg-elevated: #211f1c;
    --bg-sunken: #2b2825;
    --border: #35312c;
    --border-strong: #4a443c;
    --text: #f0ece5;
    --text-muted: #a49c8f;
    --accent: #e07c3e;
    --accent-soft: #3a2718;
    --accent-text: #171614;
    --ok: #7fce9f;
    --ok-soft: #1e3327;
    --warn: #e2bc61;
    --warn-soft: #372d13;
    --danger: #f08a80;
    --danger-soft: #3b201d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(0, 0, 0, 0.8);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

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

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

.app-loading::after {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 25vh auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Connexion ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.login__logo {
  display: block;
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 0 auto 6px;
}

.login__title {
  margin: 0 0 2px;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.login__sub {
  margin: 0 0 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- En-tête ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header__inner {
  max-width: 1100px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 1.12rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.header__brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.header__spacer {
  flex: 1;
}

.menu {
  position: relative;
}

.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 205px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 30;
}

.menu__user {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.menu__user strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  cursor: pointer;
}

.menu__item:hover {
  background: var(--bg-sunken);
}

/* ---------- Mise en page ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
}

.page__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.page__title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.search {
  flex: 1 1 220px;
  min-width: 0;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.86rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

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

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat__value {
  font-size: 1.3rem;
  font-weight: 650;
  line-height: 1.2;
}

.stat__label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Grille de chats ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-sunken);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  opacity: 0.35;
}

.card__flag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.card__body {
  padding: 10px 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__name {
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.73rem;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  width: fit-content;
}

.badge--disponible {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge--en_cours {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--adopte {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--malade {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Fiche ---------- */

.detail__hero {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}

@media (max-width: 620px) {
  .detail__hero {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.detail__cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}

.detail__name {
  margin: 0 0 8px;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.detail__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 9px;
}

.thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
  background: var(--bg-sunken);
}

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

.thumb--primary {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.thumb__tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.thumb__actions {
  position: absolute;
  inset: auto 6px 6px auto;
  display: flex;
  gap: 5px;
}

.thumb__btn {
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.7rem;
  padding: 4px 7px;
  cursor: pointer;
  backdrop-filter: blur(3px);
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--bg-elevated);
}

.dropzone--over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.info {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.info__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.info__value {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Formulaires ---------- */

.section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px 17px;
  margin-bottom: 14px;
}

.section__title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
}

.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

textarea {
  min-height: 78px;
  resize: vertical;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.hint {
  font-size: 0.79rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  padding: 9px 15px;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn--primary:hover {
  filter: brightness(1.06);
}

.btn--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger-soft);
}

.btn--ghost {
  background: none;
  border-color: transparent;
}

.btn--block {
  width: 100%;
}

.btn--icon {
  padding: 9px 11px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions--end {
  justify-content: flex-end;
}

/* ---------- Divers ---------- */

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty__emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 8px;
}

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.table th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.table tr:last-child td {
  border-bottom: 0;
}

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

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  width: min(420px, calc(100vw - 28px));
}

.toast {
  background: #23201c;
  color: #f6f3ee;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: rise 0.18s ease;
}

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

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 13, 11, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  width: min(440px, 100%);
  max-height: 88dvh;
  overflow: auto;
}

.modal h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.92);
  display: grid;
  place-items: center;
  z-index: 70;
  padding: 20px;
}

.lightbox img {
  max-width: 100%;
  max-height: 92dvh;
  border-radius: 8px;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 25;
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 13px 19px;
}

@media (min-width: 700px) {
  .fab {
    display: none;
  }
}

.desktop-only {
  display: none;
}

@media (min-width: 700px) {
  .desktop-only {
    display: inline-flex;
  }
}
