/* Bookmind — dark theme, no framework */

:root {
  --bg: #14161c;
  --bg-elevated: #1c1f27;
  --bg-elevated-2: #242833;
  --border: #2e3340;
  --text: #e7e9ee;
  --text-dim: #9aa1b1;
  --text-faint: #666d80;
  --accent: #7c9eff;
  --accent-dim: #4a5f99;
  --accent-text: #0d0f14;
  --success: #57c785;
  --danger: #e5697b;
  --danger-dim: #4a2830;
  --warn: #e5b567;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .brand {
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}
.env-badge {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.env-badge--development { color: var(--warn); background: rgba(229, 181, 103, 0.22); border-color: rgba(229, 181, 103, 0.5); }
.env-badge--production { color: var(--success); background: rgba(87, 199, 133, 0.22); border-color: rgba(87, 199, 133, 0.5); }
.site-header nav {
  display: flex;
  gap: 18px;
  flex: 1;
}
.site-header nav a {
  color: var(--text-dim);
  font-size: 0.92rem;
}
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #2b303c; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: #91acff; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-dim); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.link-button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}
.link-button:hover { color: var(--text); text-decoration: underline; }

/* Forms */
form { display: flex; flex-direction: column; gap: 10px; }
label { font-size: 0.85rem; color: var(--text-dim); margin-bottom: -4px; }
input[type="text"], input[type="password"], input[type="search"],
input[type="file"], textarea, select {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-title { text-align: center; margin: 0 0 20px; font-size: 1.3rem; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; margin: 0 0 14px; }
.flash-error { background: var(--danger-dim); color: #ffc1cb; border: 1px solid var(--danger); }
.flash-success { background: #1d3b2c; color: #b7f0cc; border: 1px solid var(--success); }

/* Page heading row */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.35rem; }

/* Tabs */
.status-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.status-tabs a {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-elevated-2);
  color: var(--text-dim);
  font-size: 0.87rem;
  border: 1px solid var(--border);
}
.status-tabs a:hover { text-decoration: none; color: var(--text); }
.status-tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.search-form { display: flex; gap: 8px; margin-bottom: 20px; }
.search-form input { flex: 1; }

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}
.book-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.12s ease;
}
.book-card:hover { border-color: var(--accent-dim); }
.book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-elevated-2);
  display: block;
}
.book-cover-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-elevated-2), #1a1d26);
  color: var(--text-faint);
  font-size: 1.8rem;
  font-weight: 700;
}
.book-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.book-card-title { font-weight: 600; font-size: 0.92rem; color: var(--text); line-height: 1.3; }
.book-card-title a { color: inherit; }
.book-card-title a:hover { text-decoration: none; color: var(--accent); }
.book-card-author { color: var(--text-dim); font-size: 0.82rem; }
.book-card-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-badge-to_read { background: #2c2f3d; color: var(--text-dim); }
.status-badge-reading { background: #3a3116; color: var(--warn); }
.status-badge-read { background: #16332a; color: var(--success); }
.status-badge-abandoned { background: #3a1f24; color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

/* Book detail */
.book-detail { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.book-detail-cover { width: 220px; flex-shrink: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.book-detail-cover img, .book-detail-cover .book-cover-placeholder { width: 100%; aspect-ratio: 2/3; }
.book-detail-info { flex: 1; min-width: 260px; }
.book-detail-info h1 { margin: 0 0 2px; font-size: 1.5rem; }
.book-detail-author { color: var(--text-dim); margin-bottom: 14px; }
.thoughts-box { white-space: pre-wrap; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-top: 6px; }
.detail-section { margin-top: 20px; }
.detail-section h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin: 0 0 8px; }

.status-history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.status-history li { font-size: 0.85rem; color: var(--text-dim); }
.status-history time { color: var(--text-faint); font-size: 0.78rem; margin-left: 6px; }

/* Rating widget: row of 1-10 buttons */
.rating-widget { display: flex; gap: 4px; flex-wrap: wrap; }
.rating-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rating-btn:hover { border-color: var(--accent); color: var(--text); }
.rating-btn.filled { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.rating-value { color: var(--text-dim); font-size: 0.85rem; margin-left: 4px; }

/* Status action buttons on card/detail */
.status-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-actions button {
  padding: 5px 11px;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text-dim);
  cursor: pointer;
}
.status-actions button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.status-actions button:hover:not(.active) { color: var(--text); }

/* Recommendations */
.rec-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.htmx-indicator { display: none; color: var(--text-dim); font-size: 0.88rem; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; align-items: center; gap: 6px; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.rec-grid { display: flex; flex-direction: column; gap: 12px; }
.rec-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.rec-card.added { opacity: 0.6; }
.rec-score {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}
.rec-body { flex: 1; }
.rec-title { font-weight: 600; font-size: 1rem; margin: 0 0 2px; }
.rec-author { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 8px; }
.rec-reasoning { color: var(--text-dim); font-size: 0.88rem; margin: 0; }
.rec-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 640px) {
  .site-header { flex-wrap: wrap; gap: 10px; }
  .site-header nav { order: 3; width: 100%; gap: 14px; }
  .book-detail { flex-direction: column; }
  .book-detail-cover { width: 160px; }
}
