/* =========================================================
   Biblioteca Municipal — Custom CSS
   ========================================================= */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 56px;
  --primary: #1a3a5c;
  --primary-light: #2c5f8a;
  --primary-hover: #0f2540;
  --accent: #e8a020;
  --success: #198754;
  --danger: #dc3545;
  --warning: #ffc107;
  --bg-page: #f0f4f8;
  --sidebar-text: rgba(255,255,255,0.85);
  --sidebar-text-hover: #ffffff;
  --sidebar-section: rgba(255,255,255,0.4);
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: #2d3748;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--primary);
  display: flex;
  flex-direction: column;
  transition: width .25s ease;
  z-index: 1040;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--topbar-height);
  background: var(--primary-hover);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-brand i { font-size: 1.3rem; flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--sidebar-section);
  padding: 14px 20px 4px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity .2s;
}

.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-link span { opacity: 0; width: 0; overflow: hidden; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.sidebar-nav .nav-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: .95rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.1); color: var(--sidebar-text-hover); }
.sidebar-nav .nav-link.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ── Main content ──────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--topbar-height);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.sidebar-toggle { color: #fff !important; padding: 6px 10px; }
.topbar-title { flex: 1; font-size: 1rem; font-weight: 600; color: #fff; }
.topbar-right { margin-left: auto; }

/* ── Flash ─────────────────────────────────────────── */
.flash-container { padding: 12px 20px 0; }
.flash-container .alert { border-radius: var(--radius); font-size: .875rem; }

/* ── Page content ──────────────────────────────────── */
.page-content { flex: 1; padding: 24px 24px 40px; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 20px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--primary);
}

/* ── Stat cards ────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.16); color: #fff; }

.stat-card .stat-icon {
  width: 54px; height: 54px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .88; margin-top: 2px; }

.bg-stat-blue    { background: linear-gradient(135deg, #1a3a5c, #2c5f8a); }
.bg-stat-green   { background: linear-gradient(135deg, #155724, #198754); }
.bg-stat-orange  { background: linear-gradient(135deg, #7a4800, #e8a020); }
.bg-stat-red     { background: linear-gradient(135deg, #7d1421, #dc3545); }

/* ── Page header ───────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Tables ────────────────────────────────────────── */
.table th {
  background: var(--primary);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .4px;
  border: none;
  white-space: nowrap;
  padding: 10px 14px;
}

.table td {
  vertical-align: middle;
  padding: 10px 14px;
  font-size: .875rem;
  border-color: #e9ecef;
}

.table tbody tr:hover { background: #f7f9fc; }
.table-responsive { border-radius: var(--radius); overflow: hidden; }

/* ── Badges ────────────────────────────────────────── */
.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge-disponivel  { background: #d1fae5; color: #065f46; }
.badge-ativo       { background: #dbeafe; color: #1e40af; }
.badge-atrasado    { background: #fee2e2; color: #991b1b; }
.badge-devolvido   { background: #f3f4f6; color: #374151; }
.badge-indisponivel{ background: #fef3c7; color: #92400e; }
.badge-manutencao  { background: #ede9fe; color: #5b21b6; }
.badge-extraviado  { background: #fee2e2; color: #991b1b; }

/* ── Forms ─────────────────────────────────────────── */
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
}

.form-control, .form-select {
  border-color: #cbd5e0;
  border-radius: 7px;
  font-size: .875rem;
  padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(44,95,138,.15);
}

.form-section-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary-light);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 4px;
  margin: 20px 0 14px;
}

/* ── Buttons ───────────────────────────────────────── */
.btn { border-radius: 7px; font-size: .875rem; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

/* ── Login page ────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, #3a7fc1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  width: 72px; height: 72px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 15px rgba(26,58,92,.4);
}

.login-logo .logo-icon i { font-size: 1.9rem; color: #fff; }
.login-logo h4 { color: var(--primary); font-weight: 700; font-size: 1.2rem; margin: 0; }
.login-logo p { color: #6b7280; font-size: .85rem; margin: 3px 0 0; }

/* ── Quick actions ─────────────────────────────────── */
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  transition: transform .15s, box-shadow .15s;
  color: #fff;
}

.quick-action-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.15); color: #fff; }
.quick-action-btn i { font-size: 1.6rem; }

/* ── Search bar ────────────────────────────────────── */
.search-box { position: relative; }
.search-box .form-control { padding-left: 38px; }
.search-box .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #9ca3af; font-size: .85rem;
}

/* ── Autocomplete dropdown ─────────────────────────── */
.autocomplete-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,.1);
  z-index: 1000;
  max-height: 280px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: .85rem;
  border-bottom: 1px solid #f3f4f6;
  transition: background .1s;
}

.autocomplete-item:hover { background: #f0f4f8; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item .ac-title { font-weight: 600; color: var(--primary); }
.autocomplete-item .ac-sub { color: #6b7280; font-size: .8rem; }

/* ── Book cover preview ────────────────────────────── */
.cover-preview {
  width: 100px; height: 140px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}

.cover-placeholder {
  width: 100px; height: 140px;
  background: #e9ecef;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #adb5bd;
  font-size: 2rem;
}

/* ── Pagination ────────────────────────────────────── */
.pagination .page-link {
  color: var(--primary);
  border-radius: 6px !important;
  margin: 0 2px;
  font-size: .85rem;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 16px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 1.5rem; }
}

/* ── Empty state ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
}

.empty-state i { font-size: 3.5rem; display: block; margin-bottom: 16px; opacity: .5; }
.empty-state p { font-size: 1rem; margin: 0; }

/* ── Info box ──────────────────────────────────────── */
.info-box {
  background: #f0f4f8;
  border-left: 4px solid var(--primary-light);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  font-size: .85rem;
}
