/* Admin / shared overrides (moved from public/admin/styles.css) */

:root {
    --admin-bp-sm-max: 575.98px;
    --admin-bp-lg-max: 991.98px;
    --admin-editor-min-height: 280px;
    --admin-preview-max-height: 16rem;
    --admin-input-width-sm: 7rem;
}

.admin-filter-select {
    width: 100%;
    max-width: 17.5rem;
}

.admin-per-page-select {
    max-width: 5.5rem;
}

.admin-input-width-sm {
    width: var(--admin-input-width-sm);
}

.interests-editor-wrap,
.holiday-editor-wrap {
    min-height: var(--admin-editor-min-height);
    position: relative;
}

/*
 * Remove stacking contexts from layout columns on admin pages.
 * app.css sets z-index: 1 / 2 here for the Elfsight chat popup on the public site,
 * but those stacking contexts trap Bootstrap modals behind the backdrop on admin pages.
 * z-index: auto does not create a stacking context, so modal z-index 1055 is
 * evaluated in the root stacking context and correctly paints above the backdrop.
 */
.site-layout-main-column,
.site-layout-right-column {
  z-index: auto;
}

@media (max-width: 991.98px) {
  .site-layout-main-column,
  .site-layout-right-column {
    z-index: auto;
  }

  .site-layout-right-column.elfsight-chat-panel-open {
    z-index: auto;
  }
}

/*
 * Admin RSS reader (/admin/feeds) — carousel: viewport-aware stage height, image centered (H+V),
 * indicators one row with horizontal scroll when needed.
 */
.feeds-admin-carousel {
    --feeds-carousel-stage-max: 500px;
    --feeds-carousel-stage-min: 220px;
    --feeds-carousel-indicator-bar: 2.25rem;
    --feeds-carousel-control-max: 2.75rem;
    --feeds-carousel-control-min: 2rem;
    --feeds-carousel-stage-h: clamp(
        var(--feeds-carousel-stage-min),
        55vh,
        var(--feeds-carousel-stage-max)
    );
    --feeds-carousel-control-w: clamp(
        var(--feeds-carousel-control-min),
        8vw,
        var(--feeds-carousel-control-max)
    );
    width: 100%;
    max-width: min(100%, 52rem);
    margin-inline: auto;
}

.feeds-admin-carousel .carousel.slide {
    position: relative;
    padding-bottom: var(--feeds-carousel-indicator-bar);
}

.feeds-admin-carousel .carousel-inner.feeds-admin-carousel__inner {
    padding: 0;
    margin: 0 auto;
    width: 100%;
    height: var(--feeds-carousel-stage-h);
}

.feeds-admin-carousel .carousel-item.feeds-admin-carousel__item {
    padding: 0;
    margin: 0;
    height: 100%;
}

.feeds-admin-carousel__stage {
    box-sizing: border-box;
    width: 100%;
    height: var(--feeds-carousel-stage-h);
    min-height: var(--feeds-carousel-stage-h);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.feeds-admin-carousel__link {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.feeds-admin-carousel__img {
    display: block;
    margin: 0 auto;
    padding: 0 !important;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center center;
}

/* Indicators: one row — scroll horizontally if many dots (avoids two-line wrap) */
.feeds-admin-carousel #feedsCarousel .carousel-indicators.feeds-admin-carousel__indicators,
.feeds-admin-carousel .feeds-admin-carousel__indicators {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem 0;
    scrollbar-width: thin;
}

.feeds-admin-carousel .carousel-indicators [type='button'] {
    flex: 0 0 auto;
    margin-inline: 0;
}

/* Vertically align controls with slide center (~half of fixed stage height) */
.feeds-admin-carousel .carousel-control-prev.feeds-admin-carousel__control,
.feeds-admin-carousel .carousel-control-next.feeds-admin-carousel__control {
    width: var(--feeds-carousel-control-w);
    top: calc(var(--feeds-carousel-stage-h) / 2);
    bottom: auto;
    transform: translateY(-50%);
    opacity: 1 !important;
    z-index: 5;
}

@media (max-width: 575.98px) {
    .feeds-admin-carousel {
        --feeds-carousel-indicator-bar: 2rem;
    }

    .feeds-admin-carousel .carousel-indicators.feeds-admin-carousel__indicators {
        padding: 0.25rem 0.35rem 0;
        -webkit-overflow-scrolling: touch;
    }
}

.feeds-admin-carousel .feeds-admin-carousel__control-icon {
    opacity: 1 !important;
    filter: drop-shadow(0 0 3px #fff) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.75));
}

/* Admin /admin/photos — public images folder browser */
.public-images-browser__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    align-items: stretch;
}

.public-images-browser__tile {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.public-images-browser__thumb {
    width: 100%;
    height: 112px;
    object-fit: cover;
    display: block;
    background: var(--bs-secondary-bg, #e9ecef);
    cursor: pointer;
}

.public-images-browser__thumb:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.public-images-browser__preview-img {
    max-height: min(80vh, 900px);
    width: auto;
    height: auto;
}

/* Pool editor tables (/admin/interests-images, named pools): fixed layout so Image Path / Alt / Caption share width evenly-ish (caption hints used to widen col 3 and squash paths). */
.rfp-pools-table {
    table-layout: fixed;
    width: 100%;
}

.rfp-pools-table col.rfp-pools-col-path {
    width: 38%;
}

.rfp-pools-table col.rfp-pools-col-alt {
    width: 18%;
}

.rfp-pools-table col.rfp-pools-col-actions {
    width: 4.25rem;
}

/* Remaining horizontal space goes to the caption column (no width on col.rfp-pools-col-caption). */

.rfp-pools-table th,
.rfp-pools-table td {
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rfp-pools-table .input-group {
    min-width: 0;
}

/* Interests admin collapsible sections (/admin/interests-content, interests-images, interests-right-partials) */
.interests-collapse-chevron {
    transition: transform 0.2s ease;
    display: block;
}

button[data-bs-toggle="collapse"].collapsed .interests-collapse-chevron {
    transform: rotate(-90deg);
}

.interests-content-preview,
.section-html-preview {
    max-height: var(--admin-preview-max-height);
    overflow-y: auto;
}

/* Pool editor: stacked card rows on narrow viewports (data-label on cells). */
@media (max-width: 575.98px) {
    .rfp-pools-table colgroup {
        display: none;
    }

    .rfp-pools-table {
        table-layout: auto;
    }

    .rfp-pools-table thead {
        display: none;
    }

    .rfp-pools-table tbody tr {
        display: block;
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: var(--bs-border-radius, 0.375rem);
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .rfp-pools-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .rfp-pools-table td {
        display: block;
        width: 100%;
        border: 0;
        padding: 0.5rem 0;
    }

    .rfp-pools-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.8125rem;
        margin-bottom: 0.25rem;
        color: var(--bs-secondary-color, #6c757d);
    }

    .rfp-pools-table td[data-label=""]::before {
        content: none;
    }

    .rfp-pools-table td.rfp-pools-col-actions {
        text-align: start;
        padding-top: 0.25rem;
    }

    .rfp-pools-table .input-group {
        width: 100%;
    }

    .admin-actions-inline,
    .list-group-item .btn,
    td .btn-group,
    td form.d-inline {
        flex-wrap: wrap;
    }

    .table-responsive .btn-sm {
        padding: 0.2rem 0.45rem;
        font-size: 0.8125rem;
    }

    #adminModal .modal-footer,
    #adminModal .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}
