/* style.css — Book Library app
   iOS-inspired visual style (grouped lists, nav bar), adapted for the browser. */

:root {
  --bg: #000000;
  --card: #1C1C1E;
  --blue: #0A84FF;
  --red: #FF453A;
  --label: #FFFFFF;
  --secondary-label: #98989D;
  --tertiary-label: #636366;
  --separator: #38383A;
  --fill: #2C2C2E;              /* neutral control fill: segmented track, search bar, chips */
  --fill-raised: #3A3A3C;       /* raised/selected state on top of --fill, e.g. active segment */
  --blue-tint: rgba(10, 132, 255, 0.22); /* blue-tinted background for badges/chips */
  --placeholder: #48484A;       /* cover placeholder while no image is set */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--label);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 90px; /* leave room for tab bar */
}

.view { display: none; }
.view.active { display: block; }

/* Nav bar */
.navbar {
  padding: 10px 16px 10px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0 10px;
}
.nav-back, .nav-icon-btn, .nav-cancel, .nav-done {
  color: var(--blue);
  font-size: 17px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
}
.nav-done { font-weight: 600; }
.nav-title { font-size: 17px; font-weight: 600; }

/* Segmented control (Status / Authors / Categories) */
.segmented {
  display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 8px;
}
.segment {
  flex: 1; text-align: center; padding: 6px 0; font-size: 13px; font-weight: 600;
  color: var(--secondary-label); background: none; border: none; border-radius: 7px;
  cursor: pointer; font-family: inherit;
}
.segment.active { background: var(--fill-raised); color: var(--label); box-shadow: 0 1px 2px rgba(0,0,0,0.4); }

/* Authors/Categories index rows */
.index-count { font-size: 13px; color: var(--tertiary-label); flex-shrink: 0; }

/* Search bar */
.searchbar {
  background: var(--fill);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.searchbar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  width: 100%;
  font-family: inherit;
  color: var(--label);
}

/* Section headers (collapsible groups) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  cursor: pointer;
  user-select: none;
}
.section-header .title-group { display: flex; align-items: center; gap: 6px; }
.section-header .chevron { font-size: 13px; color: var(--tertiary-label); transition: transform 0.15s ease; }
.section-header.collapsed .chevron { transform: rotate(-90deg); }
.section-header .label {
  font-size: 13px; font-weight: 600; color: var(--secondary-label);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.section-header .count { font-size: 13px; color: var(--tertiary-label); }
.section-body.collapsed { display: none; }

/* Card list */
.card { background: var(--card); margin: 0 16px 10px; border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-bottom: 0.5px solid var(--separator); cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--fill); }

.cover {
  width: 42px; height: 62px; border-radius: 4px; background-size: cover;
  background-position: center; background-color: var(--placeholder); flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.detail-cover {
  width: 150px; height: 220px; border-radius: 8px; background-size: cover;
  background-position: center; background-color: var(--placeholder);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5); margin: 0 auto 14px;
}

.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-author { font-size: 13px; color: var(--secondary-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-series { font-size: 12px; color: var(--tertiary-label); }
.row-source { font-size: 12px; color: var(--tertiary-label); }
.row-rating {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0;
}
.stars { font-size: 14px; letter-spacing: 1px; white-space: nowrap; flex-shrink: 0; }
.stars-red { color: #FF6961; }
.stars-yellow { color: #FFD60A; }
.stars-green { color: #32D74B; }
.row-action-btn {
  font-size: 12px; color: var(--blue); background: none; border: 1px solid var(--blue);
  border-radius: 20px; padding: 4px 10px; flex-shrink: 0; cursor: pointer; font-family: inherit;
}
.chev-right { color: var(--tertiary-label); font-size: 15px; flex-shrink: 0; }

/* Empty state */
.empty-state {
  text-align: center; color: var(--tertiary-label); font-size: 14px; padding: 40px 20px;
}

/* Detail view */
.detail-hero { display: flex; flex-direction: column; align-items: center; padding: 8px 16px 20px; text-align: center; }
.detail-title { font-size: 20px; font-weight: 700; padding: 0 20px; }
.detail-author { font-size: 15px; color: var(--secondary-label); margin-top: 3px; }
.detail-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.badge-status { background: var(--blue-tint); color: var(--blue); }

/* Cover editing (Edit Book view): click + paste an image, or Upload Photo */
.detail-cover.editable { cursor: pointer; outline: none; }
.detail-cover.editable:focus { box-shadow: 0 0 0 3px rgba(10,132,255,0.45); }
.detail-cover.editable.no-cover { display: flex; align-items: center; justify-content: center; }
.detail-cover.editable.no-cover::after {
  content: "Click, then paste (⌘V) an image";
  font-size: 12px; color: var(--secondary-label); text-align: center; padding: 0 14px; line-height: 1.4;
}
.cover-edit-actions { display: flex; justify-content: center; margin-top: 10px; }
.cover-action-btn {
  font-size: 13px; color: var(--blue); background: none; border: 1px solid var(--blue);
  border-radius: 20px; padding: 6px 14px; cursor: pointer; font-family: inherit;
}

.field-group { background: var(--card); margin: 0 16px 16px; border-radius: 12px; overflow: hidden; }
.field-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-bottom: 0.5px solid var(--separator); gap: 12px; }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 15px; flex-shrink: 0; }
.field-value { font-size: 15px; color: var(--secondary-label); text-align: right; }
.field-value.multi { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-size: 12px; background: var(--fill); color: var(--secondary-label); padding: 3px 9px; border-radius: 20px; }
.chip.removable { display: flex; align-items: center; gap: 5px; background: var(--blue-tint); color: var(--blue); cursor: pointer; }
.chip.add-chip { background: transparent; border: 1px dashed var(--tertiary-label); color: var(--secondary-label); cursor: pointer; }

.group-label { font-size: 13px; font-weight: 600; color: var(--secondary-label); text-transform: uppercase; letter-spacing: 0.4px; padding: 6px 16px 6px 30px; }
.synopsis-box, .notes-box { padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.notes-box { color: var(--secondary-label); font-style: italic; }

.field-input, .field-select, .synopsis-input, .notes-input {
  font-family: inherit; font-size: 15px; color: var(--label); border: none;
  background: transparent; outline: none; width: 100%;
}
.field-row.editing .field-label { width: 90px; }
.field-row.editing .field-input, .field-row.editing .field-select { text-align: right; }
.synopsis-input, .notes-input { resize: vertical; padding: 12px 14px; min-height: 70px; line-height: 1.45; }

.action-row {
  display: flex; align-items: center; justify-content: center; padding: 12px;
  font-size: 15px; font-weight: 600; color: var(--blue); border-bottom: 0.5px solid var(--separator);
  cursor: pointer; background: none; border-left: none; border-right: none; border-top: none; width: 100%; font-family: inherit;
}
.action-row:last-child { border-bottom: none; }
.action-row.destructive { color: var(--red); }

/* Match picker (Add Book) */
.match-item { padding: 12px 14px; border-bottom: 0.5px solid var(--separator); cursor: pointer; display: flex; gap: 12px; align-items: center; }
.match-item:last-child { border-bottom: none; }
.match-item:active { background: var(--fill); }
.match-text { flex: 1; }
.match-title { font-size: 15px; font-weight: 600; }
.match-author { font-size: 13px; color: var(--secondary-label); }
.match-source-tag { font-size: 11px; color: var(--tertiary-label); }

/* Import recap */
.recap-line { font-size: 14px; padding: 6px 14px; }
.recap-skip { color: var(--secondary-label); font-style: italic; }

/* Buttons for import/backup screens */
.big-button {
  display: block; width: calc(100% - 32px); margin: 12px 16px; padding: 14px;
  background: var(--blue); color: #fff; text-align: center; border-radius: 12px;
  font-size: 16px; font-weight: 600; border: none; cursor: pointer; font-family: inherit;
}
.big-button.secondary { background: var(--card); color: var(--blue); border: 1px solid var(--blue); }
.section-note { font-size: 13px; color: var(--secondary-label); padding: 4px 16px 16px; line-height: 1.4; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: 76px; background: rgba(20,20,22,0.92);
  backdrop-filter: blur(20px); border-top: 0.5px solid var(--separator);
  display: flex; padding-top: 8px;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--tertiary-label); font-size: 10px; font-weight: 500; cursor: pointer;
  background: none; border: none; font-family: inherit;
}
.tab.active { color: var(--blue); }

input[type="file"] { display: none; }
