/* =============================================
   BOOKSHELF -- Livraria Aconchegante Theme
   ============================================= */

/* --- CSS Variables --- */
:root {
  --bg: #faf6f1;
  --bg-card: #fff8f0;
  --text: #3d3229;
  --text-light: #8b7355;
  --accent: #8b6f47;
  --accent-hover: #7a5f3a;
  --border: #e8dcc8;
  --status-read: #6b8e5e;
  --status-reading: #c4973b;
  --status-wishlist: #5b7fa5;
  --success: #6b8e5e;
  --error: #c0392b;
  --shadow: rgba(139, 111, 71, 0.1);
  --sidebar-width: 220px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--text);
  margin: 0 0 12px 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* =============================================
   SIDEBAR NAV (Desktop)
   ============================================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  padding-bottom: 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background-color: rgba(139, 111, 71, 0.08);
  color: var(--accent);
}

.nav-link.active {
  background-color: rgba(139, 111, 71, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.nav-logout {
  margin-top: auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-logout:hover {
  background-color: rgba(192, 57, 43, 0.08);
  color: var(--error);
  border-color: var(--error);
}

/* =============================================
   BOTTOM NAV (Mobile)
   ============================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 12px;
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 16px;
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.15s ease;
  border-radius: 8px;
}

.bottom-nav-item:hover {
  color: var(--accent);
}

.bottom-nav-item.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* =============================================
   MAIN CONTENT AREA
   ============================================= */
main#app {
  padding: 32px 24px;
  min-height: 100vh;
}

/* =============================================
   LOGIN
   ============================================= */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background-color: var(--bg-card);
  padding: 48px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 24px var(--shadow), 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.login-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 28px;
  margin-top: 0;
}

/* =============================================
   FORM ELEMENTS
   ============================================= */
.input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.12);
}

.input::placeholder {
  color: var(--text-light);
}

textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 16px;
  min-height: 80px;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.12);
}

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.search-input {
  display: inline-block;
  width: auto;
  margin-bottom: 0;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  transition: background-color 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, transform 0.1s ease;
  text-align: center;
  line-height: 1.4;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-secondary:hover {
  background-color: rgba(139, 111, 71, 0.08);
}

.btn-danger {
  background-color: var(--error);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #a93226;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

/* --- Form groups --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

.form-group .input,
.form-group textarea,
.form-group select {
  margin-bottom: 0;
}

/* =============================================
   FILTER BAR
   ============================================= */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  align-items: center;
}

.filter-pill {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-light);
  transition: background-color 0.15s ease, color 0.15s ease,
              border-color 0.15s ease;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-pill.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* =============================================
   BOOK GRID
   ============================================= */
.book-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.book-card {
  background-color: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow), 0 2px 6px rgba(0,0,0,0.06);
}

.book-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background-color: var(--border);
}

.book-card-info {
  padding: 12px;
}

.book-card-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.book-card-author {
  color: var(--text-light);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.book-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* =============================================
   STATUS BADGES
   ============================================= */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-badge.read {
  background-color: rgba(107, 142, 94, 0.15);
  color: var(--status-read);
}

.status-badge.reading {
  background-color: rgba(196, 151, 59, 0.15);
  color: var(--status-reading);
}

.status-badge.wishlist {
  background-color: rgba(91, 127, 165, 0.15);
  color: var(--status-wishlist);
}

/* =============================================
   STARS
   ============================================= */
.stars {
  display: inline-flex;
  gap: 1px;
  font-size: 0.9rem;
}

.star-filled {
  color: var(--accent);
}

.star-empty {
  color: var(--border);
}

/* =============================================
   PROGRESS BARS
   ============================================= */
.progress-bar {
  width: 100%;
  background-color: var(--border);
  height: 4px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* =============================================
   READING GOAL BAR
   ============================================= */
.goal-bar {
  background-color: var(--bg-card);
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.goal-bar h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--text);
}

.goal-bar .goal-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.goal-progress {
  width: 100%;
  background-color: var(--border);
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 8px;
  transition: width 0.4s ease;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 220px;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: fadeInOut 3s ease forwards;
  pointer-events: auto;
}

.toast-success {
  background-color: var(--success);
}

.toast-error {
  background-color: var(--error);
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(20px); }
  12%  { opacity: 1; transform: translateX(0); }
  75%  { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(20px); }
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal {
  background-color: var(--bg-card);
  padding: 32px;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.modal h2 {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 1rem;
}

.empty-state-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* =============================================
   SEARCH RESULTS
   ============================================= */
.search-results {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: rgba(139, 111, 71, 0.06);
}

.search-result-thumb {
  width: 44px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background-color: var(--border);
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-author {
  color: var(--text-light);
  font-size: 0.8rem;
}

/* =============================================
   BOOK DETAIL
   ============================================= */
.book-detail {
  max-width: 700px;
  margin: 0 auto;
}

.book-detail-header {
  display: flex;
  gap: 28px;
  margin-bottom: 32px;
  align-items: flex-start;
}

.book-detail img {
  width: 160px;
  flex-shrink: 0;
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.book-detail-info {
  flex: 1;
  min-width: 0;
}

.book-detail-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.book-detail-author {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.book-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.book-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.book-detail-section {
  margin-bottom: 24px;
}

.book-detail-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
}

.book-detail-notes {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* =============================================
   STATS PAGE
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.stat-card .stat-number {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2.2rem;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

/* =============================================
   SECTION TITLE
   ============================================= */
.section-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* =============================================
   BACK LINK
   ============================================= */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 20px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--accent);
}

/* =============================================
   LOADING SPINNER
   ============================================= */
.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   DIVIDER
   ============================================= */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* =============================================
   SCROLLBAR (Webkit)
   ============================================= */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* =============================================
   PHOTO SCAN (Add via Camera)
   ============================================= */
.photo-scan-area {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.photo-scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 2px dashed var(--accent);
  background: rgba(139, 111, 71, 0.04);
  color: var(--accent);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.photo-scan-btn:hover {
  background: rgba(139, 111, 71, 0.1);
  border-color: var(--accent-hover);
}

.photo-scan-preview {
  margin-top: 12px;
  text-align: center;
}

.photo-scan-preview img {
  max-height: 200px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
}

.photo-scan-progress {
  margin-top: 12px;
}

.photo-scan-progress-label {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 6px;
}

.photo-scan-progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.photo-scan-progress-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 6px;
  transition: width 0.3s ease;
  width: 0%;
}

.photo-scan-text-area {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.photo-scan-text-area textarea {
  flex: 1;
  min-height: 60px;
  margin-bottom: 0;
}

.photo-scan-text-area .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.photo-scan-error {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--error);
}

/* =============================================
   RESPONSIVE -- MOBILE (<640px)
   ============================================= */
@media (max-width: 639px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  main#app {
    padding: 20px 16px;
    padding-bottom: 80px;
    margin-left: 0;
  }

  .book-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .book-detail-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .book-detail img {
    width: 140px;
  }

  .book-detail-actions {
    justify-content: center;
  }

  .book-detail-meta {
    justify-content: center;
  }

  .login-card {
    padding: 32px 24px;
  }

  .modal {
    padding: 24px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* =============================================
   RESPONSIVE -- TABLET (640px - 1023px)
   ============================================= */
@media (min-width: 640px) and (max-width: 1023px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  main#app {
    padding: 24px 20px;
    padding-bottom: 80px;
    margin-left: 0;
  }

  .book-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =============================================
   RESPONSIVE -- DESKTOP (>=1024px)
   ============================================= */
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  main#app {
    margin-left: var(--sidebar-width);
    padding: 36px 40px;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =============================================
   RESPONSIVE -- WIDE DESKTOP (>=1440px)
   ============================================= */
@media (min-width: 1440px) {
  .book-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
