/* ===== Design Tokens ===== */
:root {
  /* Light theme — warm bookshelf aesthetic */
  --bg-primary: #fef3c7;
  --bg-secondary: #fde68a;
  --bg-card: #fffbeb;
  --bg-card-hover: #fef9e7;
  --bg-input: #ffffff;
  --bg-overlay: rgba(120, 53, 15, 0.4);
  --text-primary: #451a03;
  --text-secondary: #78350f;
  --text-muted: #92400e;
  --accent: #92400e;
  --accent-light: #b45309;
  --accent-gradient: linear-gradient(135deg, #92400e, #b45309);
  --accent-hover: #78350f;
  --border: rgba(146, 64, 14, 0.15);
  --border-strong: rgba(146, 64, 14, 0.3);
  --shadow-sm: 0 1px 3px rgba(69, 26, 3, 0.08);
  --shadow-md: 0 4px 14px rgba(69, 26, 3, 0.1);
  --shadow-lg: 0 8px 30px rgba(69, 26, 3, 0.12);
  --shadow-glow: 0 0 20px rgba(146, 64, 14, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --transition: 0.2s ease;
  --glass: rgba(255, 251, 235, 0.7);
  --glass-border: rgba(146, 64, 14, 0.12);

  /* Progress bar colors */
  --progress-bg: rgba(146, 64, 14, 0.1);
  --progress-fill: var(--accent-gradient);

  /* Status colors */
  --status-not-started: #9ca3af;
  --status-in-progress: #f59e0b;
  --status-finished: #10b981;

  /* Priority */
  --priority-high: #ef4444;
  --priority-medium: #f59e0b;
  --priority-low: #10b981;
}

/* Dark mode — deep brown-black with warm text */
[data-theme="dark"] {
  --bg-primary: #1c1209;
  --bg-secondary: #27190d;
  --bg-card: #2d1e11;
  --bg-card-hover: #3a2717;
  --bg-input: #1c1209;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --text-primary: #fef3c7;
  --text-secondary: #fde68a;
  --text-muted: #d97706;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-gradient: linear-gradient(135deg, #f59e0b, #fbbf24);
  --accent-hover: #d97706;
  --border: rgba(253, 230, 138, 0.1);
  --border-strong: rgba(253, 230, 138, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.15);
  --glass: rgba(45, 30, 17, 0.7);
  --glass-border: rgba(253, 230, 138, 0.08);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.6rem;
}

.logo h1 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--accent);
}
.icon-btn .icon {
  width: 18px;
  height: 18px;
}

/* Theme toggle icon visibility */
[data-theme="dark"] .sun { display: block; }
[data-theme="dark"] .moon { display: none; }
:root:not([data-theme="dark"]) .sun,
body:not([data-theme="dark"]) .sun { display: none; }
:root:not([data-theme="dark"]) .moon,
body:not([data-theme="dark"]) .moon { display: block; }

/* ===== Main Content ===== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Stats Dashboard ===== */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-wide {
  grid-column: span 4;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.stat-card-wide .stat-label {
  margin: 0;
  white-space: nowrap;
}

.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ===== Controls Bar ===== */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  transition: all var(--transition);
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(146, 64, 14, 0.1);
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Reading List Items ===== */
.reading-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  animation: slideIn 0.35s ease forwards;
}
.list-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

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

.list-item.finished {
  opacity: 0.7;
}
.list-item.finished .item-title {
  text-decoration: line-through;
  text-decoration-color: var(--accent);
}

.item-type-badge {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.item-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: text-decoration var(--transition);
}

.item-title a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}
.item-title a:hover {
  color: var(--accent);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.item-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--progress-bg);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}

.item-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 99px;
  transition: width 0.5s ease;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.item-notes-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent);
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 60px;
  overflow: hidden;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-self: flex-start;
}

.item-estimate {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.not-started {
  background: rgba(156, 163, 175, 0.15);
  color: var(--status-not-started);
}
.status-badge.in-progress {
  background: rgba(245, 158, 11, 0.15);
  color: var(--status-in-progress);
}
.status-badge.finished {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-finished);
}

/* Priority dot */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-dot.high { background: var(--priority-high); }
.priority-dot.medium { background: var(--priority-medium); }
.priority-dot.low { background: var(--priority-low); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-sm {
  max-width: 400px;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 8px 24px 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.required {
  color: var(--priority-high);
}

.optional {
  color: var(--text-muted);
  font-weight: 400;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  transition: all var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(146, 64, 14, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
}

/* Progress Slider */
.progress-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 99px;
  background: var(--progress-bg);
  outline: none;
  margin-top: 6px;
}

.progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}

.progress-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ===== Export Options ===== */
.export-options {
  display: flex;
  gap: 12px;
}

.export-option {
  flex: 1;
  flex-direction: column;
  padding: 20px;
  font-size: 0.9rem;
}

.export-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

/* ===== Import ===== */
.import-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: all var(--transition);
}

.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--accent);
  background: rgba(146, 64, 14, 0.05);
  color: var(--accent);
}

.drop-icon {
  width: 32px;
  height: 32px;
}

.import-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-finished);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  color: var(--text-primary);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3s forwards;
  max-width: 320px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
  }

  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card-wide {
    grid-column: span 2;
  }

  .controls-bar {
    flex-direction: column;
  }

  .search-wrap {
    width: 100%;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group select {
    flex: 1;
  }

  .list-item {
    flex-direction: column;
    gap: 10px;
  }

  .item-type-badge {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }

  .item-header {
    flex-direction: column;
    gap: 6px;
  }

  .item-actions {
    align-self: flex-end;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-group {
    width: 100% !important;
  }

  .export-options {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 16px;
  }

  .stats-dashboard {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .header-actions .btn span,
  .btn-ghost .btn-text {
    display: none;
  }
}

/* ===== Checked-off Animation ===== */
@keyframes checkOff {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 0.7; }
}

.list-item.just-finished {
  animation: checkOff 0.5s ease forwards;
}
