/* 鲁社长的读书会 - 主题样式 */
:root {
  --color-bg: #f5f0e8;
  --color-bg-alt: #ebe3d5;
  --color-surface: #ffffff;
  --color-primary: #8b4513;
  --color-primary-dark: #6b3410;
  --color-primary-light: #c4956a;
  --color-text: #2c1810;
  --color-text-secondary: #7a6a5c;
  --color-border: #d4c5b0;
  --color-accent: #c0392b;
  --color-success: #27ae60;
  --font-heading: 'Georgia', 'Noto Serif SC', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ==================== Header ==================== */
.site-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
}

.site-header .logo svg { width: 28px; height: 28px; }

.site-header .nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header .nav-links a,
.site-header .nav-links button {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.site-header .nav-links a:hover,
.site-header .nav-links button:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* ==================== Login Page ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-card .form-group {
  margin-bottom: 20px;
  text-align: left;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
  background: var(--color-bg);
  color: var(--color-text);
}

.login-card input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  width: 100%;
  padding: 12px;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

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

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.login-card .error-msg {
  color: var(--color-accent);
  font-size: 0.85rem;
  margin-top: 12px;
  display: none;
}

/* ==================== Bookshelf ==================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.page-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.auto-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 20px;
  background: #e8f5e9;
  color: #2e7d32;
  margin-left: 8px;
  vertical-align: middle;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.book-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: 1px solid var(--color-border);
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.book-card .cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 3rem;
}

.book-card .cover-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 3rem;
  font-family: var(--font-heading);
}

.book-card .info {
  padding: 16px;
}

.book-card .info h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: var(--color-text);
  line-height: 1.3;
}

.book-card .info .author {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.book-card .info .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.book-card .info .meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==================== Search & Toolbar ==================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}

.search-box input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
}

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

.search-box button {
  padding: 8px 16px;
}

/* ==================== Reader Page ==================== */
.reader-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  height: calc(100vh - 60px);
}

.reader-main {
  display: flex;
  flex-direction: column;
  background: #3c3c3c;
  position: relative;
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #2c2c2c;
  color: #ccc;
  font-size: 0.85rem;
}

.reader-toolbar .page-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-toolbar .page-info input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #444;
  color: white;
  text-align: center;
  font-size: 0.85rem;
}

.reader-toolbar button {
  background: #555;
  color: #ccc;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.reader-toolbar button:hover {
  background: #666;
  color: white;
}

.pdf-container {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.pdf-container canvas {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  max-width: 100%;
}

.reader-sidebar {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-tabs button {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.sidebar-tabs button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ==================== Comments ==================== */
.comment-form {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.comment-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 8px;
  background: var(--color-bg);
  color: var(--color-text);
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.comment-form .form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.comment-form .form-row label {
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-form .form-row input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.comment-form .screenshot-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-form .screenshot-area .preview {
  max-width: 120px;
  max-height: 80px;
  border-radius: 4px;
  display: none;
}

.comment-item {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--color-bg);
}

.comment-item .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.comment-item .header .user {
  font-weight: 600;
  color: var(--color-primary);
}

.comment-item .header .page-tag {
  background: var(--color-primary-light);
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.comment-item .header .time {
  color: var(--color-text-secondary);
}

.comment-item .content {
  font-size: 0.9rem;
  margin-bottom: 8px;
  line-height: 1.5;
}

.comment-item .screenshot {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.comment-item .screenshot:hover {
  transform: scale(1.02);
}

/* ==================== Upload Page ==================== */
.upload-form {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px;
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid var(--color-border);
}

.upload-form .form-group {
  margin-bottom: 20px;
}

.upload-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.upload-form input,
.upload-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}

.upload-form input:focus,
.upload-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: white;
}

.upload-form textarea {
  min-height: 100px;
  resize: vertical;
}

.upload-form .file-input {
  border: 2px dashed var(--color-border);
  padding: 24px;
  text-align: center;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-bg);
}

.upload-form .file-input:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-alt);
}

.upload-form .file-input .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.upload-form .file-input .hint {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.upload-form .progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
  display: none;
}

.upload-form .progress-bar .fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content img {
  max-width: 100%;
  border-radius: var(--radius);
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
}

/* ==================== Empty State ==================== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-text-secondary);
}

.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--color-text);
}

/* ==================== Toast Notification ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-accent); }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .reader-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .reader-sidebar {
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }

  .book-card .cover,
  .book-card .cover-placeholder {
    height: 140px;
  }

  .container { padding: 16px; }
  .login-card { margin: 16px; }
}

/* ==================== Loading Spinner ==================== */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
