/* ═══════════════════════════════════════════════════════════════════════════════
   MEDIA RESOURCES — PREMIUM REDESIGN (2026)
   ════════════════════════════════════════════════════════════════════════════════
   Цели:
   · современный визуал в стиле сайта (бренд-зелёный #05612A / #187D35),
   · тонкие анимации, которые украшают интерфейс без лишних нагрузок,
   · адаптивность от 1920px до 360px,
   · CSS Grid вместо таблиц — корректный флоу и отсутствие «пустых» колонок.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ───── Shell / страница ───── */
/* Листинг (cards) — светло-серый фон помогает разделить карточки.
   Details — тот же белый, что и у самой статьи, чтобы не было цветной
   полосы между блоком и футером (ранее был виден контраст #f4f6fa vs #fff). */
.media-resources-page {
    background: #f4f6fa;
    min-height: calc(100vh - 200px);
    padding: 0 !important;
    margin: 0 !important;
}

/* На странице Details внутри wrapper'а лежит только один белый блок .mr-article,
   поэтому любой серый "хвост" снизу (margin + page bg) визуально торчит
   перед тёмным футером. Делаем фон страницы белым в этом кейсе. */
.media-resources-page:has(.media-details-page) {
    background: #ffffff;
}
/* Fallback для браузеров без :has() (на всякий случай) */
.media-details-page {
    background: #ffffff;
}

/* Унифицированный фон на уровне самой статьи — убираем старые фоновые
   различия между вложенными блоками (CKEditor-контент иногда задаёт свои
   background-color, которые выбивались из общего светлого оттенка). */
.mr-article,
.mr-article__meta,
.mr-article__body,
.mr-gallery,
.mr-docs {
    background: #ffffff;
}
.mr-article__body * {
    background-color: transparent !important;
}
.mr-article__body img,
.mr-article__body video,
.mr-article__body iframe {
    background-color: transparent !important;
}

.media-index-page,
.media-details-page {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto !important;
    padding: 0 20px !important;
}

/* ───── Hero-заголовок списка ───── */
.mr-hero {
    position: relative;
    padding: 28px 0 20px;
    text-align: center;
}

.mr-hero__eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #187D35;
    margin-bottom: 10px;
    padding: 4px 14px;
    background: rgba(24,125,53,.08);
    border-radius: 999px;
}

.mr-hero__title {
    /* Noto Sans + Ubuntu поддерживают все три языка (казахский включительно).
       Monserrat для кириллицы Kazakh неполный, поэтому заменён. */
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: clamp(22px, 3vw, 32px);
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 6px;
    letter-spacing: -.3px;
}

.mr-hero__sub {
    color: #64748b;
    font-size: 14px;
    margin: 0 auto 18px;
    max-width: 640px;
}

.mr-hero__divider {
    width: 52px;
    height: 3px;
    margin: 0 auto 10px;
    background: linear-gradient(90deg, #05612A, #2bb55a);
    border-radius: 999px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   РАСШИРЕННЫЙ ФИЛЬТР (chip + sort + date range + search)
   ═══════════════════════════════════════════════════════════════════════════════ */

.mr-filter {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0 0 28px;
    padding: 14px 18px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e6ebf2;
    box-shadow: 0 4px 18px rgba(15,23,42,.05);
}

/* Category chips */
.mr-filter__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef2f7;
}

.mr-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease, box-shadow .2s ease;
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', Arial, sans-serif;
}
.mr-chip:hover {
    border-color: #187D35;
    color: #05612A;
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24,125,53,.12);
}
.mr-chip.is-active {
    background: linear-gradient(135deg, #05612A, #187D35);
    color: #fff;
    border-color: #05612A;
    box-shadow: 0 6px 18px rgba(24,125,53,.3);
}

/* Toolbar (search + sort + date range + buttons) */
.mr-filter__toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(150px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.mr-filter__field {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 0 12px;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
    min-height: 42px;
}
.mr-filter__field:focus-within {
    border-color: #187D35;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(24,125,53,.12);
}
.mr-filter__icon {
    color: #94a3b8;
    flex-shrink: 0;
    margin-right: 8px;
}
.mr-filter__field input,
.mr-filter__field select {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #0f172a;
    padding: 10px 0;
    font-family: inherit;
    font-weight: 500;
}
.mr-filter__field select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
    padding-right: 16px;
}
.mr-filter__field input::placeholder {
    color: #94a3b8;
}
.mr-filter__field--date input {
    font-variant-numeric: tabular-nums;
}

.mr-filter__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-self: end;
}

.mr-filter__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
    font-family: inherit;
    white-space: nowrap;
}
.mr-filter__btn--primary {
    background: linear-gradient(135deg, #05612A, #187D35);
    color: #fff;
    box-shadow: 0 4px 14px rgba(24,125,53,.3);
}
.mr-filter__btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(24,125,53,.4);
    color: #fff;
}
.mr-filter__btn--ghost {
    background: #fff;
    color: #475569;
    border-color: #e2e8f0;
}
.mr-filter__btn--ghost:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

@media (max-width: 980px) {
    .mr-filter__toolbar {
        grid-template-columns: 1fr 1fr;
    }
    .mr-filter__field--search {
        grid-column: 1 / -1;
    }
    .mr-filter__actions {
        grid-column: 1 / -1;
        justify-self: stretch;
    }
    .mr-filter__btn { flex: 1; justify-content: center; }
}

@media (max-width: 560px) {
    .mr-filter__toolbar { grid-template-columns: 1fr; }
    .mr-filter { padding: 12px 12px; }
}

/* Legacy fallback (если где-то ещё остались .filter-buttons) */
.filter-buttons { display: none !important; }

/* ───── Адаптивная сетка карточек ───── */
.mr-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    margin: 8px 0 32px;
}

@media (max-width: 1200px) { .mr-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; } }
@media (max-width: 900px)  { .mr-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (max-width: 560px)  { .mr-grid { grid-template-columns: 1fr; gap: 14px; } }

/* ───── Карточка ───── */
.mr-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    transition: transform .35s cubic-bezier(.2,.8,.2,1),
                box-shadow .35s cubic-bezier(.2,.8,.2,1);
    will-change: transform;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.mr-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(15,23,42,.12);
}

.mr-card:focus-visible {
    outline: 3px solid #187D35;
    outline-offset: 2px;
}

.mr-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #e5e7eb;
}

.mr-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s cubic-bezier(.2,.8,.2,1), filter .35s ease;
}

.mr-card:hover .mr-card__media img {
    transform: scale(1.06);
}

/* Лёгкий градиент поверх фото */
.mr-card__media::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 38%;
    background: linear-gradient(to top, rgba(15,23,42,.55), transparent);
    opacity: 0;
    transition: opacity .3s ease;
}
.mr-card:hover .mr-card__media::after { opacity: 1; }

.mr-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #fff;
    background: linear-gradient(135deg, #05612A, #187D35);
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(5,97,42,.35);
}

.mr-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px 18px;
}

.mr-card__title {
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .25s ease;
}

.mr-card:hover .mr-card__title { color: #05612A; }

.mr-card__meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    color: #64748b;
    font-size: 12px;
}

.mr-card__meta .mr-icon {
    width: 12px; height: 12px;
    display: inline-flex;
    vertical-align: -1px;
    margin-right: 4px;
}

/* Shimmer-эффект загрузки (опционально подключается классом) */
.mr-card.is-loading .mr-card__media img {
    filter: blur(6px);
}

/* ───── Pagination ───── */
.mr-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 12px 0 40px;
    list-style: none;
    margin: 0;
}

.mr-pagination a,
.mr-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    background: #fff;
    color: #05612A;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #e2e8f0;
    transition: all .2s ease;
}

.mr-pagination a:hover {
    background: #05612A;
    color: #fff;
    border-color: #05612A;
    transform: translateY(-1px);
}

.mr-pagination .is-active {
    background: linear-gradient(135deg, #05612A, #187D35);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(5,97,42,.25);
}

/* ───── Empty state ───── */
.mr-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 4px 14px rgba(15,23,42,.06);
    color: #64748b;
}

.mr-empty__icon {
    font-size: 56px;
    margin-bottom: 12px;
    color: #cbd5e1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DETAILS (полная карточка материала)
   ═══════════════════════════════════════════════════════════════════════════════ */

.mr-article {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(15,23,42,.06);
    margin: 0 0 36px;
    animation: mr-fade-up .5s cubic-bezier(.2,.8,.2,1);
}

@keyframes mr-fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mr-article__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #05612A;
    text-decoration: none;
    transition: transform .2s ease, color .2s ease;
}
.mr-article__back:hover { transform: translateX(-3px); color: #187D35; }

.mr-article__hero {
    position: relative;
    aspect-ratio: 16 / 7;
    background: linear-gradient(135deg, #05612A 0%, #187D35 100%);
    overflow: hidden;
}
.mr-article__hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.2s cubic-bezier(.2,.8,.2,1);
}
.mr-article:hover .mr-article__hero img { transform: scale(1.02); }

.mr-article__hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15,23,42,0) 30%, rgba(15,23,42,.72) 100%);
}

.mr-article__hero-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 28px 32px;
    color: #fff;
    z-index: 2;
}

.mr-article__hero-overlay .mr-card__badge {
    position: static;
    display: inline-block;
    margin-bottom: 12px;
}

.mr-article__title {
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
    line-height: 1.25;
    color: #fff;
    margin: 0;
    text-shadow: 0 2px 20px rgba(0,0,0,.4);
}

.mr-article__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 18px 32px;
    border-bottom: 1px solid #eef2f7;
    color: #64748b;
    font-size: 13px;
}
.mr-article__meta .mr-meta-item {
    display: inline-flex; align-items: center; gap: 6px;
}

.mr-article__body {
    padding: 22px 32px 8px;
    font-size: 16px;
    color: #1e293b;
    line-height: 1.75;
}
.mr-article__body img {
    max-width: 100%;
    border-radius: 12px;
    height: auto;
    margin: 14px auto;
    display: block;
    box-shadow: 0 4px 18px rgba(15,23,42,.1);
}
.mr-article__body p { margin: 0 0 14px; }
.mr-article__body a { color: #187D35; text-decoration: none; border-bottom: 1px dashed rgba(24,125,53,.4); }
.mr-article__body a:hover { color: #05612A; border-bottom-color: #05612A; }

/* ───── Галерея доп. изображений ───── */
.mr-gallery {
    padding: 12px 32px 24px;
}
.mr-gallery__title {
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mr-gallery__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 900px) { .mr-gallery__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .mr-gallery__grid { grid-template-columns: 1fr; } }

.mr-gallery__item {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    cursor: zoom-in;
    background: #e5e7eb;
    transition: transform .25s ease;
}
.mr-gallery__item:hover { transform: translateY(-3px); }
.mr-gallery__item img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .5s cubic-bezier(.2,.8,.2,1);
}
.mr-gallery__item:hover img { transform: scale(1.08); }

/* ───── Документы ───── */
.mr-docs { padding: 8px 32px 28px; }
.mr-docs__title {
    font-family: 'Noto Sans', 'Ubuntu', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 14px;
    display: inline-flex; align-items: center; gap: 8px;
}

.mr-docs__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mr-doc {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.mr-doc:hover {
    background: #fff;
    border-color: #c6e6d0;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(15,23,42,.08);
}

.mr-doc__icon {
    flex: 0 0 44px;
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px;
    font-size: 22px;
    color: #fff;
}
.mr-doc--pdf  .mr-doc__icon { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.mr-doc--doc  .mr-doc__icon { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.mr-doc--xls  .mr-doc__icon { background: linear-gradient(135deg, #16a34a, #15803d); }
.mr-doc--ppt  .mr-doc__icon { background: linear-gradient(135deg, #ea580c, #c2410c); }
.mr-doc--any  .mr-doc__icon { background: linear-gradient(135deg, #64748b, #475569); }

.mr-doc__info { flex: 1; min-width: 0; }
.mr-doc__name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mr-doc__sub {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

.mr-doc__actions {
    display: flex; gap: 6px; flex-shrink: 0;
}
.mr-doc__btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.mr-doc__btn--primary {
    background: linear-gradient(135deg, #05612A, #187D35);
    color: #fff;
}
.mr-doc__btn--primary:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(5,97,42,.3); color:#fff; }
.mr-doc__btn--ghost {
    background: #fff; color: #0f172a; border-color: #e2e8f0;
}
.mr-doc__btn--ghost:hover { border-color: #94a3b8; color: #0f172a; }

/* ───── Lightbox ───── */
.mr-lightbox {
    position: fixed; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(15,23,42,.92);
    z-index: 9999;
    padding: 20px;
    cursor: zoom-out;
    animation: mr-fade .25s ease both;
}
.mr-lightbox.is-open { display: flex; }
.mr-lightbox img {
    max-width: 92vw; max-height: 88vh;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.6);
    animation: mr-zoom-in .25s cubic-bezier(.2,.8,.2,1) both;
}
.mr-lightbox__close {
    position: absolute; top: 18px; right: 22px;
    font-size: 32px; color: #fff; cursor: pointer;
    background: rgba(255,255,255,.1);
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .2s ease;
}
.mr-lightbox__close:hover { background: rgba(255,255,255,.25); }

@keyframes mr-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mr-zoom-in { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ───── Общая адаптивность для деталей ───── */
@media (max-width: 768px) {
    .mr-article__hero-overlay,
    .mr-article__meta,
    .mr-article__body,
    .mr-gallery,
    .mr-docs { padding-left: 18px; padding-right: 18px; }
    .mr-doc { flex-wrap: wrap; }
    .mr-doc__actions { width: 100%; justify-content: flex-end; }
}

/* ───── Совместимость: старая разметка .news-card больше не используется ───── */
.media-resources-page table, .media-resources-page td { border: none !important; padding: 0 !important; }
