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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #1a1a1a;
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Nav */
header {
  background: #111;
  color: #fff;
  padding: 0 1.5rem;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.nav-brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.nav-links a {
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.nav-links a:hover {
  color: #fff;
}

.nav-button {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 0.9rem;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}

.nav-button:hover {
  color: #fff;
}

/* Main content */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

main h1 {
  font-size: 1.75rem;
  margin-bottom: 1.25rem;
}

main h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
}

/* Messages */
.messages {
  max-width: 900px;
  width: 100%;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.message-debug    { background: #f0f0f0; border-color: #ccc; color: #333; }
.message-info     { background: #e8f4fd; border-color: #90caf9; color: #1565c0; }
.message-success  { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.message-warning  { background: #fff8e1; border-color: #ffe082; color: #f57f17; }
.message-error    { background: #fdecea; border-color: #ef9a9a; color: #b71c1c; }

/* Footer */
footer {
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: #666;
}

footer a {
  color: #333;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Forms */
form p {
  margin-bottom: 0.75rem;
}

form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #333;
}

button[type="submit"],
a.button {
  display: inline-block;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.55rem 1.25rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  margin-top: 0.5rem;
}

button[type="submit"]:hover,
a.button:hover {
  background: #333;
}

/* Entity detail */
.entity-header {
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: flex-start;
}

.entity-cover {
  width: 200px;
  height: auto;
  border-radius: 4px;
  flex-shrink: 0;
}

.entity-cover--placeholder {
  width: 200px;
  height: 200px;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  color: #666;
  font-size: 0.85rem;
}

.entity-info {
  flex: 1;
}

.entity-badges,
.entity-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.badge {
  display: inline-block;
  background: #e8e8e8;
  color: #333;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.badge--genre {
  background: #e3f0ff;
  color: #1a4f8a;
}

.badge--source {
  background: #fff8e1;
  color: #7a5c00;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  margin-top: 0.75rem;
}

.detail-list dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: #555;
}

.detail-list dd {
  font-size: 0.9rem;
}

.user-item-section {
  border-top: 1px solid #e0e0e0;
  margin-top: 2rem;
  padding-top: 1.5rem;
}

.user-item-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.button--small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.button--danger {
  background: #c62828;
}

.button--danger:hover {
  background: #b71c1c;
}

.button--secondary {
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
}

.button--secondary:hover {
  background: #f5f5f5;
}

@media (max-width: 600px) {
  .entity-header {
    flex-direction: column;
  }

  .entity-cover,
  .entity-cover--placeholder {
    width: 100%;
    height: auto;
    max-width: 200px;
  }
}

/* Collection / browse */
.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-bar select,
.filter-bar input[type="text"] {
  max-width: 180px;
}

.collection-table {
  width: 100%;
  border-collapse: collapse;
}

.collection-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  border-bottom: 2px solid #e0e0e0;
  padding: 0.4rem 0.5rem;
}

.collection-table td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.collection-table tr:hover td {
  background: #fafafa;
}

.collection-table a {
  color: #1a1a1a;
  text-decoration: none;
}

.collection-table a:hover {
  font-weight: 600;
}

.col-cover {
  width: 40px;
}

.table-cover {
  width: 36px;
  height: 36px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
}

.table-cover--placeholder {
  background: #e0e0e0;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
}

.empty-state p {
  margin-bottom: 1rem;
}

/* Manual add form */
.form-group {
  margin-bottom: 1.25rem;
}

.field-optional {
  font-weight: 400;
  font-size: 0.85rem;
  color: #888;
}

.field-errors {
  list-style: none;
  margin-top: 0.25rem;
}

.field-error {
  color: #b71c1c;
  font-size: 0.875rem;
}

.field-help {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Search / add-item page */
.search-form {
  margin-bottom: 1.5rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field--grow {
  flex: 1;
  min-width: 200px;
}

.form-actions {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline;
}

/* Search result cards */
.result-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.result-card:hover {
  background: #fafafa;
}

.result-cover img,
.result-cover--placeholder {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.result-cover--placeholder {
  background: #e0e0e0;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-title a {
  color: #1a1a1a;
  text-decoration: none;
}

.result-title a:hover {
  text-decoration: underline;
}

.result-creators {
  color: #666;
  font-size: 0.875rem;
}

.result-detail {
  color: #888;
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.result-meta {
  display: flex;
  gap: 0.4rem;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
