/* ============================================================
   Bibliothèque Paroissiale — Feuille de styles
   Esthétique : manuscrit enluminé × interface moderne
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Lora:ital,wght@0,400;0,500;1,400&family=Source+Code+Pro:wght@400&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --parchment:    #F0F7F2;
  --parchment-dk: #E2EFE7;
  --cream:        #F8FEFA;
  --wine:         #1B5E37;
  --wine-hover:   #236B42;
  --wine-light:   #E8F5ED;
  --gold:         #C09A2F;
  --gold-light:   #D4AE4A;
  --gold-pale:    #FBF6E4;
  --text:         #102918;
  --text-muted:   #4A6B55;
  --text-light:   #7A9B85;
  --border:       #B8D4C2;
  --border-light: #D4EAD8;
  --surface:      #F5FAF7;
  --success:      #2D6B3A;
  --success-bg:   #EDF7EE;
  --danger:       #8B2222;
  --danger-bg:    #FAEAEA;
  --warning:      #8B5E00;
  --warning-bg:   #FFF6E0;
  --shadow-sm:    0 1px 4px rgba(42,24,16,.08);
  --shadow:       0 3px 12px rgba(42,24,16,.12);
  --shadow-lg:    0 8px 32px rgba(42,24,16,.18);
  --radius:       10px;
  --radius-lg:    16px;
  --transition:   0.2s ease;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--parchment);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
  background-image:
    radial-gradient(ellipse at top right, rgba(27,94,55,.06) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(192,154,47,.04) 0%, transparent 60%);
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  line-height: 1.3;
}

a { color: var(--wine); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--wine-hover); }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── Scrollbar stylisée ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--parchment-dk); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Navbar ─────────────────────────────────────────────────── */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--wine);
  background-image: linear-gradient(135deg, var(--wine) 0%, #0F3D22 100%);
  box-shadow: 0 2px 12px rgba(27,94,55,.35);
  padding: 0 1.5rem;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--parchment);
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
}

.nav-brand .brand-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
}

.nav-links a, .nav-links button {
  color: rgba(244,237,211,.8);
  font-family: 'Lora', serif;
  font-size: .88rem;
  padding: .4rem .85rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-links a:hover, .nav-links button:hover {
  color: var(--parchment);
  background: rgba(244,237,211,.15);
}

.nav-links a.active {
  color: var(--gold-light);
  background: rgba(192,154,47,.2);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--gold-light);
  font-size: .85rem;
  font-style: italic;
}

.nav-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-style: normal;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  font-size: .9rem;
  color: var(--wine);
}

/* Hamburger mobile */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  padding: .4rem;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 24px; height: 2px;
  background: var(--parchment);
  border-radius: 2px;
  transition: all .3s;
}

/* ── Layout principal ────────────────────────────────────────── */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  min-height: calc(100vh - 62px);
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}

.page-header h1 {
  font-size: 2rem;
  color: var(--wine);
}

.page-header p {
  color: var(--text-muted);
  margin-top: .3rem;
  font-style: italic;
}

/* ── Ornement enluminé ───────────────────────────────────────── */
.ornament {
  text-align: center;
  color: var(--gold);
  font-size: 1.2rem;
  letter-spacing: .5rem;
  margin: .5rem 0;
  user-select: none;
}

/* ── Search + filtres ────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding: .65rem 1rem .65rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  font-family: 'Lora', serif;
  font-size: .95rem;
  color: var(--text);
  transition: border var(--transition), box-shadow var(--transition);
}

.search-input-wrap::before {
  content: '🔍';
  position: absolute;
  left: .75rem;
  top: 50%; transform: translateY(-50%);
  font-size: .85rem;
  opacity: .6;
  pointer-events: none;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(27,94,55,.1);
}

.filter-select {
  padding: .65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  font-family: 'Lora', serif;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  transition: border var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--wine);
}

/* ── Grille de livres ────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: var(--cream);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.book-cover {
  height: 200px;
  background: var(--parchment-dk);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

.book-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  color: var(--text-light);
  font-size: .75rem;
  text-align: center;
  padding: 1rem;
}

.book-cover-placeholder .icon {
  font-size: 3rem;
  opacity: .5;
}

.book-badge {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  font-family: 'Lora', serif;
  letter-spacing: .02em;
}

/* Badge absolu pour les cartes du catalogue (contexte position:relative) */
.book-card .book-badge {
  position: absolute;
  top: .6rem;
  right: .6rem;
}

.coeur-badge {
  position: absolute;
  bottom: .5rem;
  left: .5rem;
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

.badge-Disponible { background: var(--success-bg); color: var(--success); }
.badge-Prêté      { background: var(--danger-bg);  color: var(--danger); }
.badge-Réservé    { background: var(--warning-bg); color: var(--warning); }
.badge-Indisponible { background: #f0f0f0; color: #888; }

.book-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.book-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}

.book-meta {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .2rem;
}

.tag {
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 12px;
  background: var(--gold-pale);
  color: var(--gold);
  border: 1px solid rgba(184,148,58,.2);
  font-family: 'Lora', serif;
}

.book-owner {
  font-size: .78rem;
  color: var(--text-light);
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px dashed var(--border-light);
}

/* ── Détail du livre ─────────────────────────────────────────── */
.book-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.book-detail-cover {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 3/4;
  background: var(--parchment-dk);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-detail-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.book-detail-cover-placeholder {
  font-size: 4rem;
  opacity: .4;
  color: var(--text-muted);
}

.book-detail-content h1 {
  font-size: 1.9rem;
  color: var(--wine);
  margin-bottom: .3rem;
}

.book-detail-content .author {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.25rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1.5rem;
  margin: 1.25rem 0;
  padding: 1.25rem;
  background: var(--parchment);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.detail-item label {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-light);
  font-family: 'Lora', serif;
  margin-bottom: .15rem;
}

.detail-item span {
  font-size: .95rem;
  color: var(--text);
  font-weight: 500;
}

.book-comment {
  background: var(--gold-pale);
  border-left: 3px solid var(--gold);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.book-comment::before {
  content: '✦ Note du propriétaire — ';
  font-style: normal;
  font-size: .8rem;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Formulaires ─────────────────────────────────────────────── */
.form-card {
  background: var(--cream);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 640px;
  box-shadow: var(--shadow-sm);
}

.form-card h2 {
  font-size: 1.6rem;
  color: var(--wine);
  margin-bottom: .25rem;
}

.form-card .subtitle {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.75rem;
  font-size: .9rem;
}

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

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group label .required { color: var(--wine); margin-left: .15rem; }

.form-control {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: 'Lora', serif;
  font-size: .95rem;
  color: var(--text);
  transition: border var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(27,94,55,.1);
}

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control { cursor: pointer; }

/* ── Boutons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  font-family: 'Lora', serif;
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--wine);
  color: var(--parchment);
}
.btn-primary:hover { background: var(--wine-hover); box-shadow: 0 4px 12px rgba(107,26,53,.3); }

.btn-gold {
  background: var(--gold);
  color: white;
}
.btn-gold:hover { background: var(--gold-light); box-shadow: 0 4px 12px rgba(184,148,58,.3); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--wine); color: var(--wine); background: var(--wine-light); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: .85; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { opacity: .85; }

.btn-sm { padding: .4rem .9rem; font-size: .82rem; }
.btn-lg { padding: .9rem 2rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Onglets (Login) ─────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.75rem;
  gap: .1rem;
}

.tab-btn {
  padding: .6rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: 'Lora', serif;
  font-size: .95rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn.active {
  color: var(--wine);
  border-bottom-color: var(--wine);
  font-weight: 500;
}

/* ── Alertes ─────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(45,107,58,.2); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(139,34,34,.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(139,94,0,.2); }
.alert-info    { background: var(--wine-light); color: var(--wine);    border: 1px solid rgba(107,26,53,.15); }

/* ── Cards / Panneaux ────────────────────────────────────────── */
.card {
  background: var(--cream);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--wine);
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border-light);
}

/* ── Table admin ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-light); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

thead {
  background: var(--parchment);
  border-bottom: 2px solid var(--border);
}

th {
  padding: .7rem 1rem;
  text-align: left;
  font-family: 'Lora', serif;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--parchment); }

/* ── Loan items ──────────────────────────────────────────────── */
.loan-item {
  background: var(--cream);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.loan-item .loan-info { flex: 1; min-width: 200px; }
.loan-item .loan-title { font-weight: 600; font-family: 'Playfair Display', serif; }
.loan-item .loan-meta { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }
.loan-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-light);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-family: 'Playfair Display', serif; color: var(--text-muted); margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4rem;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--wine);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

/* ── Divider ornemental ──────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-light);
  font-size: .8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Statut badge inline ─────────────────────────────────────── */
.status-pill {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  font-family: 'Lora', serif;
}

.status-demande    { background: var(--warning-bg); color: var(--warning); }
.status-en_cours   { background: var(--danger-bg);  color: var(--danger); }
.status-rendu      { background: var(--success-bg); color: var(--success); }
.status-refuse     { background: #f0f0f0; color: #888; }
.status-accepte    { background: var(--success-bg); color: var(--success); }

/* ── Admin tabs ──────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-tab-btn {
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: 'Lora', serif;
  font-size: .88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.admin-tab-btn:hover:not(.active) {
  border-color: var(--wine);
  color: var(--wine);
  background: rgba(107,26,53,.06);
}

.admin-tab-btn.active {
  background: var(--wine);
  color: var(--parchment);
  border-color: var(--wine);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .book-detail { grid-template-columns: 1fr; }
  .book-detail-cover { max-width: 240px; aspect-ratio: 3/4; margin: 0 auto; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  #app { padding: 1.25rem 1rem 3rem; }

  .nav-links {
    display: none;
    position: absolute;
    top: 62px;
    left: 0; right: 0;
    background: var(--wine);
    flex-direction: column;
    padding: 1rem;
    gap: .25rem;
    box-shadow: 0 4px 16px rgba(27,94,55,.3);
  }

  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }
  .nav-user { display: none; }

  #navbar { position: relative; }

  .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
  .book-cover { height: 160px; }

  .form-row { grid-template-columns: 1fr; }
  .form-card { padding: 1.25rem; }

  .page-header h1 { font-size: 1.5rem; }
}

/* ── Animation d'entrée de page ──────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-enter {
  animation: fadeIn .25s ease forwards;
}

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--parchment);
  padding: .8rem 1.2rem;
  border-radius: var(--radius);
  font-size: .88rem;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  animation: toastIn .3s ease;
  border-left: 4px solid var(--gold);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger  { border-left-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
