/* ============================================================
   Biblio — main.css
   Thème éditorial sombre/lumineux (sans Bootstrap)
   ============================================================ */

/* --- Variables de thème --- */
:root[data-theme="dark"] {
  --bg: #13100a;
  --surface: #131313;
  --text: #f0ebe0;
  --text-muted: #666666;
  --border: #1e1e1e;
  --border-muted: #2a2a2a;
  --accent: #c4a35a;
  --accent-hover: color-mix(in oklch, var(--accent), white 15%);
  --badge-avail: #c4a35a;
  --badge-unavail: #555555;
  --btn-border: #2a2a2a;
  --overlay-nav: rgba(255,255,255,0.08);
}

:root[data-theme="light"] {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #1a1208;
  --text-muted: #9a8f82;
  --border: #e8e2d6;
  --border-muted: #ece6da;
  --accent: #8b5e3c;
  --accent-hover: color-mix(in oklch, var(--accent), black 12%);
  --badge-avail: #7a5c2a;
  --badge-unavail: #9a8f82;
  --btn-border: #d8d0c4;
  --overlay-nav: rgba(0,0,0,0.04);
}

/* --- Reset minimal --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'IM Fell English', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

/* =====================
   NAVBAR
   ===================== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  transition: background 0.2s, border-color 0.2s;
}

.navbar-brand { flex-shrink: 0; }
.navbar-brand a { text-decoration: none; }
.brand-sub {
  font-size: 8px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}
.brand-name {
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1.3;
}

.navbar-links {
  display: flex;
  gap: 20px;
}
.navbar-links a {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.15s;
}
.navbar-links a:hover,
.navbar-links a.active { color: var(--text); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.navbar-username {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-theme {
  background: none;
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  line-height: 1;
}
.btn-theme:hover { border-color: var(--accent); color: var(--accent); }

.btn-nav {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-muted);
  padding: 4px 10px;
  background: none;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-nav:hover { border-color: var(--accent); color: var(--accent); }

/* Offset du contenu sous la navbar fixe */
.page-content { padding-top: 52px; }

/* =====================
   PAGE D'ACCUEIL — HERO
   ===================== */
body.page-home { overflow: hidden; }

body.page-home .navbar {
  background: transparent;
  border-bottom-color: rgba(255,255,255,0.1);
}
body.page-home .brand-sub,
body.page-home .navbar-links a,
body.page-home .navbar-username { color: rgba(255,255,255,0.5); }
body.page-home .brand-name { color: #f0ebe0; }
body.page-home .btn-nav { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.5); }
body.page-home .btn-theme { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.4); }

.hero-wrap {
  position: relative;
  min-height: 72dvh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background: url('/static/img/biblio_bg.jpg') center/cover no-repeat;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.68);
}
.hero-content {
  position: relative;
  z-index: 1;
  text-align: left;
  padding: 80px 10% 80px 8%;
  max-width: 520px;
}
.hero-content h1 {
  font-family: Georgia, serif;
  font-size: clamp(26px, 5vw, 46px);
  font-style: normal;
  color: #f0ebe0;
  line-height: 1.25;
  margin-bottom: 12px;
}
.hero-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 32px;
  line-height: 1.6;
}

/* Bouton accent */
.btn-accent {
  display: inline-block;
  background: var(--accent, #c4a35a);
  color: #0f0f0f;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: bold;
  padding: 10px 24px;
  border: none;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  transition: opacity 0.15s;
}
.btn-accent:hover { opacity: 0.85; color: #0f0f0f; }

/* =====================
   LISTE DES LIVRES
   ===================== */
.list-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}
.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.list-header h1 {
  font-family: Georgia, serif;
  font-size: 20px;
  font-style: normal;
}
.link-muted {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-muted);
  padding: 4px 10px;
  transition: border-color 0.15s, color 0.15s;
}
.link-muted:hover { border-color: var(--accent); color: var(--accent); }

/* Filtres */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.filters input[type="text"],
.filters select {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  outline: none;
  font-family: system-ui, sans-serif;
  transition: border-color 0.15s;
}
.filters input[type="text"]::placeholder { color: var(--text-muted); }
.filters input[type="text"]:focus,
.filters select:focus { border-color: var(--accent); }
.filters select { cursor: pointer; }
.filter-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.filter-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.btn-search {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: bold;
  padding: 6px 16px;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  transition: opacity 0.15s;
  margin-left: auto;
}
.btn-search:hover { opacity: 0.85; }

/* Table livres */
.book-table {
  width: 100%;
  border-collapse: collapse;
}
.book-table thead tr {
  border-bottom: 1px solid var(--border);
}
.book-table th {
  font-size: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: normal;
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}
.book-table th a { color: var(--text-muted); }
.book-table th a:hover,
.book-table th.sort-active a { color: var(--accent); }

.book-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.book-table tbody tr:hover { background: var(--surface); }
.book-table td {
  padding: 8px;
  vertical-align: middle;
  font-size: 13px;
}

/* Couverture */
td.col-cover { width: 56px; padding: 6px 8px; }
.book-cover {
  width: 40px;
  height: 58px;
  object-fit: cover;
  border-radius: 2px;
}
.cover-fallback {
  width: 40px;
  height: 58px;
  border-radius: 2px;
  box-shadow: 2px 3px 6px rgba(0,0,0,0.3);
}
.cover-fallback[data-genre="roman"]    { background: #5a3a2a; }
.cover-fallback[data-genre="essai"]    { background: #2a4a5a; }
.cover-fallback[data-genre="poesie"]   { background: #4a3a5a; }
.cover-fallback[data-genre="theatre"]  { background: #5a4a2a; }
.cover-fallback[data-genre="bd"]       { background: #2a5a3a; }
.cover-fallback[data-genre="sciences"] { background: #2a3a5a; }
.cover-fallback[data-genre="autre"]    { background: #3a3a3a; }

/* Titre / auteur */
.book-title {
  font-family: Georgia, serif;
  font-size: 13px;
  color: var(--text);
  display: block;
  line-height: 1.3;
}
.book-author {
  font-size: 11px;
  color: var(--text-muted);
  font-style: normal;
}

/* Badges */
.badge {
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  white-space: nowrap;
  border: 1px solid;
}
.badge-avail { color: var(--badge-avail); border-color: var(--badge-avail); }
.badge-unavail { color: var(--badge-unavail); border-color: var(--badge-unavail); }

/* Boutons action */
.btn-borrow {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
  transition: opacity 0.15s;
  display: inline-block;
}
.btn-borrow:hover { opacity: 0.85; }
.btn-return {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  background: none;
  color: var(--accent);
  border: 1px solid var(--accent);
  cursor: pointer;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-return:hover { background: var(--accent); color: #0f0f0f; }
.btn-disabled {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  color: var(--badge-unavail);
  border: 1px solid var(--btn-border);
  opacity: 0.5;
  cursor: not-allowed;
  background: none;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 28px 0;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { border-color: var(--accent); color: var(--accent); }
.pagination .disabled { opacity: 0.3; cursor: default; }

/* =====================
   MES EMPRUNTS
   ===================== */
.loans-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}
.loans-page h1 {
  font-family: Georgia, serif;
  font-size: 20px;
  font-style: normal;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.loan-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.loan-info { flex: 1; min-width: 0; }
.loan-title {
  font-family: Georgia, serif;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loan-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.badge-overdue {
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  color: #c44a3a;
  border: 1px solid #c44a3a;
  white-space: nowrap;
}
.badge-returned {
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  color: var(--badge-unavail);
  border: 1px solid var(--btn-border);
  white-space: nowrap;
}
.loans-empty {
  padding: 48px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-style: normal;
  font-family: Georgia, serif;
}

/* =====================
   FORMULAIRES
   ===================== */
.form-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 32px 24px;
}
.form-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 36px 40px;
}
.form-card h1 {
  font-family: Georgia, serif;
  font-size: 19px;
  font-style: normal;
  margin-bottom: 28px;
  color: var(--text);
}
.form-field { margin-bottom: 22px; }
.form-field label {
  display: block;
  font-size: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.form-field input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text);
  font-size: 14px;
  padding: 6px 0;
  outline: none;
  font-family: Georgia, serif;
  transition: border-color 0.15s;
}
.form-field input:focus { border-bottom-color: var(--accent); }
.form-field input:user-invalid { border-bottom-color: #c44a3a; }
.form-field input:user-valid:not(:placeholder-shown) { border-bottom-color: var(--accent); }
.form-error {
  font-size: 11px;
  color: #c44a3a;
  margin-bottom: 16px;
  padding: 8px 10px;
  border: 1px solid rgba(196,74,58,0.3);
  background: rgba(196,74,58,0.06);
}
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  flex-wrap: wrap;
  gap: 8px;
}
.form-link {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.form-link:hover { color: var(--accent); }

/* Confirmation inscription */
.register-done-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-top: 8px;
  font-family: Georgia, serif;
  font-style: normal;
}

/* =====================
   RESPONSIVE TABLE
   ===================== */
.book-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
  /* Masquer Genre (col 4) et Année (col 5) sur mobile */
  .book-table th:nth-child(4),
  .book-table td:nth-child(4),
  .book-table th:nth-child(5),
  .book-table td:nth-child(5) {
    display: none;
  }
}
