/* ════════════════════════════════════════════════════════════════
   Ma Collection BD — Styles
   ════════════════════════════════════════════════════════════════ */
:root {
  --blue:        #1a3a5c;
  --blue-light:  #2c5680;
  --gold:        #d4a017;
  --gold-soft:   #fff3d1;
  --red:         #c0392b;
  --green:       #27ae60;
  --bg:          #f0ece6;
  --surface:     #ffffff;
  --border:      #ddd6cc;
  --text:        #2d2d2d;
  --muted:       #6b6560;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow-sm:   0 2px 6px rgba(0,0,0,0.08);
  --shadow:      0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.18);
  --safe-bot:    env(safe-area-inset-bottom, 0);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

/* ═══ LANDING SCREEN ════════════════════════════════════════════ */
#landing {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--blue) 0%, #0d2236 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: landingIn 0.4s ease-out;
}
#landing.fade-out { animation: landingOut 0.5s ease-in forwards; }
@keyframes landingIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes landingOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

.landing-inner { text-align: center; color: #fff; padding: 2rem; }
.landing-logo {
  width: 140px;
  height: 140px;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.4));
  animation: logoFloat 1.8s ease-out;
}
@keyframes logoFloat {
  0%   { transform: translateY(-20px) scale(0.9); opacity: 0; }
  60%  { transform: translateY(0) scale(1.03); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.landing-title { font-size: 2rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 0.4rem; }
.landing-sub   { font-size: 0.95rem; opacity: 0.75; font-weight: 400; }

/* ═══ HEADER ════════════════════════════════════════════════════ */
#header {
  background: var(--blue);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
  padding-top: env(safe-area-inset-top, 0);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-home {
  background: none;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.header-home:hover { background: rgba(255,255,255,0.1); }
.header-logo { width: 28px; height: 28px; }
#page-title { flex: 1; font-size: 1rem; font-weight: 600; text-align: center; }
.btn-install {
  background: var(--gold);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

/* ═══ MAIN ══════════════════════════════════════════════════════ */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(2rem + var(--safe-bot));
}

/* ═══ DASHBOARD TILES ═══════════════════════════════════════════ */
.dashboard-greeting {
  margin-bottom: 1.25rem;
  padding: 0 0.2rem;
}
.dashboard-greeting h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.2rem; }
.dashboard-greeting p { color: var(--muted); font-size: 0.9rem; }

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 2rem;
}
@media (min-width: 640px) { .tiles-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .tiles-grid { grid-template-columns: repeat(4, 1fr); } }

.tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 0.9rem;
  cursor: pointer;
  text-align: left;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 130px;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile:active { transform: translateY(-1px); }
.tile.disabled { opacity: 0.55; cursor: not-allowed; }
.tile.disabled:hover { transform: none; box-shadow: var(--shadow-sm); }

.tile-icon {
  font-size: 2rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-soft);
}
.tile-icon.blue   { background: #dde7f1; }
.tile-icon.red    { background: #fadbd8; }
.tile-icon.green  { background: #d5f0dc; }
.tile-icon.purple { background: #e8dcf0; }
.tile-icon.gray   { background: #e8e4de; }

.tile-title { font-size: 0.95rem; font-weight: 700; line-height: 1.25; }
.tile-sub   { font-size: 0.78rem; color: var(--muted); margin-top: auto; }

.tile-badge {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  background: var(--blue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  min-width: 1.5rem;
  text-align: center;
}
.tile-badge.coming { background: var(--muted); }

/* Section "Ma collection" sur le dashboard */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding: 0 0.2rem;
}
.section-header h3 { font-size: 1.15rem; font-weight: 700; }
.section-header a {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.section-header a:hover { text-decoration: underline; }

/* ═══ TOOLBAR ═══════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input[type="search"],
.toolbar input[type="text"],
.toolbar select {
  flex: 1;
  min-width: 180px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--surface);
}

/* ═══ BUTTONS ═══════════════════════════════════════════════════ */
.btn {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-gold    { background: var(--gold); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-amazon  { background: #FF9900; color: #131921; }
.btn-sm      { padding: 0.32rem 0.7rem; font-size: 0.8rem; }
.btn-lg      { padding: 0.75rem 1.4rem; font-size: 1rem; }
.btn-block   { width: 100%; justify-content: center; }

/* ═══ BOOKS GRID ════════════════════════════════════════════════ */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 1rem;
}
@media (min-width: 640px) { .books-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }

.book-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: linear-gradient(135deg, #e8e4de, #d8d2c8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2.5rem;
  position: relative;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.book-fav-marker {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  font-size: 1.2rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.book-status-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-info {
  padding: 0.55rem 0.6rem 0.65rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.book-series { font-size: 0.7rem; color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.book-title  { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.book-meta   { font-size: 0.72rem; color: var(--muted); margin-top: auto; padding-top: 0.2rem; }

/* ═══ BD DETAIL PAGE ════════════════════════════════════════════ */
.bd-detail {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.bd-detail-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
}
@media (min-width: 640px) {
  .bd-detail-hero { grid-template-columns: 200px 1fr; padding: 1.75rem; gap: 1.75rem; }
}
.bd-detail-cover {
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: linear-gradient(135deg, #e8e4de, #d8d2c8);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 3.5rem;
}
.bd-detail-cover img { width: 100%; height: 100%; object-fit: cover; }

.bd-detail-info { display: flex; flex-direction: column; gap: 0.85rem; }
.bd-detail-series {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bd-detail-title { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.bd-detail-volume {
  display: inline-block;
  background: var(--gold-soft);
  color: #7a5800;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  width: fit-content;
}

.bd-meta-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.bd-meta-list li {
  display: flex;
  gap: 0.6rem;
  font-size: 0.92rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.bd-meta-list li:last-child { border-bottom: none; }
.bd-meta-label { color: var(--muted); font-weight: 600; min-width: 100px; }
.bd-meta-value { color: var(--text); }

.bd-notes {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
@media (min-width: 640px) { .bd-notes { padding: 0 1.75rem 1.75rem; } }

.bd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
@media (min-width: 640px) { .bd-actions { padding: 1.25rem 1.75rem; } }

/* ═══ SERIES LIST ═══════════════════════════════════════════════ */
.series-list { display: flex; flex-direction: column; gap: 0.6rem; }
.series-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.series-name { font-weight: 700; font-size: 1rem; flex: 1; min-width: 150px; }
.series-stats { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.progress-wrap { flex: 2; min-width: 120px; }
.progress-bar  { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.3s; }
.series-actions { display: flex; gap: 0.4rem; }

/* ═══ MISSING LIST ══════════════════════════════════════════════ */
.missing-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
}
.missing-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}
.missing-header h3 { font-size: 1rem; }
.badge {
  background: var(--gold);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
}
.missing-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  color: #7a5800;
  font-size: 0.82rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-weight: 600;
}

/* ═══ EMPTY STATES ══════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty .empty-icon { font-size: 3.5rem; margin-bottom: 0.6rem; opacity: 0.7; }
.empty p { font-size: 0.95rem; margin-bottom: 1rem; }

.loading { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.95rem; }

/* ═══ MODAL ═════════════════════════════════════════════════════ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
#modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
#modal-title { font-size: 1.1rem; font-weight: 700; }
#modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
#modal-close:hover { background: var(--bg); }
#modal-body { padding: 1.25rem; }

/* ═══ FORMS ═════════════════════════════════════════════════════ */
.form-grid { display: flex; flex-direction: column; gap: 0.85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}
textarea { resize: vertical; min-height: 75px; }

.form-radio-group {
  display: flex;
  gap: 0.5rem;
  background: var(--bg);
  padding: 0.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.form-radio-group label {
  flex: 1;
  margin: 0;
  padding: 0.5rem 0.75rem;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  transition: all 0.15s;
}
.form-radio-group input[type="radio"] { display: none; }
.form-radio-group input[type="radio"]:checked + span { /* placeholder */ }
.form-radio-group label.checked {
  background: var(--blue);
  color: #fff;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.error-msg { color: var(--red); font-size: 0.85rem; margin-top: 0.25rem; min-height: 1.2em; }

/* ═══ HORIZONTAL SCROLL (collection preview) ════════════════════ */
.horizontal-scroll {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.horizontal-scroll .book-card {
  flex: 0 0 130px;
  scroll-snap-align: start;
}
.horizontal-scroll::-webkit-scrollbar { height: 4px; }
.horizontal-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ═══ RESPONSIVE TWEAKS ═════════════════════════════════════════ */
@media (max-width: 380px) {
  .tile { min-height: 110px; padding: 0.9rem 0.7rem; }
  .tile-icon { width: 40px; height: 40px; font-size: 1.6rem; }
  .tile-title { font-size: 0.88rem; }
}
