/* ════════════════════════════════════════════════
   NOVELA — Light, warm, cozy reading platform
   Paleta: creme, terracota suave, marrom quente
   ════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --bg:          #faf7f2;
  --bg2:         #f4ede3;
  --bg3:         #ede4d8;
  --surface:     #ffffff;
  --surface2:    #fdf9f5;
  --border:      #e0d5c7;
  --border2:     #ece4d9;

  --brown:       #7c5c3e;
  --brown-light: #a07850;
  --brown-dim:   #c4a882;
  --terra:       #b86b4a;
  --terra-light: #d4845e;
  --terra-dim:   rgba(184,107,74,.12);

  --text:        #3a2e24;
  --text2:       #6b5644;
  --text3:       #a08872;
  --text4:       #c4b09a;

  --font-title:  'Lora', Georgia, serif;
  --font-body:   'DM Sans', system-ui, sans-serif;

  --r-sm:  8px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;

  --shadow-sm: 0 2px 8px rgba(90,60,30,.08);
  --shadow:    0 4px 24px rgba(90,60,30,.1);
  --shadow-lg: 0 8px 40px rgba(90,60,30,.13);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
::selection { background: rgba(184,107,74,.18); }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--brown-dim); border-radius: 4px; }

/* ── Shell ── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 2rem;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,247,242,.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--brown);
  letter-spacing: .01em;
}

.nav { display: flex; gap: .25rem; align-items: center; }

.nav a {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  padding: .45rem .85rem;
  border-radius: 999px;
  transition: all .15s;
}
.nav a:hover { background: var(--bg3); color: var(--text); }
.nav a.active { background: var(--terra-dim); color: var(--terra); font-weight: 600; }

/* ── Page ── */
.page {
  width: min(1060px, calc(100% - 2.5rem));
  margin: 2rem auto 4rem;
  flex: 1;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

/* ── Flash ── */
.flash {
  width: min(1060px, calc(100% - 2.5rem));
  margin: .75rem auto 0;
  padding: .85rem 1.25rem;
  border-radius: var(--r);
  font-size: .875rem;
}
.flash.danger  { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.flash.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* ── Typography ── */
.label-sm {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
}

h1, h2, h3 {
  font-family: var(--font-title);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.muted, small { color: var(--text3); font-size: .85rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 500;
  padding: .6rem 1.25rem;
  border-radius: 999px;
  border: 1.5px solid var(--terra);
  background: var(--terra);
  color: #fff;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--terra-light); border-color: var(--terra-light); }

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text2);
}
.btn.ghost:hover { background: var(--bg2); border-color: var(--border); color: var(--text); }

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

.btn.disabled { pointer-events: none; opacity: .4; }

.mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 500;
  padding: .35rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
}
.mini:hover { background: var(--bg3); color: var(--text); }

/* ── Pill / Badge ── */
.pill {
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text3);
  border: 1px solid var(--border2);
}

/* ════════════════════
   HOME — SHELF / OBRAS
   ════════════════════ */

.shelf-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.shelf-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.novels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

/* Card da obra na prateleira */
.novel-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.novel-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.novel-card-cover {
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg3);
  flex-shrink: 0;
}
.novel-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.novel-card:hover .novel-card-cover img { transform: scale(1.04); }

.novel-card-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.novel-card-info h3 {
  font-family: var(--font-title);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.novel-card-info p {
  font-size: .78rem;
  color: var(--text3);
  line-height: 1.45;
  flex: 1;
}
.novel-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .5rem;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  margin-right: .35rem;
}

/* ════════════════════
   NOVEL DETAIL PAGE
   ════════════════════ */

/* Cabeçalho da obra — capa + título + info */
.novel-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.novel-cover-wrap {
  flex-shrink: 0;
  width: 180px;
}
.novel-cover-wrap img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  border: 1px solid var(--border2);
}

.novel-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.novel-meta h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  line-height: 1.15;
}
.novel-meta .subtitle {
  font-size: 1rem;
  color: var(--text2);
  font-style: italic;
}
.novel-meta .stats-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}
.stat-chip {
  font-size: .78rem;
  font-weight: 500;
  padding: .3rem .75rem;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text2);
  border: 1px solid var(--border2);
}
.novel-meta .actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

/* Sinopse */
.synopsis-block {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border2);
}
.synopsis-block h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text3);
  margin-bottom: .75rem;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .78rem;
}
.synopsis-text {
  font-size: .975rem;
  color: var(--text2);
  line-height: 1.85;
  font-family: var(--font-title);
  font-style: italic;
}

/* ════════════════
   SEASONS / CHAPTERS
   ════════════════ */

.section-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border2); }

.seasons-list { display: grid; gap: 1.25rem; }

.season-block {
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.season-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border2);
  gap: 1rem;
}
.season-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.season-header p {
  font-size: .83rem;
  color: var(--text3);
  margin-top: .2rem;
  font-style: italic;
}
.season-info { flex: 1; }

.chapter-list { display: grid; }
.chapter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.5rem;
  border-bottom: 1px solid var(--border2);
  transition: background .12s;
  color: var(--text);
}
.chapter-row:last-child { border-bottom: none; }
.chapter-row:hover { background: var(--bg2); }

.ch-num {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text4);
  min-width: 2rem;
  text-align: right;
  flex-shrink: 0;
}
.ch-info { flex: 1; }
.ch-info strong {
  font-size: .92rem;
  font-weight: 500;
  color: var(--text);
  display: block;
}
.ch-info span { font-size: .8rem; color: var(--text3); }
.ch-arrow { color: var(--text4); font-size: .9rem; flex-shrink: 0; }

/* ════════════════
   SEASONS GRID VIEW
   ════════════════ */
.seasons-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 1rem; }
.season-card {
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.season-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.season-card h2 { font-size: 1rem; }
.season-card p { font-size: .875rem; color: var(--text2); flex: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.list-head h1, .list-head h2 { font-size: 1.15rem; }

/* ════════════════
   SEARCH
   ════════════════ */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.section-head h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.section-head p { color: var(--text2); font-size: .9rem; margin-top: .2rem; }

.searchbar { display: flex; gap: .5rem; flex-wrap: wrap; }
.searchbar input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  font-size: .9rem;
  color: var(--text);
  outline: none;
  min-width: 220px;
  transition: border-color .15s;
}
.searchbar input:focus { border-color: var(--terra); }
.searchbar input::placeholder { color: var(--text4); }

/* ════════════════
   READER
   ════════════════ */
.reader { display: grid; gap: 1.25rem; }

.reader-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.reader-head-info .label-sm { margin-bottom: .4rem; }
.reader-head-info h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.2;
}
.reader-head-info .season-link {
  font-size: .83rem;
  color: var(--text3);
  margin-top: .3rem;
}
.reader-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }

.reading-area {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.reading-area p {
  font-family: var(--font-title);
  font-size: 1.1rem;
  line-height: 1.95;
  color: var(--text);
  margin-bottom: 1.25rem;
  text-align: justify;
}
.reading-area p:last-child { margin-bottom: 0; }

.reader-nav {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  max-width: 680px;
  margin: 0 auto;
}

/* ════════════════
   ADMIN
   ════════════════ */
.admin-grid { display: grid; gap: 1.25rem; }
.admin-two-col { display: grid; grid-template-columns: 1.2fr .9fr; gap: 1.25rem; }
.admin-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; }

.action-card {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--r-lg);
  transition: all .15s;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
}
.action-card:hover { border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-dim); transform: translateY(-1px); }
.action-card strong { font-size: .95rem; font-weight: 600; color: var(--text); }
.action-card p { font-size: .83rem; color: var(--text3); line-height: 1.4; }

.admin-hero { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.admin-hero h1 { font-size: 1.6rem; }
.admin-hero p { font-size: .9rem; color: var(--text2); margin-top: .3rem; }
.admin-stats { display: flex; gap: .75rem; flex-wrap: wrap; }
.admin-stat {
  text-align: center;
  padding: .85rem 1.25rem;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
}
.admin-stat strong { display: block; font-family: var(--font-title); font-size: 1.5rem; color: var(--terra); }
.admin-stat span { font-size: .73rem; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }

.form-grid { display: grid; gap: .9rem; margin-top: 1rem; }
.form-grid label {
  display: grid;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text2);
}
.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .7rem .9rem;
  font-size: .93rem;
  outline: none;
  transition: border-color .15s;
}
.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus { border-color: var(--terra); background: var(--surface); }
.form-grid select option { background: #fff; }
.form-grid textarea { resize: vertical; }

.checkbox { display: flex !important; flex-direction: row !important; align-items: center; gap: .6rem; }
.checkbox input { width: auto; accent-color: var(--terra); cursor: pointer; }

.table-like { display: grid; gap: .5rem; margin-top: 1rem; }
.table-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-radius: var(--r);
  background: var(--surface2);
  border: 1px solid var(--border2);
  transition: border-color .15s;
}
.table-row:hover { border-color: var(--border); }
.table-row strong { font-size: .9rem; color: var(--text); }
.table-row p { font-size: .8rem; color: var(--text3); margin-top: .15rem; font-style: italic; }
.table-row small { font-size: .73rem; color: var(--terra); margin-top: .25rem; display: block; }
.row-actions { display: flex; gap: .35rem; flex-shrink: 0; }

.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #fecaca; }

.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: .88em; }

/* ── Auth ── */
.auth-page { width: min(440px, calc(100% - 2rem)); }
.auth-card { padding: 2.25rem; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .25rem; }
.auth-card .label-sm { color: var(--terra); margin-bottom: .1rem; display: block; }
.auth-card > p { font-size: .88rem; color: var(--text3); margin-bottom: .75rem; }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border2);
  font-size: .78rem;
  color: var(--text4);
}

/* ── Reading progress ── */
#read-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--terra);
  z-index: 9999;
  border-radius: 0 2px 2px 0;
  transition: width .08s linear;
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page > * { animation: fadeUp .35s ease both; }
.page > *:nth-child(1) { animation-delay: .04s; }
.page > *:nth-child(2) { animation-delay: .1s; }
.page > *:nth-child(3) { animation-delay: .16s; }
.page > *:nth-child(4) { animation-delay: .22s; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .novel-header { flex-direction: column; align-items: center; text-align: center; }
  .novel-cover-wrap { width: 160px; }
  .novel-meta .stats-row, .novel-meta .actions { justify-content: center; }
  .admin-two-col { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .reader-head { flex-direction: column; }
  .reading-area { padding: 1.5rem; }
}
@media (max-width: 580px) {
  .topbar { padding: 0 1rem; height: 56px; }
  .nav a { font-size: .8rem; padding: .4rem .65rem; }
  .page { width: calc(100% - 1.5rem); margin: 1rem auto 3rem; }
  .novels-grid { grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 1rem; }
  .novel-cover-wrap { width: 130px; }
  .reading-area { font-size: .95rem; }
}
