/* LabelMaker application styles. Bootstrap does the heavy lifting; keep this file small. */

:root {
    --lm-sidebar-width: 250px;
}

/* The hidden attribute must always win. Bootstrap utilities like .d-flex use display: ... !important and
   would otherwise keep elements visible that scripts hide (wizard spirit search, editor image card). */
[hidden] {
    display: none !important;
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--lm-sidebar-width);
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;  /* lets the admin group sit at the bottom (mt-auto) */
    background-color: var(--bs-tertiary-bg);
    border-right: 1px solid var(--bs-border-color);
    transition: transform 0.2s ease-in-out;
}

#main-content {
    margin-left: var(--lm-sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.2s ease-in-out;
}

body.sidebar-hidden #sidebar {
    transform: translateX(-100%);
}

body.sidebar-hidden #main-content {
    margin-left: 0;
}

.sidebar-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--bs-body-color);
    text-decoration: none;
    border-bottom: 1px solid var(--bs-border-color);
}

.sidebar-heading {
    padding: 1rem 1rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.sidebar-link-sm {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    font-size: 0.875rem;
    border-bottom: none;
}

.sidebar-admin {
    border-top: 1px solid var(--bs-border-color);
}

.sidebar-link:hover {
    background-color: var(--bs-secondary-bg);
}

.sidebar-link.active {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    border-left: 3px solid var(--bs-primary);
}

/* Colour picker next to a text field */
input[type="color"].form-control-color {
    width: 80px;
    height: 38px;
    padding: 2px;
}

/* htmx: dim content while a request is in flight */
.htmx-request.htmx-dim,
.htmx-request .htmx-dim {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Label preview: checkerboard-free neutral frame, preview scales to the column width */
.label-preview svg,
.label-preview img {
    max-width: 100%;
    height: auto;
    box-shadow: 0 0 0 1px var(--bs-border-color);
    background: #fff;
}

/* Sortable tables (see app.js) */
th.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable-header:hover {
    background-color: var(--bs-secondary-bg);
}

/* Label size preview (templatetags/labels.py size_preview): one scale for all sizes */
.size-preview {
    vertical-align: middle;
    flex-shrink: 0;
}

/* The size preview uses the theme's contrast colour (info), so it stands apart from the orange primary. */
.size-preview rect {
    fill: rgba(var(--bs-info-rgb), 0.18);
    stroke: var(--bs-info);
    stroke-width: 1.2;
}

.format-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.format-chip.customer-only {
    opacity: 0.65;
}

/* Customer templates are listed after the own brand and shown a little quieter */
tr.customer-template td {
    color: var(--bs-secondary-color);
}

.btn-primary .size-preview rect {
    fill: rgba(255, 255, 255, 0.25);
    stroke: #fff;
}


/* ---------------------------------------------------------------- mobile (below Bootstrap's lg breakpoint)
   The sidebar becomes an off-canvas overlay opened by the menu button; the content gets the full width. */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    #sidebar {
        z-index: 1045;
        transform: translateX(-100%);
        box-shadow: 0 0 1.5rem rgba(0, 0, 0, 0.25);
    }

    body.sidebar-open #sidebar {
        transform: none;
    }

    #main-content {
        margin-left: 0;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, 0.4);
    }

    /* Format quick filter: one swipeable row instead of a tall column of buttons */
    .format-chips {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .format-chips > * {
        flex-shrink: 0;
    }

    main.container-fluid {
        padding-top: 1rem !important;
    }

    h1.h2 {
        font-size: 1.5rem;
    }
}
