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

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

:root {
  --bg:        #F7F4EF;
  --bg2:       #EFEAE2;
  --bg3:       #E5DED3;
  --surface:   #FDFCFA;
  --border:    #D8D1C7;
  --border2:   #C4BAB0;
  --text:      #1C1916;
  --text2:     #5C5650;
  --text3:     #8C867F;
  --accent:    #2D5016;
  --accent2:   #4A7A28;
  --accent-bg: #EBF2E4;
  --danger:    #8B1A1A;
  --danger-bg: #FBF0F0;
  --warn:      #7A5A10;
  --warn-bg:   #FBF5E6;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(28,25,22,0.08), 0 4px 12px rgba(28,25,22,0.05);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: 'Lora', serif;
  font-weight: 500;
  line-height: 1.25;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 0 24px; }

/* --- Nav --- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 32px;
}
.nav-brand {
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  font-size: 14px;
  font-weight: 400;
  color: var(--text2);
  padding: 6px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--bg2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--text3); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border2);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg2); }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg2); color: var(--text); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #E8C0C0;
}
.btn-danger:hover:not(:disabled) { background: #F5E0E0; }
.btn-sm { font-size: 13px; padding: 5px 10px; }
.btn-icon { padding: 7px; }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(74,122,40,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 5px; }
.form-error { font-size: 13px; color: var(--danger); margin-top: 5px; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 14px 16px; }

/* --- Book grid --- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}
.book-card:hover {
  box-shadow: 0 4px 20px rgba(28,25,22,0.12);
  transform: translateY(-2px);
}
.book-cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lora', serif;
  font-size: 13px;
  color: var(--text3);
  text-align: center;
  padding: 16px;
}
.book-info { padding: 12px; }
.book-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.3; margin-bottom: 3px; }
.book-author { font-size: 12px; color: var(--text3); }

/* --- Loan badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-on-loan { background: var(--warn-bg); color: var(--warn); }
.badge-returned { background: var(--accent-bg); color: var(--accent); }
.badge-borrowed { background: #EEF0FA; color: #3A3D8C; }

/* --- Loan list --- */
.loan-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.loan-row:last-child { border-bottom: none; }
.loan-cover-thumb {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg2);
  flex-shrink: 0;
}
.loan-cover-thumb-placeholder {
  width: 36px;
  height: 54px;
  background: var(--bg2);
  border-radius: 4px;
  flex-shrink: 0;
}
.loan-details { flex: 1; min-width: 0; }
.loan-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loan-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.loan-actions { flex-shrink: 0; }

/* --- Empty state --- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty h3 { font-family: 'Lora', serif; font-size: 18px; color: var(--text2); margin-bottom: 6px; }
.empty p { font-size: 14px; }

/* --- Page header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 26px; }
.page-subtitle { font-size: 14px; color: var(--text3); margin-top: 2px; font-family: 'DM Sans', sans-serif; font-weight: 300; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(28,25,22,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(28,25,22,0.2);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* --- Alert --- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #EAC0C0; }
.alert-success { background: var(--accent-bg); color: var(--accent); border: 1px solid #C0D8A8; }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text3);
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* --- Auth pages --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo {
  font-family: 'Lora', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-tagline {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 28px;
}
.auth-divider {
  text-align: center;
  font-size: 13px;
  color: var(--text3);
  margin: 20px 0;
}
.auth-submit { width: 100%; padding: 11px; font-size: 15px; }

/* --- Spinner --- */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Search --- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-input {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent2); }

/* --- Stats bar --- */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  flex: 1;
  min-width: 100px;
}
.stat-value { font-size: 24px; font-family: 'Lora', serif; font-weight: 500; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* --- Responsive --- */
@media (max-width: 600px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .nav-links { display: none; }
  .auth-card { padding: 28px 20px; }
}
