/* Application components. Colours come from Tabler variables so both colour schemes work. */

/* Focus: always visible for keyboard users. */
:focus-visible {
    outline: 2px solid var(--tblr-primary);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -4rem;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background: var(--tblr-bg-surface);
    border-radius: var(--tblr-border-radius);
}

.skip-link:focus {
    top: 0.5rem;
}

.text-accent {
    color: var(--tblr-primary);
}

.border-accent {
    border-color: var(--tblr-border-color) !important;
}

/* Sidebar */
.navbar-vertical .nav-section-title {
    padding: 1rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tblr-secondary);
}

.navbar-vertical .nav-link {
    position: relative;
    border-radius: var(--tblr-border-radius);
}

.navbar-vertical .nav-link {
    color: var(--tblr-body-color);
}

.navbar-vertical .nav-link:hover {
    background-color: var(--tblr-bg-surface-secondary);
}

.navbar-vertical .nav-link.active {
    background-color: var(--diskur-accent-soft);
    color: var(--diskur-accent);
    font-weight: 600;
}

.navbar-vertical .nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background-color: var(--diskur-accent);
}

@media (min-width: 992px) {
    .navbar-vertical .navbar-brand {
        display: flex;
        align-items: center;
        width: 100%;
        height: var(--diskur-header-height);
        margin: 0;
        padding: 0 1.25rem;
    }

    /* The brand stays put; only the menu scrolls, with a thin bar that never narrows the header. */
    .navbar-vertical.navbar-expand-lg {
        overflow: hidden;
    }

    .navbar-vertical.navbar-expand-lg > .container-fluid {
        height: 100%;
        min-height: 0;
        padding: 0;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .navbar-vertical.navbar-expand-lg .navbar-collapse {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0 0.75rem 1rem;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--diskur-chrome-border) transparent;
    }
}

@media (max-width: 991.98px) {
    .navbar-vertical {
        border-right: 0;
        border-bottom: 1px solid var(--diskur-chrome-border);
    }

    .navbar-vertical > .container-fluid {
        min-height: var(--diskur-header-height);
    }
}

/* Top bar */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--diskur-header-height);
    padding: 0 1rem;
    background-color: var(--diskur-chrome-bg);
}

.app-topbar-breadcrumbs {
    flex: 1 1 0;
    min-width: 0;
}

.app-topbar-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 28rem;
}

.app-topbar-search .ti-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tblr-secondary);
    pointer-events: none;
}

.app-topbar-search .form-control {
    padding-left: 2.25rem;
    padding-right: 2.25rem;
    background-color: var(--tblr-bg-surface-secondary);
}

.app-topbar-search kbd {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.app-topbar-search .form-control:focus + kbd {
    display: none !important;
}

.app-topbar-suggestions {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 1040;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    max-height: min(26rem, 70vh);
    overflow-y: auto;
    background-color: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    box-shadow: var(--tblr-box-shadow-dropdown, 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2));
}

.app-topbar-suggestions[hidden] {
    display: none;
}

.app-topbar-suggestion a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--tblr-border-radius);
    color: var(--tblr-body-color);
    text-decoration: none;
}

.app-topbar-suggestion[aria-selected="true"] a {
    background-color: var(--tblr-primary-lt);
    box-shadow: inset 3px 0 0 var(--tblr-primary);
}

.app-topbar-suggestion-cover {
    flex: 0 0 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    border-radius: 0.25rem;
    background-color: var(--tblr-bg-surface-secondary);
    color: var(--tblr-secondary);
}

.app-topbar-suggestion-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar-suggestion-text > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-topbar-suggestion-text small {
    color: var(--tblr-secondary);
}

.app-topbar-actions {
    flex: 1 1 0;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

@media (min-width: 992px) {
    .app-topbar {
        padding: 0 1.5rem;
    }

    /* One line across the sidebar header and the top bar, so the two can never drift apart. */
    .page-wrapper::before {
        content: "";
        position: fixed;
        top: calc(var(--diskur-header-height) - 1px);
        left: 0;
        right: 0;
        height: 1px;
        background-color: var(--diskur-chrome-border);
        z-index: 1031;
        pointer-events: none;
    }
}

@media (max-width: 991.98px) {
    .app-topbar {
        position: static;
        height: auto;
        padding: 0.5rem 1rem;
        border-bottom: 1px solid var(--diskur-chrome-border);
    }

    .app-topbar-search {
        max-width: none;
    }
}

.navbar-vertical .nav-link-sub {
    padding-left: 2.25rem;
}

/* Collection */
.record-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.record-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tblr-box-shadow);
}

.record-cover {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    width: 100%;
    background-color: var(--tblr-bg-surface-secondary);
}

.record-thumb {
    width: 2.75rem;
    height: 2.75rem;
    flex: none;
    object-fit: cover;
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface-secondary);
}

[data-view-toggle-view="list"] .collection-grid,
[data-view-toggle-view="grid"] .collection-list {
    display: none;
}

.stat-card .col {
    min-width: 0;
}

.stat-card-footer {
    display: flex;
    align-items: center;
    min-height: 3.25rem;
}

.stat-card-footer .form-select {
    width: 100%;
}

.stat-detail {
    min-height: 1.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}

/* Legacy screens: map the old dark-only classes onto the active colour scheme. */
.custom-card {
    background-color: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg);
}

.custom-create {
    border: 2px dashed var(--tblr-primary);
    border-radius: var(--tblr-border-radius-lg);
}

.custom-create:hover {
    background-color: var(--diskur-accent-soft);
}

.text-light {
    color: inherit !important;
}

.bg-dark {
    background-color: var(--tblr-bg-surface-secondary) !important;
}

.btn-outline-light {
    --tblr-btn-color: var(--tblr-body-color);
    --tblr-btn-border-color: var(--tblr-border-color);
    --tblr-btn-hover-color: var(--tblr-body-color);
    --tblr-btn-hover-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-hover-border-color: var(--tblr-border-color-active);
    --tblr-btn-active-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-active-color: var(--tblr-body-color);
}

.btn-close-white {
    filter: none;
}

[data-bs-theme="dark"] .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.table-dark {
    --tblr-table-color: var(--tblr-body-color);
    --tblr-table-bg: transparent;
    --tblr-table-border-color: var(--tblr-border-color);
}

.cover-upload .cover-preview {
    width: 220px;
    max-width: 100%;
    height: auto;
}

.cover-upload .dropzone-container {
    min-height: 140px;
    border-color: var(--tblr-primary);
    background-color: var(--tblr-bg-surface-secondary);
}

.cover-upload .dropzone-placeholder {
    color: var(--tblr-secondary);
}

.discogs-search-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.discogs-search-results {
    min-height: 0;
}

/* Tom Select follows the form control look of the active colour scheme. */
.ts-wrapper.form-control,
.ts-wrapper.form-select {
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.ts-control,
.ts-dropdown {
    background-color: var(--tblr-bg-forms);
    border: 1px solid var(--tblr-border-color);
    color: var(--tblr-body-color);
    border-radius: var(--tblr-border-radius);
}

.ts-control input {
    color: var(--tblr-body-color);
}

.ts-wrapper.focus .ts-control {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--tblr-primary-rgb), 0.25);
}

.ts-dropdown .option {
    color: var(--tblr-body-color);
}

.ts-dropdown .active {
    background-color: var(--diskur-accent-soft);
    color: var(--tblr-body-color);
}

.ts-control .item {
    background-color: var(--tblr-primary) !important;
    border: 1px solid var(--tblr-primary) !important;
    color: var(--tblr-primary-fg) !important;
}

.ts-control .item .remove {
    color: inherit !important;
    border-left-color: rgba(255, 255, 255, 0.3) !important;
}

@media (prefers-reduced-motion: reduce) {
    .record-card {
        transition: none;
    }
}

/* Sidebar library list: buttons look like links and long lists scroll */
.sidebar-libraries {
    max-height: 14rem;
    overflow-y: auto;
}

.sidebar-libraries .nav-link {
    background: none;
    border: 0;
}

.sidebar-libraries .nav-link.active {
    background-color: rgba(var(--diskur-accent-rgb), 0.28);
}

/* Reference data: indent for styles and rotating chevron */
.ps-6 {
    padding-left: 3.5rem !important;
}

[data-reference-filter-target="group"].is-open .ti-chevron-right {
    transform: rotate(90deg);
}
