@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@400;600;700&display=swap');

:root {
  --c1: #FF6B6B;
  --c2: #FF9A3C;
  --c3: #FFD93D;
  --c4: #6BCB77;
  --c5: #4D96FF;
  --c6: #C77DFF;
  --rainbow: linear-gradient(135deg, #FF6B6B, #FF9A3C, #FFD93D, #6BCB77, #4D96FF, #C77DFF);
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: #f8f7ff;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: linear-gradient(270deg, #FF6B6B, #FF9A3C, #FFD93D, #6BCB77, #4D96FF, #C77DFF, #FF6B6B);
  background-size: 300% 300%;
  animation: rainbowShift 10s ease infinite;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  color: white;
}

@keyframes rainbowShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

header h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  letter-spacing: 1px;
}

header p.tagline {
  margin-top: 0.25rem;
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 600;
}

nav {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  background: rgba(255,255,255,0.25);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
}

nav a:hover { background: rgba(255,255,255,0.45); }

/* ── Flash messages ── */
.flash-container {
  max-width: 900px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
  width: 100%;
}

.flash {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.flash-success { background: #d4edda; color: #155724; border-left: 4px solid #6BCB77; }
.flash-error   { background: #f8d7da; color: #721c24; border-left: 4px solid #FF6B6B; }

/* ── Main container ── */
main { flex: 1; padding: 1.5rem; }

.container {
  max-width: 960px;
  margin: 0 auto;
}

/* ── Section headings ── */
.section-heading {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Current book card ── */
.current-book-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2.5rem;
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.current-book-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--rainbow);
}

.book-cover-wrap {
  flex-shrink: 0;
}

.book-cover {
  width: 160px;
  height: 240px;
  object-fit: cover;
  border-radius: 4px 8px 8px 4px;
  box-shadow:
    -3px 0 8px rgba(0,0,0,0.12),
    5px 8px 20px rgba(0,0,0,0.25),
    inset -2px 0 5px rgba(0,0,0,0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: block;
}

.book-cover:hover {
  transform: translateY(-4px) rotate(1deg);
  box-shadow: -3px 0 8px rgba(0,0,0,0.12), 8px 14px 28px rgba(0,0,0,0.3);
}

.no-cover-placeholder {
  width: 160px;
  height: 240px;
  border-radius: 4px 8px 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-size: 3.5rem;
  box-shadow: 5px 8px 20px rgba(0,0,0,0.25);
  gap: 0.3rem;
}

.no-cover-placeholder span {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.85rem;
  opacity: 0.8;
  text-align: center;
  padding: 0 0.5rem;
}

.book-info { flex: 1; }

.book-title {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  color: #222;
  margin-bottom: 0.3rem;
}

.book-author {
  font-size: 1.05rem;
  color: #666;
  margin-bottom: 1rem;
  font-weight: 600;
}

.book-description {
  color: #555;
  line-height: 1.6;
  margin-bottom: 1.2rem;
  font-size: 0.97rem;
}

.picked-by {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.next-picker-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--rainbow);
  background-size: 200% 200%;
  animation: rainbowShift 6s ease infinite;
  color: white;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.no-book-message {
  text-align: center;
  padding: 3rem 2rem;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
}

.no-book-message .big-emoji { font-size: 4rem; display: block; margin-bottom: 1rem; }

.no-book-message h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.6rem;
  color: #555;
}

/* ── Past books ── */
.past-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.past-book-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.past-book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.14);
}

.past-book-card:nth-child(6n+1) .card-accent { background: var(--c1); }
.past-book-card:nth-child(6n+2) .card-accent { background: var(--c2); }
.past-book-card:nth-child(6n+3) .card-accent { background: var(--c3); }
.past-book-card:nth-child(6n+4) .card-accent { background: var(--c4); }
.past-book-card:nth-child(6n+5) .card-accent { background: var(--c5); }
.past-book-card:nth-child(6n+0) .card-accent { background: var(--c6); }

.card-accent { height: 6px; flex-shrink: 0; }

.past-book-inner {
  padding: 1.1rem;
  display: flex;
  gap: 1rem;
  flex: 1;
}

.past-cover {
  width: 64px;
  height: 96px;
  object-fit: cover;
  border-radius: 3px 5px 5px 3px;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.past-no-cover {
  width: 64px;
  height: 96px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px 5px 5px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}

.past-book-details { flex: 1; min-width: 0; }

.past-book-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.past-book-author {
  font-size: 0.85rem;
  color: #777;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.past-book-meta {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 0.4rem;
}

.past-book-notes {
  font-size: 0.82rem;
  color: #666;
  font-style: italic;
  line-height: 1.4;
  margin-top: 0.4rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.4rem;
}

/* ── Admin ── */
.admin-grid {
  display: grid;
  gap: 1.5rem;
}

.admin-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-card-header {
  padding: 1rem 1.5rem;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
}

.admin-card-header.red    { background: var(--c1); }
.admin-card-header.orange { background: var(--c2); }
.admin-card-header.yellow { background: var(--c3); color: #333; }
.admin-card-header.green  { background: var(--c4); }
.admin-card-header.blue   { background: var(--c5); }
.admin-card-header.purple { background: var(--c6); }

.admin-card-body { padding: 1.5rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: #444;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  background: #fafafa;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--c5);
  background: white;
}

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

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 999px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--c5); color: white; }
.btn-success  { background: var(--c4); color: white; }
.btn-danger   { background: var(--c1); color: white; }
.btn-warning  { background: var(--c2); color: white; }
.btn-purple   { background: var(--c6); color: white; }
.btn-rainbow  { background: var(--rainbow); background-size: 200%; color: white; animation: rainbowShift 6s ease infinite; }

.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }

/* ── Book search ── */
.search-wrapper { position: relative; }

#search-results {
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  margin-top: 0.5rem;
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.search-result {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f5f5f5;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: #f8f7ff; }

.result-cover-img {
  width: 44px;
  height: 64px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.15);
}

.result-no-cover {
  width: 44px;
  height: 64px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.result-info strong {
  display: block;
  font-size: 0.95rem;
  color: #222;
  line-height: 1.3;
}

.result-info span {
  font-size: 0.82rem;
  color: #777;
  font-weight: 600;
}

.result-info small {
  display: block;
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 0.15rem;
}

.no-results { padding: 1rem; text-align: center; color: #aaa; font-size: 0.9rem; }
.searching  { padding: 1rem; text-align: center; color: #aaa; font-size: 0.9rem; }

/* ── Book preview ── */
.book-preview {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  background: #f8f7ff;
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 2px solid #e8e8e8;
}

.preview-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 3px 5px 12px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.preview-no-cover {
  width: 80px;
  height: 120px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px 6px 6px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.preview-info strong {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.preview-info em {
  color: #777;
  font-size: 0.9rem;
}

.preview-picker {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #555;
}

/* ── Rotation list ── */
.rotation-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.rotation-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rotation-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.rotation-item:nth-child(1) .rotation-badge { background: var(--c1); }
.rotation-item:nth-child(2) .rotation-badge { background: var(--c2); }
.rotation-item:nth-child(3) .rotation-badge { background: var(--c4); }
.rotation-item:nth-child(4) .rotation-badge { background: var(--c5); }
.rotation-item:nth-child(5) .rotation-badge { background: var(--c6); }

.rotation-item input[type="text"] {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.next-tag {
  font-size: 0.72rem;
  background: var(--c3);
  color: #333;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
}

/* ── Login page ── */
.login-container {
  min-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card .big-emoji { font-size: 3rem; margin-bottom: 0.5rem; display: block; }

.login-card h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  color: #333;
}

/* ── Meeting banner ── */
.meeting-banner {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-left: 4px solid var(--c3);
}

.countdown-pill {
  background: var(--c3);
  color: #333;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ── Past books admin table ── */
.past-books-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.past-books-table th {
  text-align: left;
  padding: 0.7rem 1.2rem;
  background: #f8f7ff;
  color: #888;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #eee;
}

.past-books-table td {
  padding: 0.65rem 1.2rem;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
}

.past-books-table tr:last-child td { border-bottom: none; }
.past-books-table tr:hover td { background: #fafafa; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.5rem;
  color: #aaa;
  font-size: 0.85rem;
  border-top: 1px solid #eee;
}

/* ── Inline row helpers ── */
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .form-group { flex: 1; min-width: 140px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .current-book-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .next-picker-badge { justify-content: center; }

  .past-books-grid {
    grid-template-columns: 1fr;
  }
}
