/* Better grid management for project cards */



/* Carousel container - aligned to the right on desktop */

@media (min-width: 992px) {
    .project-actions-row {
        grid-template-columns: repeat(3, auto) 1fr;
    }
    
    .carousel-container {
        grid-column: 4 / 5;
        margin-top: 0;
        justify-self: end;
    }
}

.carousel {
    max-width: 300px;
    width: 100%;
}

.carousel-item img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
}

.modal-form-group {
    display: grid;
    gap: 15px;
    margin-bottom: 15px;
}

.breadcrumb-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

@media (max-width: 576px) {
    .breadcrumb-header {
        grid-template-columns: 1fr;
    }

    .breadcrumb-header .btn {
        width: 100%;
    }

    .project-actions-row {
        grid-template-columns: 1fr;
    }

    .carousel {
        max-width: 100%;
    }
}

.card-body {
    padding: 1.5rem;
}

.list-unstyled {
    padding: 0;
    margin: 0;
}

.carousel-item ul {
    margin: 0;
}

/* ── Project cards ────────────────────────────────────────────────────────
   Previously a 3px blue border with large buttons, which made a list of a
   dozen projects very tall. Lighter frame, tighter spacing, smaller actions. */
.project-card {
    border: 1px solid #e3e6ea;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Only a card whose title is a .stretched-link is actually one big click
   target. The same frame is reused for the panels on the edit, sharing and
   report pages, where nothing but the buttons inside is clickable — there a
   hand cursor over the whole panel (the QR code tiles above all) promises a
   click that does nothing. */
.project-card:has(.stretched-link) {
    cursor: pointer;   /* the whole card opens the project */
}

.project-card:hover {
    border-color: #cfd9e6;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
}

.project-card:has(.stretched-link):hover .project-card-title {
    text-decoration: underline;
}

/* Keyboard users get the same outline they would get on a plain link. */
.project-card:focus-within {
    border-color: #1e7cec;
    box-shadow: 0 0 0 0.2rem rgba(30, 124, 236, 0.2);
}

/* The badges are not interactive, so let the card's link take clicks there. */
.project-card-badges {
    position: static;
}

.project-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f7f9fc;
    border-bottom: 1px solid #e9edf2;
    padding: 0.6rem 1rem;
}

.project-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: #1e7cec;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card-title:hover {
    text-decoration: underline;
}

/* How many of the five allowed QR codes the project has. */
.project-card-count {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: #6c757d;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 999px;
    padding: 2px 10px;
}

.project-card .card-body {
    padding: 1rem;
}

.project-card-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
}

.project-card .project-actions-row {
    gap: 8px;
    margin-bottom: 0;
}

/* QR thumbnails: a light frame instead of a 3px black box. */
.qr-thumb {
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    background: #fff;
}

.qr-thumb .qr-missing {
    color: #adb5bd;
    font-size: 0.8rem;
    margin: 0;
    padding: 1.5rem 0.5rem;
    text-align: center;
}

.project-card .carousel {
    max-width: 190px;
}

.project-card .carousel-item img {
    max-height: 190px;
}

@media (max-width: 767.98px) {
    .project-card-header {
        padding: 0.5rem 0.75rem;
    }

    .project-card .card-body {
        padding: 0.75rem;
    }

    .project-card .carousel {
        max-width: 100%;
    }
}


/* ── QR codes on the project edit page ────────────────────────────────── */
.qr-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.qr-edit-item {
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    background: #fff;
}

.qr-edit-item img {
    width: 100%;
    height: auto;
    max-width: 150px;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.qr-edit-meta {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
}

@media (max-width: 575.98px) {
    .qr-edit-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }
}


/* ── Search ───────────────────────────────────────────────────────────── */
.project-search {
    margin-bottom: 1.25rem;
}

.search-summary {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: #6c757d;
}

/* ── Compact project cards ────────────────────────────────────────────────
   The cards used to embed a QR carousel, which made each one ~280px tall so
   barely one and a half fitted on screen. QR codes are managed on the project
   edit page now, so the card only needs a summary and its actions. */
/* A grid rather than a stack: on a wide screen several projects fit across,
   and each card carries its own actions instead of hiding them a page away. */
.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 0.9rem;
    align-items: start;
}

.project-list > li {
    min-width: 0;    /* long titles must ellipsis, not widen the column */
}

.project-list > li > .project-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-card .card-body.project-card-body {
    padding: 0.75rem 1rem;
}

.project-card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.project-card-description {
    color: #6c757d;
    font-size: 0.875rem;
    margin: 0 0 0.6rem;
    /* One line only: the full text is on the project page. */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    /* The card title is a stretched link covering the whole card, so these
       have to sit above it or every button would just open the edit page.
       The row spans the full width, though, so only the controls themselves
       take clicks — the empty space beside them falls through to the card. */
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.project-card-actions > * {
    pointer-events: auto;
}

/* Remove is a <button> inside a <form> while Edit and Stats are plain <a>.
   The form is the flex item, so it has to carry the same sizing as the
   anchors — otherwise the two kinds of control end up different heights and
   widths once they stretch on a phone. */
.project-card-actions form {
    margin: 0;
    display: flex;
}

.project-card-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    white-space: nowrap;
    line-height: 1.5;
}

.empty-state {
    text-align: center;
    color: #6c757d;
    border: 1px dashed #dee2e6;
    border-radius: 10px;
    padding: 2rem 1rem;
}

@media (max-width: 575.98px) {
    /* The labelled actions share the width; the icon-only delete stays at its
       natural size rather than being given an equal column, which pushed it
       onto a row of its own. min-width:0 is what lets them shrink: a flex item
       will not go below its content width without it. */
    .project-card-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .project-card-actions > .btn,
    .project-card-actions > form {
        flex: 1 1 0;
        min-width: 0;
    }

    /* The delete form, which holds only an icon. */
    .project-card-actions > form:last-child {
        flex: 0 0 auto;
    }

    .project-card-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .project-card-actions .btn {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }

    .project-card-description {
        -webkit-line-clamp: 2;
    }
}


/* ── Sharing ──────────────────────────────────────────────────────────── */
.share-list { margin: 0 0 1rem; }

.share-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f2f5;
}

.share-row:last-child { border-bottom: 0; }

.share-person {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
}

.share-email {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    color: #6c757d;
    overflow-wrap: anywhere;
}

.share-permission {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: #6c757d;
    background: #f7f9fc;
    border: 1px solid #e3e6ea;
    border-radius: 999px;
    padding: 2px 10px;
}

.share-row form { margin: 0; }

/* Codes still answering on a numbered address, listed on a private project so
   the owner can see what ticking the box did not fix. */
.qr-guessable-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0.3rem 0;
}

.qr-guessable-row form { margin: 0; }

/* Marks a code whose address cannot be guessed. */
.qr-address-tag {
    font-size: 0.75rem;
    color: #0f5132;
    background: #e7f4ec;
    border: 1px solid #cfe8da;
    border-radius: 999px;
    padding: 1px 9px;
    white-space: nowrap;
}

/* The sharing box's live results. The list is positioned over the page rather
   than pushing it down: the permission select and the Share button sit beside
   and below the input, and reflowing them under every keystroke made the
   button move away from the pointer. */
.user-search { position: relative; }

.user-search-results {
    position: absolute;
    z-index: 1050;              /* over the card, under Bootstrap's modal */
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}

.user-search-item {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 8px;
    padding: 0.45rem 0.6rem;
    border-radius: 7px;
    cursor: pointer;
}

.user-search-item.is-active,
.user-search-item:hover { background: #eef4fd; }

.user-search-name {
    font-weight: 600;
    flex: 0 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.user-search-fullname {
    font-weight: 400;
    color: #6c757d;
    margin-left: 6px;
}

.user-search-email {
    flex: 1 1 100%;
    font-size: 0.8rem;
    color: #6c757d;
    overflow-wrap: anywhere;
}

/* Someone the project already reaches, with the access they have. Shown
   rather than hidden, because re-sharing is how a permission gets changed. */
.user-search-tag {
    flex: 0 0 auto;
    font-size: 0.75rem;
    color: #6c757d;
    background: #f7f9fc;
    border: 1px solid #e3e6ea;
    border-radius: 999px;
    padding: 1px 9px;
}

/* Marks a card on the hub that belongs to someone else. */
.project-card-shared {
    font-size: 0.75rem;
    color: #6c757d;
    background: #eef4fd;
    border: 1px solid #d6e4fb;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}


/* ── Card contents ────────────────────────────────────────────────────── */
.project-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1 1 auto;
}

.project-card-main {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    min-width: 0;
}

/* One code from the project, so a card is recognisable at a glance. */
.project-card-qr {
    flex: 0 0 auto;
    width: 68px;
    height: 68px;
    object-fit: contain;
    border: 1px solid #e9edf2;
    border-radius: 6px;
    background: #fff;
    padding: 3px;
}

.project-card-qr-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ced4da;
    font-size: 1.5rem;
}

.project-card-detail {
    min-width: 0;
    flex: 1 1 auto;
}

.project-card-link {
    display: block;
    font-size: 0.78rem;
    color: #6c757d;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* above the card-wide link, or it would open the editor instead */
    position: relative;
    z-index: 2;
}

.project-card-link:hover {
    color: #1e7cec;
    text-decoration: underline;
}

.project-card-actions {
    margin-top: auto;    /* actions sit at the bottom whatever the text length */
}

@media (max-width: 575.98px) {
    .project-list {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .project-card-qr {
        width: 56px;
        height: 56px;
    }
}


/* ── Page header actions ──────────────────────────────────────────────── */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-actions-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 575.98px) {
    .page-actions-buttons {
        width: 100%;
    }

    .page-actions-buttons .btn {
        flex: 1 1 0;
    }
}


/* ── Events ───────────────────────────────────────────────────────────── */
.event-projects {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.event-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 1rem;
}

.event-figure {
    display: flex;
    flex-direction: column;
}

.event-figure-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: #1e7cec;
}

.event-figure-label {
    font-size: 0.8rem;
    color: #6c757d;
}

/* A plain bar chart: no library for a handful of days. */
.day-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 150px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.day-bar {
    flex: 1 0 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 26px;
}

.day-bar-fill {
    width: 100%;
    min-height: 2px;
    background: linear-gradient(180deg, #1e7cec 0%, #1560d4 100%);
    border-radius: 4px 4px 0 0;
}

.day-bar-label {
    margin-top: 4px;
    font-size: 0.68rem;
    color: #6c757d;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .event-figures { gap: 1.25rem; }
    .event-figure-number { font-size: 1.6rem; }
}
