:root {
    color-scheme: light;

    /* Warm, leather/library accent replacing Bootstrap's default blue — fitting for
       a book catalog, applied narrowly (primary accent only) to stay clean and sharp
       rather than turning into a themed/decorated UI. Bootstrap 5.3's compiled CSS
       hardcodes most component colors rather than deriving them from --bs-primary, so
       the handful of components this app actually uses are retargeted individually
       below instead of relying on a single root override to cascade everywhere. */
    --bs-primary: #6d2932;
    --bs-primary-rgb: 109, 41, 50;
    --bs-link-color: #6d2932;
    --bs-link-color-rgb: 109, 41, 50;
    --bs-link-hover-color: #4a1b22;
    --bs-link-hover-color-rgb: 74, 27, 34;
}

body {
    min-height: 100vh;
}

h1, h2, h3, .navbar-brand {
    font-family: Georgia, 'Times New Roman', 'Liberation Serif', serif;
}

.navbar-brand {
    font-weight: 600;
    display: flex;
    align-items: center;
    min-width: 0;
    flex-shrink: 1;
}

.brand-icon {
    width: 1.3em;
    height: 1.3em;
    vertical-align: -0.28em;
    margin-right: 0.35rem;
    flex-shrink: 0;
}

.navbar-brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Bootstrap's default .navbar > .container is flex-wrap: wrap, which is exactly why a
   long custom site name pushed the hamburger toggle onto its own row below the brand.
   Keeping the row nowrap and letting the brand text itself shrink/truncate (above)
   means the brand and the toggler always share one line, at any site-name length. */
.navbar > .container {
    flex-wrap: nowrap;
}

.navbar-toggler {
    flex-shrink: 0;
}

/* At the md breakpoint the collapse becomes a horizontal row of several items (admin
   link, user name, account link, logout, language switcher) — with a long site name
   eating into the available width that row can get tight right at 768px. Prevent
   individual multi-word labels from breaking mid-phrase; if the row still needs to
   wrap, it wraps whole items rather than splitting a label across two lines. */
@media (min-width: 768px) {
    .navbar-collapse .nav-link,
    .navbar-collapse .text-body-secondary,
    .navbar-collapse .btn {
        white-space: nowrap;
    }

    .navbar-collapse {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }
}

@media (max-width: 400px) {
    .navbar-brand {
        font-size: 1.05rem;
    }
}

.btn-primary {
    --bs-btn-bg: #6d2932;
    --bs-btn-border-color: #6d2932;
    --bs-btn-hover-bg: #58212a;
    --bs-btn-hover-border-color: #4a1b22;
    --bs-btn-active-bg: #4a1b22;
    --bs-btn-active-border-color: #401820;
    --bs-btn-disabled-bg: #6d2932;
    --bs-btn-disabled-border-color: #6d2932;
    --bs-btn-focus-shadow-rgb: 109, 41, 50;
}

.form-control:focus,
.form-select:focus {
    border-color: #b08d95;
    box-shadow: 0 0 0 0.25rem rgba(109, 41, 50, 0.25);
}

.form-check-input:checked {
    background-color: #6d2932;
    border-color: #6d2932;
}

.form-check-input:focus {
    border-color: #b08d95;
    box-shadow: 0 0 0 0.25rem rgba(109, 41, 50, 0.25);
}

.pagination {
    --bs-pagination-active-bg: #6d2932;
    --bs-pagination-active-border-color: #6d2932;
    --bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(109, 41, 50, 0.25);
}

/* Utility classes replacing inline style="" attributes, which a strict
   style-src 'self' CSP (no 'unsafe-inline') would otherwise silently block. */
.cover-thumb-cell {
    width: 48px;
}

.img-cover {
    object-fit: cover;
}

.notes-text {
    white-space: pre-wrap;
}

.other-book-thumb-wrap {
    width: 120px;
}

.gallery-thumb {
    aspect-ratio: 1;
    object-fit: cover;
}

.settings-name-input {
    max-width: 320px;
}

.settings-logo-preview {
    max-width: 240px;
    max-height: 120px;
    object-fit: contain;
}

.settings-favicon-preview {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.login-logo {
    max-width: 220px;
    max-height: 120px;
    object-fit: contain;
}

.login-fallback-icon svg {
    width: 3rem;
    height: 3rem;
    color: #6d2932;
}

.empty-state-icon svg {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.5rem;
}

.category-picker-menu {
    min-width: 280px;
    max-width: 100%;
}

.category-picker-list {
    max-height: 260px;
    overflow-y: auto;
}

.category-picker-expanded .category-picker-panel {
    background-color: var(--bs-tertiary-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.75rem;
}

.category-picker-expanded .category-picker-list {
    max-height: none;
    overflow: visible;
    display: grid;
    /* Grid (not flex-wrap) so every row shares the same column tracks — a long
       label in one row no longer pushes that row's checkboxes out of alignment
       with the rows above/below it. auto-fill + minmax also collapses to fewer
       columns on narrow viewports on its own, no extra breakpoint needed. */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.25rem 1.5rem;
}

.category-picker-expanded .category-picker-list .form-check {
    /* Allow the label to wrap inside its own column instead of overflowing it. */
    min-width: 0;
}

.suggest-item-rich {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

.suggest-thumb-wrap {
    width: 32px;
    height: 44px;
}

.suggest-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.15rem;
}

/* Search action row: Szukaj / Wyczyść / (mobile) Filtry — must stay on one line even
   on a 360px phone, so on narrow screens the buttons share the row evenly instead of
   wrapping onto a staggered second line. */
.search-actions {
    flex-wrap: nowrap;
}

@media (max-width: 575.98px) {
    .search-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.9rem;
    }
}

/* Book show page: title/author must dominate, not compete with the action buttons for
   space — so actions live in their own wrapped row below, never squeezed beside the
   heading. */
.book-actions .btn {
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .book-cover-wrap {
        text-align: center;
    }

    .book-cover-img {
        max-width: 180px;
        margin-left: auto;
        margin-right: auto;
    }
}

.book-field-label {
    color: var(--bs-secondary-color);
    margin-right: 0.35em;
}

.row-actions {
    margin-left: auto;
    width: 90px;
}

.no-cover-thumb {
    object-fit: cover;
    background-color: var(--bs-tertiary-bg);
}

.audit-log-metadata {
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.error-log-content {
    max-height: 70vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
