/* ──────────────────────────────────────────
   Document Manager – Frontend Styles v1.2
────────────────────────────────────────── */

.dm-wrapper {
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

/* ── FILTER BAR ─────────────────────────────────── */
.dm-wrapper .dm-filters {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 28px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}

/* Search wrapper grows to fill all leftover space */
.dm-wrapper .dm-filters .dm-search-wrap {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;            /* critical: allows shrink below content size */
    width: 0;                /* forces flex to control the width, not content */
}

.dm-wrapper .dm-filters .dm-search-wrap .dm-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #aaa;
    pointer-events: none;
    z-index: 2;
}

/* Use high-specificity selector to beat theme rules on input[type=search] */
.dm-wrapper .dm-filters .dm-search-wrap input.dm-search,
.dm-wrapper .dm-filters .dm-search-wrap input.dm-search[type="search"] {
    display: block !important;
    width: 100% !important;
    height: 42px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-right: 14px !important;
    padding-left: 40px !important;   /* room for the search icon */
    margin: 0 !important;
    border: 2px solid #ddd !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    line-height: 42px !important;
    background: #fff !important;
    background-image: none !important;   /* kill any theme magnifier bg-image */
    color: inherit !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: border-color .2s !important;
}
.dm-wrapper .dm-filters .dm-search-wrap input.dm-search:focus {
    outline: none !important;
    border-color: var(--wp--preset--color--primary, #007cba) !important;
    box-shadow: 0 0 0 3px rgba(0,124,186,.12) !important;
}

/* Dropdowns — category is auto-width, year is locked narrow */
.dm-wrapper .dm-filters select.dm-filter-select {
    flex: 0 0 auto;
    height: 42px;
    padding: 0 32px 0 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: inherit;
    cursor: pointer;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .2s;
}
.dm-wrapper .dm-filters select.dm-filter-year {
    width: 104px;    /* just wide enough for a 4-digit year + chevron */
}
.dm-wrapper .dm-filters select.dm-filter-cat {
    max-width: 160px;  /* cap category dropdown — search bar keeps the rest */
}
.dm-wrapper .dm-filters select.dm-filter-select:focus {
    outline: none;
    border-color: var(--wp--preset--color--primary, #007cba);
}

/* ── GRID ─────────────────────────────────────────── */
.dm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* ── CARD ──────────────────────────────────────────── */
.dm-card {
    background: var(--wp--preset--color--tertiary, #eef2fb);
    border-radius: 30px;
    padding: 28px 22px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Document icon (FA) — follows primary color */
.dm-card-icon {
    font-size: 2.2em;
    margin-bottom: 10px;
    color: var(--wp--preset--color--primary, #1a5ca0);
    line-height: 1;
}

.dm-card-subtitle {
    font-size: .78em;
    color: #666;
    margin: 0 0 4px;
    line-height: 1.3;
}

.dm-card-title {
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 10px;
    line-height: 1.35;
    color: inherit;
}

.dm-card-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    min-height: 22px;
}

.dm-card-cat {
    font-size: .72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #555;
    background: rgba(0,0,0,.07);
    padding: 2px 10px;
    border-radius: 20px;
}

.dm-card-year {
    font-size: .75em;
    color: #888;
}

/* ── DOWNLOAD BUTTON ─────────────────────────────── */
.dm-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding-top: calc(0.667em + 2px);
    padding-right: calc(1.333em + 2px);
    padding-bottom: calc(0.667em + 2px);
    padding-left: calc(1.333em + 2px);
    border-radius: 100px;
    background: var(--wp--preset--color--primary, #1a5ca0);
    color: #fff !important;
    font-size: .9em;
    font-weight: 400;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    margin-top: auto;
    line-height: 1;
}
.dm-card-btn:hover  { opacity: .88; }
.dm-card-btn:focus  {
    outline: 3px solid var(--wp--preset--color--primary, #1a5ca0);
    outline-offset: 3px;
    opacity: .9;
}
.dm-card-btn svg { flex-shrink: 0; }

/* ── GROUPED SECTIONS ────────────────────────────── */
.dm-cat-section          { margin-bottom: 32px; }
.dm-cat-section:last-child { margin-bottom: 0; }

/* Subcategories nested inside a section */
.dm-cat-section .dm-cat-section { margin-top: 24px; margin-bottom: 0; }

/* Heading base — all depths */
.dm-cat-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0,0,0,.07);
    line-height: 1.25;
    color: inherit;
}
/* Icon always follows primary color */
.dm-cat-heading i {
    flex-shrink: 0;
    line-height: 1;
    color: var(--wp--preset--color--primary, #1a5ca0);
}

/* Depth 0 = h2: larger, full-weight border */
.dm-cat-heading--depth-0 {
    font-size: 1.45em;
    border-bottom-width: 2px;
}
/* Depth 1 = h3: medium */
.dm-cat-heading--depth-1 {
    font-size: 1.15em;
    border-bottom-width: 1px;
    border-bottom-color: rgba(0,0,0,.05);
}
/* Depth 2+ = h4/h5/h6: smaller */
.dm-cat-heading--depth-2,
.dm-cat-heading--depth-3 {
    font-size: 1em;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 4px;
    opacity: .85;
}

.dm-cat-section--uncategorized .dm-cat-heading { color: #777; }

/* Safety-net: ensure filtered cards/sections really disappear
   even if theme CSS interferes with the [hidden] attribute */
.dm-card[hidden],
.dm-cat-section[hidden],
.dm-year-section[hidden] { display: none !important; }

/* ── NO RESULTS ──────────────────────────────────── */
.dm-no-results {
    text-align: center;
    color: #888;
    padding: 32px 16px;
    font-size: .95em;
}

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 560px) {
    .dm-wrapper .dm-filters       { flex-wrap: wrap; }
    .dm-wrapper .dm-filters .dm-search-wrap { flex: 1 1 100%; width: 100%; }
    .dm-wrapper .dm-filters select.dm-filter-select { flex: 1 1 auto; width: auto; }
    .dm-wrapper .dm-filters select.dm-filter-year   { width: auto; }
    .dm-grid  { grid-template-columns: 1fr; }
    .dm-card  { border-radius: 30px; }
}
