/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0f0f13;
  --surface:   #1a1a23;
  --surface2:  #22222e;
  --border:    #2e2e3e;
  --accent:    #c89b3c;       /* doré hibou */
  --accent2:   #7c6dd8;       /* violet */
  --text:      #e8e6f0;
  --text-muted:#9090a8;
  --danger:    #e05454;
  --success:   #4caf7d;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}

.search-form {
  display: flex;
  flex: 1;
  max-width: 480px;
  gap: .5rem;
}
.search-form input {
  flex: 1;
  padding: .45rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .95rem;
}
.search-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }

header nav {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-size: .9rem;
}
header nav a { color: var(--text-muted); }
header nav a:hover { color: var(--text); text-decoration: none; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary  { background: var(--accent);  color: #111; font-weight: 600; }
.btn-secondary{ background: var(--accent2); color: #fff; }
.btn-ghost    { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger   { background: rgba(224,84,84,.15); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.delete-form  { display: contents; }
.btn.full     { width: 100%; justify-content: center; }
button.btn, button[type="submit"] {
  padding: .45rem .9rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #111;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: .9rem;
}
button[type="submit"]:hover { opacity: .85; }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
  font-size: .92rem;
}
.alert.error   { background: rgba(224,84,84,.15); border: 1px solid var(--danger);  color: #f59a9a; }
.alert.success { background: rgba(76,175,125,.15); border: 1px solid var(--success); color: #89e8b5; }

/* ── Main ──────────────────────────────────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

.result-count {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: .92rem;
}

/* ── Book grid ─────────────────────────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.25rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
  color: var(--text);
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--surface2);
  overflow: hidden;
}
.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-cover {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--surface2), var(--border));
}
.no-cover span {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.no-cover.large span { font-size: 4rem; }

.format-badge {
  position: absolute;
  top: .4rem;
  right: .4rem;
  background: rgba(0,0,0,.65);
  color: var(--accent);
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .4rem;
  border-radius: 4px;
}

.book-info {
  padding: .6rem .75rem;
}
.book-title {
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-author {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty p { margin-bottom: 1rem; font-size: 1.1rem; }

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .4rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.pagination a {
  padding: .4rem .75rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .9rem;
}
.pagination a.active,
.pagination a:hover {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  text-decoration: none;
}

/* ── Book detail ───────────────────────────────────────────────────────── */
.book-detail {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}
.book-detail-cover img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
}
.book-detail-cover .no-cover {
  aspect-ratio: 2/3;
  border-radius: var(--radius);
}

.book-detail-info h1 {
  font-size: 1.6rem;
  margin-bottom: .75rem;
  line-height: 1.2;
}
.meta-line {
  display: flex;
  gap: .6rem;
  font-size: .93rem;
  color: var(--text-muted);
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.meta-line strong {
  color: var(--text);
  min-width: 110px;
  flex-shrink: 0;
}
.description {
  margin-top: 1.25rem;
}
.description h2 {
  font-size: 1rem;
  margin-bottom: .5rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.description p {
  font-size: .93rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.book-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.enrich-msg {
  margin-top: .75rem;
  font-size: .88rem;
  padding: .5rem .85rem;
  border-radius: var(--radius);
}
.enrich-msg.ok  { background: rgba(76,175,125,.12); color: var(--success); }
.enrich-msg.err { background: rgba(224,84,84,.12);  color: var(--danger); }

/* ── Auth page ─────────────────────────────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}
.auth-logo {
  font-size: 2rem;
  text-align: center;
  margin-bottom: .25rem;
}
.auth-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
.auth-box label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .3rem;
  margin-top: .9rem;
}
.auth-box input {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .95rem;
}
.auth-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-box .btn { margin-top: 1.25rem; }

/* ── Import page ───────────────────────────────────────────────────────── */
.import-page h1 { margin-bottom: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* Drop zone */
#drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 3rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(200, 155, 60, .06);
}
.drop-icon  { font-size: 2.5rem; line-height: 1; }
.drop-label { font-size: 1.05rem; font-weight: 600; }
.drop-sub   { font-size: .85rem; color: var(--text-muted); }

/* Queue */
#queue { margin-top: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem .85rem;
  background: var(--surface2);
  border-radius: var(--radius);
  font-size: .88rem;
}
.queue-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-muted);
}
.queue-status          { white-space: nowrap; font-size: .82rem; }
.queue-status.pending  { color: var(--text-muted); }
.queue-status.uploading{ color: var(--accent); }
.queue-status.done     { color: var(--success); }
.queue-status.fail      { color: var(--danger); }
.queue-status.duplicate { color: var(--accent); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header { flex-wrap: wrap; }
  .search-form { order: 3; flex-basis: 100%; max-width: 100%; }
  .book-detail { grid-template-columns: 1fr; }
  .book-detail-cover { max-width: 180px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
