/* Together We Read - Modern Book Club Site */
/* Mobile-first responsive design */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

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

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

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

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

.search-container {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.875rem;
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 150;
}

.search-results.open {
  display: block;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result.selected {
  background: var(--bg);
}

.search-result.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.search-result-cover {
  width: 32px;
  height: 48px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.search-result-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

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

.search-result-author {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-result-tab {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--border);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.book-card.highlighted {
  animation: highlight-pulse 2s ease-out;
}

@keyframes highlight-pulse {
  0% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.5); }
  100% { box-shadow: var(--shadow); }
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.user-name {
  color: var(--primary);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.user-name:hover {
  background: var(--bg);
  text-decoration: underline;
}

/* Navigation Tabs */
.tabs {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  min-width: 80px;
  padding: 0.625rem 0.5rem;
  text-align: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  background: var(--bg);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab .count {
  display: inline-block;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
  margin-left: 0.25rem;
}

.tab.active .count {
  background: var(--primary);
  color: white;
}

/* Main Content */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Proposed Two-Column Layout */
.proposed-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .proposed-columns {
    grid-template-columns: 1fr 1fr;
  }
}

#tab-proposed .book-grid {
  display: block;
}

.proposed-column {
  min-width: 0;
}

.column-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.column-count {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--border);
  color: var(--text-muted);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.column-books {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Book Cards */
.book-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .book-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.book-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.book-card:hover {
  box-shadow: var(--shadow-lg);
}

.book-card-inner {
  display: flex;
  padding: 0.75rem;
  gap: 0.75rem;
}

.book-cover {
  width: 60px;
  height: 90px;
  flex-shrink: 0;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
}

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

.book-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.book-author {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  font-size: 0.7rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
}

.badge-fiction {
  background: #dbeafe;
  color: #1e40af;
}

.badge-nonfiction {
  background: #fef3c7;
  color: #92400e;
}

.badge-date {
  background: var(--border);
  color: var(--text-muted);
}

.badge-location {
  background: #dcfce7;
  color: #166534;
}

.badge-creator {
  background: #f3e8ff;
  color: #6b21a8;
}

.book-location {
  margin-top: 0.375rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 500;
}

/* Rating */
.rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stars {
  display: flex;
  gap: 2px;
}

.star {
  color: #fbbf24;
  font-size: 0.875rem;
}

.star.empty {
  color: var(--border);
}

.rating-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

/* Vote Buttons */
.vote-section {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vote-buttons {
  display: flex;
  gap: 0.375rem;
}

.vote-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.vote-btn:hover {
  background: var(--bg);
}

.vote-btn.voted-yes {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.vote-btn.voted-no {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.vote-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Comments Section */
.comments-section {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

.comments-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.comments-toggle:hover {
  color: var(--text);
}

.comments-list {
  margin-top: 0.5rem;
  display: none;
}

.comments-list.open {
  display: block;
}

.comment {
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  margin-bottom: 0.375rem;
  position: relative;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.comment-rating {
  margin-left: auto;
}

.comment-delete {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
  padding: 0.125rem 0.25rem;
}

.comment:hover .comment-delete {
  opacity: 1;
}

.comment-delete:hover {
  color: var(--danger);
}

.comment-author {
  font-weight: 600;
  font-size: 0.75rem;
}

.comment-rating {
  font-size: 0.7rem;
}

.comment-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.comment-text a {
  color: var(--primary);
}

/* Add Comment Form */
.add-comment {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.add-comment textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.add-comment-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.375rem;
  gap: 0.375rem;
}

.star-input {
  display: flex;
  gap: 2px;
}

.star-input button {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--border);
  transition: color 0.1s;
}

.star-input button.filled {
  color: #fbbf24;
}

.star-input button:hover {
  color: #fbbf24;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  z-index: 50;
}

.fab:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--bg-card);
  cursor: pointer;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
}

.toast {
  background: var(--text);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state-text {
  font-size: 1rem;
}

/* Loading Spinner */
.loading {
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Book Actions Menu */
.book-actions {
  position: relative;
}

.book-actions-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
}

.book-actions-btn:hover {
  color: var(--text);
}

.book-actions-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  display: none;
  z-index: 10;
}

.book-actions-menu.open {
  display: block;
}

.book-actions-menu button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: none;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
}

.book-actions-menu button:hover {
  background: var(--bg);
}

.book-actions-menu button.danger {
  color: var(--danger);
}

/* Responsive adjustments */
@media (max-width: 639px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .book-card-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .book-cover {
    width: 100px;
    height: 150px;
  }

  .book-meta {
    justify-content: center;
  }
}

/* Nickname prompt */
.nickname-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 1rem;
}

.nickname-card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.nickname-card h2 {
  margin-bottom: 1rem;
}

.nickname-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.nickname-card input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  text-align: center;
  margin-bottom: 1rem;
}

.nickname-card button {
  width: 100%;
}
