/* ===== BIBLIAPP — Design System ===== */
/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:wght@500;600;700&display=swap');

/* ===== CSS Custom Properties ===== */
:root {
  /* Colors */
  --bg: #f7f5f0;
  --bg-alt: #f0ede6;
  --surface: #faf9f6;
  --surface-hover: #f0ede6;
  --primary: #5c6b3a;
  --primary-hover: #4a5a2e;
  --primary-light: rgba(92, 107, 58, 0.08);
  --primary-border: rgba(92, 107, 58, 0.2);
  --accent: #a07c2a;
  --accent-light: rgba(160, 124, 42, 0.1);
  --error: #9b3535;
  --error-light: rgba(155, 53, 53, 0.08);
  --error-border: rgba(155, 53, 53, 0.2);
  --success: #3a7d44;
  --success-light: rgba(58, 125, 68, 0.1);
  --warning: #b8860b;
  --warning-light: rgba(184, 134, 11, 0.1);
  --text: #2d2d2d;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --text-inverse: #ffffff;
  --border: #e0dcd0;
  --border-light: #ebe8de;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  /* Typography */
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Lora', Georgia, serif;
  /* Spacing */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
}

[data-theme="dark"] {
  --bg: #1a1d15;
  --bg-alt: #1f221a;
  --surface: #242820;
  --surface-hover: #2a2e25;
  --primary: #7a8c4e;
  --primary-hover: #8a9e58;
  --primary-light: rgba(122, 140, 78, 0.12);
  --primary-border: rgba(122, 140, 78, 0.25);
  --accent: #c99d3a;
  --accent-light: rgba(201, 157, 58, 0.12);
  --error: #c45a5a;
  --error-light: rgba(196, 90, 90, 0.1);
  --error-border: rgba(196, 90, 90, 0.25);
  --success: #5a9e64;
  --success-light: rgba(90, 158, 100, 0.12);
  --warning: #d4a520;
  --warning-light: rgba(212, 165, 32, 0.12);
  --text: #e8e6dd;
  --text-secondary: #b5b3aa;
  --text-muted: #7a7872;
  --text-inverse: #1a1d15;
  --border: #3a3d35;
  --border-light: #2e302a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35), 0 4px 6px rgba(0, 0, 0, 0.2);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 600; }

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

img { max-width: 100%; display: block; }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ===== Shared Components ===== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font-body);
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-danger {
  background: var(--error);
  color: white;
  border-color: var(--error);
}
.btn-danger:hover:not(:disabled) {
  background: #822c2c;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  padding: 0.4rem 0.875rem;
  font-size: 0.825rem;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--radius);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-label .required {
  color: var(--error);
  margin-left: 2px;
}

.form-input,
.form-select {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.925rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input.error,
.form-select.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-light);
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 0.125rem;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-green {
  background: var(--success-light);
  color: var(--success);
}

.badge-yellow {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-red {
  background: var(--error-light);
  color: var(--error);
}

.badge-neutral {
  background: var(--bg-alt);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-alt);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-alt);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* Toasts */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease, fadeOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  max-width: 380px;
}

.toast-success {
  background: var(--success);
  color: white;
}

.toast-error {
  background: var(--error);
  color: white;
}

.toast-info {
  background: var(--primary);
  color: white;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty-state h4 {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 320px;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border-light) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.25rem;
  width: 60%;
  margin-bottom: 0.75rem;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton-row {
  height: 44px;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

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

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

.search-input-wrapper .form-input {
  padding-left: 2.5rem;
}

/* Alert banner */
.alert {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.alert-error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid var(--error);
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

/* KPI card */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.kpi-card .kpi-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.kpi-card .kpi-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.kpi-card .kpi-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h2 {
  margin: 0;
}

/* Category badge colors */
.cat-bible { background: #e8dcc8; color: #6b5b3a; }
.cat-theologie { background: #d4c4e0; color: #4a3570; }
.cat-predication { background: #c8dde0; color: #2d5a60; }
.cat-vie { background: #d0e0c8; color: #3d5a2d; }
.cat-famille { background: #e0cfc8; color: #5a3d2d; }
.cat-jeunesse { background: #c8d8e0; color: #2d455a; }
.cat-temoignages { background: #e0d8c8; color: #5a4d2d; }
.cat-evangelisation { background: #d8e0c8; color: #3d4d2d; }
.cat-culte { background: #d4c4d0; color: #5a2d4a; }
.cat-histoire { background: #c8d4d8; color: #2d3d4a; }
.cat-autre { background: #e0e0e0; color: #4a4a4a; }

[data-theme="dark"] .cat-bible { background: rgba(232, 220, 200, 0.15); color: #d4c8a8; }
[data-theme="dark"] .cat-theologie { background: rgba(212, 196, 224, 0.15); color: #c4b4d8; }
[data-theme="dark"] .cat-predication { background: rgba(200, 221, 224, 0.15); color: #b4ced4; }
[data-theme="dark"] .cat-vie { background: rgba(208, 224, 200, 0.15); color: #bcd4b4; }
[data-theme="dark"] .cat-famille { background: rgba(224, 207, 200, 0.15); color: #d4bcb4; }
[data-theme="dark"] .cat-jeunesse { background: rgba(200, 216, 224, 0.15); color: #b4c8d4; }
[data-theme="dark"] .cat-temoignages { background: rgba(224, 216, 200, 0.15); color: #d4ccb4; }
[data-theme="dark"] .cat-evangelisation { background: rgba(216, 224, 200, 0.15); color: #ccd4b4; }
[data-theme="dark"] .cat-culte { background: rgba(212, 196, 208, 0.15); color: #c8b4c4; }
[data-theme="dark"] .cat-histoire { background: rgba(200, 212, 216, 0.15); color: #b4c4cc; }
[data-theme="dark"] .cat-autre { background: rgba(224, 224, 224, 0.15); color: #c0c0c0; }

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Utility classes ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden { display: none !important; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 0.75rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.w-full { width: 100%; }
