/* ===== AEPC Docs: Front-end listing ===== */

/* Header layout: title left, tools right */
.aepc-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
    margin-right: 2.5% !important;
    margin-left: 2.5% !important;
}

.aepc-title {
    margin: 0;
    flex: 0 0 auto;
}

/* Push tools to the right; keep compact */
.aepc-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
    flex: 0 0 auto;
}

.aepc-toolbar input[type="search"] {
    flex: 0 1 340px;
    max-width: 420px;
    min-width: 220px;
}

/* Advanced search toggle (summary stays put) */
details.aepc-adv {
    position: relative;
    margin: .25rem 0 .25rem;
}

details.aepc-adv>summary {
    cursor: pointer;
    display: inline-block;
    white-space: nowrap;
    padding: .25rem .6rem;
    border: 1px solid #e2e2e2;
    border-radius: 999px;
    list-style: none;
    background: rgba(0, 0, 0, .03);
}

details.aepc-adv>summary::-webkit-details-marker {
    display: none;
}

details.aepc-adv[open]>summary {
    background: rgba(0, 0, 0, .08);
    border-color: #d0d0d0;
}

details.aepc-adv.has-active>summary {
    background: rgba(0, 0, 0, .12);
    border-color: #c0c0c0;
    font-weight: 600;
}

/* Panel sits below; spacing on the panel (prevents summary “jump”) */
.aepc-adv .aepc-panel {
    margin-top: .5rem;
}

.aepc-adv .aepc-grid {
    display: grid;
    gap: .5rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.aepc-adv fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.aepc-adv legend {
    font-weight: 600;
    margin-bottom: .25rem;
    font-size: .95em;
}

/* Smaller buttons */
.aepc-actions {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
}

.aepc-actions .button,
.aepc-actions .button-primary {
    font-size: .9em;
    line-height: 1.2;
    padding: .25rem .5rem;
    border-radius: 6px;
}

/* Cards grid + filter chips */
.aepc-doc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.aepc-chip {
    border: 1px solid #ddd;
    border-radius: 999px;
    padding: .2rem .6rem;
}

/* Small screens: stack toolbar full width */
@media (max-width: 640px) {
    .aepc-toolbar {
        margin-left: 0;
        width: 100%;
    }
}

/* --- Advanced panel as a right-anchored dropdown card --- */
.aepc-header-row {
    position: relative;
}

/* anchor for absolute panel */
details.aepc-adv {
    position: relative;
}

details.aepc-adv>summary {
    cursor: pointer;
    display: inline-block;
    white-space: nowrap;
    padding: .25rem .6rem;
    border: 1px solid #e2e2e2;
    border-radius: 999px;
    background: rgba(0, 0, 0, .03);
}

details.aepc-adv>summary::-webkit-details-marker {
    display: none;
}

details.aepc-adv[open]>summary {
    background: rgba(0, 0, 0, .08);
    border-color: #d0d0d0;
}

details.aepc-adv.has-active>summary {
    background: rgba(0, 0, 0, .12);
    border-color: #c0c0c0;
    font-weight: 600;
}

/* The dropdown panel: wide, organized, doesn't push the toggle */
.aepc-adv .aepc-panel {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    width: min(760px, 96vw);
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
    z-index: 20;
}

/* Two clean columns inside the panel */
.aepc-adv .aepc-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.aepc-adv fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.aepc-adv legend {
    font-weight: 600;
    margin-bottom: .25rem;
    font-size: .95em;
}

/* Right-align the action buttons, smaller size */
.aepc-actions {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
    justify-content: flex-end;
}

.aepc-actions .button,
.aepc-actions .button-primary {
    font-size: .9em;
    line-height: 1.2;
    padding: .25rem .5rem;
    border-radius: 6px;
}

/* Mobile: panel becomes inline (no absolute), full-width card */
@media (max-width: 720px) {
    .aepc-adv .aepc-panel {
        position: static;
        width: auto;
        box-shadow: none;
        border-radius: 8px;
        margin-top: .5rem;
    }

    .aepc-adv .aepc-grid {
        grid-template-columns: 1fr;
    }
}

.aepc-download {
    text-decoration: none;
    font-size: 1.1em;
    padding: .1rem .35rem;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
}

.aepc-download:hover {
    background: #f6f6f6;
}