/*
 * BiblioCloud-temat.
 * Klassnamn (.box, .book, .book-content, .book-cover, .book-info,
 * .category-grid, button.primary/.danger/.active-category m.fl.) är
 * medvetet samma som i Lenas ursprungliga prototyp (se
 * LenasMaterial/LenasSite) så att det visuella uttrycket känns igen,
 * men utan Netlify/Supabase-specifika inslag.
 */

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  max-width: 1000px;
  margin: 0 auto;
  padding: 25px;
  background: #f7f7f7;
  color: #222;
}

a {
  color: #2a5f9e;
}

h1 {
  margin-bottom: 5px;
}

h2 {
  margin-top: 30px;
}

h3 {
  margin-bottom: 8px;
}

/* Sidhuvud / navigation */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.site-header .tagline {
  margin: 0;
  color: #555;
}

.site-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.library-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.library-bar select.library-switcher {
  width: auto;
  min-width: 0;
  max-width: 200px;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: transparent;
  color: #777;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.library-bar select.library-switcher:hover,
.library-bar select.library-switcher:focus {
  color: #222;
  border-color: #aaa;
}

.library-bar .library-name {
  color: #888;
  font-size: 0.8rem;
}

.site-nav a {
  display: inline-block;
  line-height: 1.2;
  padding: 8px 12px;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: white;
  text-decoration: none;
  color: #222;
}

.site-nav a:hover,
.site-nav a.current {
  background: #e9f4ff;
  border-color: #7aa7d9;
}

.site-footer {
  margin-top: 40px;
  padding-top: 15px;
  border-top: 1px solid #ddd;
  color: #777;
  font-size: 13px;
}

/* Boxar / formulär, som i originalet */

.box {
  background: white;
  padding: 20px;
  margin: 20px 0;
  border-radius: 10px;
  border: 1px solid #ddd;
}

input,
select {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  margin: 5px 0 10px;
  font-size: 16px;
}

button {
  padding: 9px 14px;
  margin: 4px;
  cursor: pointer;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: white;
}

button:hover {
  background: #eee;
}

button.primary {
  background: #e9f4ff;
  border-color: #7aa7d9;
}

button.danger {
  background: #fff0f0;
  border-color: #d98b8b;
}

button.active-category {
  background: #dfefff;
  border-color: #7aa7d9;
  font-weight: bold;
}

#categories {
  margin: 15px 0 12px;
}

#fact-categories {
  margin: 8px 0 25px;
}

#fact-categories h3 {
  margin: 10px 0 6px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.category-list a {
  display: inline-block;
  padding: 9px 14px;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: white;
  color: #222;
  text-decoration: none;
}

.category-list a:hover {
  background: #eee;
}

.category-list a.active-category {
  background: #dfefff;
  border-color: #7aa7d9;
  font-weight: bold;
}

.site-nav a.current {
  background: #dfefff;
  border-color: #7aa7d9;
  font-weight: bold;
}

/* Böcker */

.book-content {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.book-cover {
  width: 95px;
  max-height: 145px;
  object-fit: contain;
  border-radius: 4px;
  flex: 0 0 auto;
}

.book-info {
  flex: 1;
  min-width: 0;
}

.book-info h3 {
  margin-top: 0;
}

.book {
  position: relative;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.book-card-edit-link {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 5px 10px;
  font-size: 13px;
}

/* Visuell markering för åldersgrupp enligt SAB (Hcf / ,uf = 0–9 år, Hcg / ,ug = 10–12 år) */
.book.age-0-9 {
  border-left: 4px solid #4caf50; /* 0–9 år */
}

.book.age-10-12 {
  border-left: 4px solid #2196f3; /* 10–12 år */
}

.book.age-u {
  border-left: 4px solid #ff9800; /* barn och ungdom, ospecificerat */
}

/* Nyans för faktaböcker */
.book.is-fact {
  background-color: #fcfdfe;
}

.book-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.edit-book-link {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #7aa7d9;
  border-radius: 6px;
  background: #e9f4ff;
  color: #222;
  text-decoration: none;
  font-weight: bold;
  white-space: nowrap;
}

.edit-book-link:hover {
  background: #d6eaff;
}

.book-detail .book-content {
  align-items: flex-start;
}

.book-detail .book-cover,
.book-detail img {
  width: 200px;
  max-height: 300px;
}

.book-description {
  white-space: pre-line;
}

.loan {
  border-bottom: 1px solid #ddd;
  padding: 12px 0;
}

.message {
  margin: 10px 0;
  font-weight: bold;
}

.small {
  font-size: 14px;
  color: #555;
}

.admin-section {
  border-top: 1px solid #ddd;
  margin-top: 20px;
  padding-top: 10px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 14px;
  max-width: 760px;
  margin: 8px 0 14px;
}

.category-grid label {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 5px;
}

.category-grid input[type='checkbox'] {
  width: auto;
  margin: 0;
}

.admin-actions {
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .book-content {
    gap: 10px;
  }

  .book-cover {
    width: 75px;
    max-height: 115px;
  }
}

/* ==========================================================================
   Servicedisk / Personalvy
   ========================================================================== */

.desk-header {
  margin-bottom: 20px;
}

.desk-header h2 {
  margin-top: 0;
  margin-bottom: 4px;
}

.desk-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 12px;
}

.desk-tabs button {
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fdfdfd;
  color: #444;
  cursor: pointer;
  transition: all 0.2s ease;
}

.desk-tabs button:hover {
  background: #eef5ff;
  border-color: #90b8e6;
  color: #1a4d80;
}

.desk-tabs button.active {
  background: #1976d2;
  border-color: #1565c0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(25, 118, 210, 0.3);
}

.desk-panel {
  animation: fadeIn 0.15s ease-in-out;
}

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

.desk-card {
  background: #fafafa;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.desk-quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: #f0f7ff;
  border: 1px solid #cce3ff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 15px;
  align-items: center;
  justify-content: space-between;
}

.quick-block label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.camera-btn {
  background: #fff;
  border: 2px dashed #1976d2;
  color: #1976d2;
  font-weight: bold;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.camera-btn:hover {
  background: #e3effd;
}

.barcode-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.barcode-modal {
  background: #000;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.barcode-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  margin-bottom: 10px;
}

.barcode-modal-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.barcode-modal-close:hover {
  color: #ccc;
  background: transparent;
}

.barcode-modal .small {
  color: #ddd;
  margin: 8px 0 0;
}

.barcode-video {
  width: 100%;
  max-width: 400px;
  border-radius: 6px;
  background: #111;
}

.analyze-btn {
  margin-top: 8px;
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
}

.isbn-candidates-box {
  margin: 10px 0 20px;
  padding: 15px;
  background: #fff8e6;
  border: 1px solid #f0d58c;
  border-radius: 8px;
}

.form-row-split {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.form-col-main {
  flex: 1;
  min-width: 280px;
}

.form-col-side {
  width: 200px;
}

.form-row-inline {
  display: flex;
  gap: 12px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.cover-preview-box {
  width: 100%;
  height: 240px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;
  position: relative;
}

.preview-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.preview-img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.remove-preview-btn {
  margin-top: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

.no-preview {
  text-align: center;
  cursor: pointer;
  padding: 12px;
  color: #888;
}

.no-preview span {
  font-size: 32px;
}

.desk-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  transition: all 0.15s ease;
}

.chip-label:hover {
  background: #f1f5f9;
}

.chip-label input[type='checkbox'] {
  width: auto;
  margin: 0;
}

.chip-label.fact-chip {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.chip-label.fact-chip:hover {
  background: #dcfce7;
}

.desk-alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-weight: 500;
}

.desk-alert.success {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #1b5e20;
}

.desk-alert.error {
  background: #ffebee;
  border: 1px solid #ffcdd2;
  color: #b71c1c;
}

.save-book-btn {
  font-size: 16px;
  padding: 12px 24px;
  background: #2e7d32;
  color: #fff;
  border-color: #1b5e20;
}

.save-book-btn:hover {
  background: #1b5e20;
}

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

.desk-table th,
.desk-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.desk-table th {
  background: #f1f5f9;
  font-weight: 600;
  font-size: 13px;
  color: #475569;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge.active-badge {
  background: #e0f2fe;
  color: #0369a1;
}

/* SAB-information (servicedisk + detaljsida) */
.sab-breadcrumb,
.sab-secondary {
  display: block;
  margin-top: 4px;
  color: #5f6b7a;
  font-size: 0.85em;
}

.sab-info strong {
  font-family: ui-monospace, Consolas, monospace;
}
