/* ---------- Theme Variables ---------- */
:root {
  --green-primary: #004225;      /* British racing green */
  --green-dark: #013220;         /* Darker header / text green */
  --green-light: #2f6f4e;        /* Hover / lighter green */
  --accent-gold: #c2a878;        /* Soft brass/gold */
  --accent-gold-dark: #a48a5d;   /* Darker gold for borders */
  --bg-cream: #f2f1e8;           /* Page background */
  --bg-card: #fffdf7;            /* Card backgrounds */
  --text-main: #222222;          /* Primary text */
  --text-muted: #555555;         /* Muted text */
}

/* ---------- Global Styles ---------- */
body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg-cream);
  color: var(--text-main);
  margin: 0;
}

header {
  background: linear-gradient(135deg, var(--green-dark), var(--green-primary));
  color: #fff;
  padding: 1em;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

footer {
  text-align: center;
  background: var(--green-dark);
  color: #fdf7e6;
  padding: 0.5em;
}

/* ---------- Universal Add Form (shared by Add Book, Add Location, etc.) ---------- */
.add-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.8em;
  background: var(--bg-card);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 1em 1.5em;
  margin: 1.5em auto;
  max-width: 600px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.add-form input[type="text"],
.add-form select {
  flex: 1 1 200px;
  min-width: 200px;
  max-width: 260px;
  padding: 0.6em 1em;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  font-size: 1em;
  background: #fff;
  box-sizing: border-box;
}

.add-form input[type="text"]:focus,
.add-form select:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 2px rgba(0,66,37,0.15);
}

.add-form button {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.7em 1.4em;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.3s, transform 0.1s;
}

.add-form button:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

/* ---------- Centered Form Heading ---------- */
.add-heading {
  text-align: center;
  font-family: 'Georgia', serif;
  font-size: 1.6em;
  color: var(--green-dark);
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  letter-spacing: 0.5px;
}

/* ---------- Book & Location Cards ---------- */
/* This grid is ONLY for the book cards inside a shelf */
.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1em;
  padding: 1em;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dark);
  padding: 1em;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.book-card img {
  display: block;
  margin: 0 auto 0.5em;
  max-height: 180px;
  max-width: 100%;
  height: auto;
}

.book-card p {
  margin: 0.3em 0;
}

.book-card form {
  margin-top: 0.3em;
}

/* ---------- Rooms & Shelves ---------- */

/* Room wrapper */
.location-group {
  margin: 1em auto;
  max-width: 1000px;
}

/* Room title bar */
.location-group h2 {
  background: var(--green-primary);
  color: #fff;
  padding: 0.4em 0.6em;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 1em;       /* separation from first shelf */
}

.location-group h2 a {
  color: #fff;
  text-decoration: none;
}

/* Shelf list inside each room (holds shelf accordions in a column) */
.shelf-list {
  display: block;
  margin-top: 0.5em;
  padding: 0;               /* shelf cards handle spacing */
}

/* Each shelf = its own card */
.shelf-group {
  display: block;
  width: 100%;
  margin: 0 0 0.9em;        /* space between shelf cards */
  padding: 0.35em 0.45em;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  box-sizing: border-box;
}

/* ---------- Buttons ---------- */
.btn-small,
button.btn-small {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  text-decoration: none;
  margin: 0.2em;
  display: inline-block;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95em;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-small:hover,
button.btn-small:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

.btn-small:active,
button.btn-small:active {
  background: var(--green-dark);
  transform: translateY(0);
}

.danger {
  background: #a62828;
}

.danger:hover {
  background: #7b1d1d;
}

.btn-large {
  background: var(--green-primary);
  color: #fff;
  padding: 1em 1.4em;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
}

.btn-large:hover {
  background: var(--green-light);
}

/* Move dialog layout */
#moveDialog {
  border: none;
  border-radius: 0.75rem;
  padding: 0;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

/* body of the dialog already has padding via inline style on the form */

.move-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.move-field label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.move-field select,
.move-field input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1px solid #c9c3b4;
}

.move-field select:focus,
.move-field input:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 2px rgba(0,66,37,0.15);
}

.move-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Dashboard Layout ---------- */
.dashboard {
  text-align: center;
  margin: 2em auto;
  max-width: 800px;
}

.dash-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1em;
  margin-top: 1.5em;
  margin-bottom: 2.5em;
}

/* ---------- Barcode & Book Detail ---------- */
.barcode-box {
  text-align: center;
  margin: 1.5em 0;
}

.barcode-box img {
  display: inline-block;
  max-width: 100%;
  height: auto;
}

.book-detail {
  text-align: center;
  padding: 1em;
}

.book-detail img {
  margin: 1em 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.barcode-location {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 0.5em;
  letter-spacing: 1px;
}

/* ---------- Collapsible Sections ---------- */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
  color: #fff;
  padding: 0.6em 1em;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0;            /* sits flush inside shelf card */
}

.collapsible-header a {
  color: #fff;
  text-decoration: none;
}

.collapsible-header:hover {
  background: var(--green-light);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2em;
  cursor: pointer;
  transition: transform 0.2s ease;
}

/* Apply collapsible behaviour to BOTH shelf-list and book-list containers */
.collapsible-content {
  margin-top: 0.8em;
  overflow: hidden;
  max-height: none;
  opacity: 1;
  transition: opacity 0.25s ease-in-out;
}

.collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  pointer-events: none;
}

.collapse-controls {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-bottom: 1.5em;
}

.collapse-controls .btn-small {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.1s;
}

.collapse-controls .btn-small:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

.collapse-controls .btn-small.danger {
  background: #a33;
}

.collapse-controls .btn-small.danger:hover {
  background: #c44;
}

/* ---------- Charts ---------- */
#booksChart {
  background: #f9f6f2;
  border-radius: 8px;
  padding: 1em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ---------- Dashboard Buttons ---------- */
.dashboard-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1em;
  margin-top: 1.5em;
  margin-bottom: 2.5em;
}

.dashboard-buttons .btn,
.btn-large {
  display: inline-block;
  padding: 1em 1.4em;
  background: var(--green-primary);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: background 0.3s ease, transform 0.2s ease;
}

.dashboard-buttons .btn:hover,
.btn-large:hover {
  background: var(--green-light);
  transform: translateY(-2px);
}

/* Universal form card + stack (use on Add Manual + Edit) */
.form-card {
  max-width:520px;
  margin:2em auto;
  padding:1.2em 1.4em;
  background:var(--bg-card);
  border:1px solid var(--accent-gold-dark);
  border-radius:12px;
  box-shadow:0 2px 6px rgba(0,0,0,.1);
}
.form-stack {
  display:flex;
  flex-direction:column;
  gap:.9em;
}
.form-stack label {
  font-weight:600;
  color:var(--green-dark);
}
.form-stack input[type="text"],
.form-stack select {
  width:100%;
  padding:.6em;
  border:1px solid #c9c3b4;
  border-radius:6px;
  box-sizing:border-box;
  background:#fff;
}
.form-stack input[type="text"]:focus,
.form-stack select:focus {
  outline:none;
  border-color:var(--green-primary);
  box-shadow:0 0 0 2px rgba(0,66,37,0.15);
}
.form-stack button {
  display:block;
  width:100%;
  padding:.8em;
  background:var(--green-primary);
  color:#fff;
  border:none;
  border-radius:8px;
  cursor:pointer;
  transition:background .2s ease, transform 0.1s;
}
.form-stack button:hover {
  background:var(--green-light);
  transform: translateY(-1px);
}

/* Base style for smaller action buttons (kept for compatibility) */
.btn-small {
  display: inline-block;
  padding: 0.5em 1em;
  background-color: var(--green-primary);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-small:hover {
  background-color: var(--green-light);
  transform: translateY(-1px);
}

.btn-small:active {
  background-color: var(--green-dark);
  transform: translateY(0);
}

/* Optional: add icon space if using "+" or emojis */
.btn-small::before {
  content: "";
  margin-right: 0.2em;
}

.btn-small.center {
  display: block;           /* Makes it take its own line */
  margin: 1em auto;         /* Centers horizontally */
  text-align: center;       /* Ensures text is centered inside */
  width: fit-content;       /* Keeps it from stretching too wide */
}
