/* Shell & header */
.cert-shell {
    display: grid;
    gap: 20px;
}

.cert-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

/* Toolbar: search stretches, actions pinned right */
.cert-toolbar__controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    padding: 0 12px;
    min-height: 42px;
    background: var(--surface);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 184, 179, 0.12);
}

.search-field__icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.search-field__input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    width: 100%;
    min-height: 40px;
}

.search-field__input::placeholder {
    color: var(--text-muted);
}

.cert-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Filter select — bottom-left, styled to match table */
.cert-filter__select {
    padding: 0 28px 0 10px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: border-color 160ms ease, color 160ms ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238ca1b4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}

.cert-filter__select:hover,
.cert-filter__select:focus {
    border-color: var(--accent);
    color: var(--text);
    outline: none;
}

/* Pagination row: filter left, buttons right */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.pagination__buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination__info {
    padding: 0 8px;
    font-size: 0.9rem;
    color: var(--text-soft);
}

.button--icon {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 0.8rem;
}

@media (max-width: 760px) {
    .cert-toolbar__controls {
        flex-wrap: wrap;
    }
    .search-field {
        width: 100%;
    }
    .cert-toolbar__actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table__head {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-soft);
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
    user-select: none;
}

.data-table__head--sortable {
    cursor: pointer;
}

.data-table__head--sortable:hover {
    color: var(--accent);
}

.data-table__sort-label {
    display: inline;
}

.data-table__sort-icon::after {
    content: '';
    display: inline-block;
    margin-left: 4px;
    opacity: 0.35;
}

.data-table__head--sort-asc .data-table__sort-icon::after {
    content: '↑';
    opacity: 1;
    color: var(--accent);
}

.data-table__head--sort-desc .data-table__sort-icon::after {
    content: '↓';
    opacity: 1;
    color: var(--accent);
}

.data-table__row {
    border-bottom: 1px solid var(--line);
    transition: background 120ms ease;
}

.data-table__row:last-child {
    border-bottom: none;
}

.data-table tbody .data-table__row:hover {
    background: var(--surface-soft);
}

.data-table__row--active {
    background: rgba(23, 184, 179, 0.06);
    border-bottom: 1px solid var(--line);
}

.data-table__row--active:last-child {
    border-bottom: none;
}

.data-table__cell {
    padding: 12px 14px;
    font-size: 0.9rem;
    color: var(--text);
    vertical-align: middle;
}

.data-table__cell a {
    color: var(--accent-ink);
    text-decoration: none;
}

.data-table__cell a:hover {
    text-decoration: underline;
}

/* Индикатор статуса срока действия сертификата */
.cert-status {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 8px;
    border-radius: 50%;
    vertical-align: middle;
    flex-shrink: 0;
    cursor: default;
}

.cert-status--expiring {
    background: var(--warning);
    box-shadow: 0 0 0 3px rgba(240, 165, 67, 0.18);
}

.cert-status--expired {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(235, 103, 111, 0.18);
}

/* First column — checkbox, fixed width */
.data-table th:first-child,
.data-table td:first-child {
    width: 46px;
    padding-left: 8px;
    padding-right: 4px;
}

/* Small checkbox variant */
.checkbox-button__box--small {
    width: 22px;
    height: 22px;
}

.checkbox-button__box--small::after {
    width: 11px;
    height: 6px;
}

/* ===== Адаптив ===== */

/* Планшет — ≤ 900px */
@media (max-width: 900px) {
    /* Скрываем колонку "Дата создания" */
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        display: none;
    }
}

/* Мобильный — ≤ 600px */
@media (max-width: 600px) {
    /* Тулбар: поиск на всю строку, кнопки под ним */
    .cert-toolbar__controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 12px;
    }

    .search-field {
        width: 100%;
        flex: none;
    }

    .cert-toolbar__actions {
        width: 100%;
        justify-content: flex-end;
        flex-shrink: unset;
    }

    /* Заголовок карточки: название сверху, кнопка под ним */
    .cert-card__header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Таблица в горизонтальный скролл */
    .cert-table article {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Скрываем "Издатель" */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        display: none;
    }

    /* Скрываем "Дата создания" (уже скрыта на 900px, дублируем явно) */
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        display: none;
    }

    /* Чуть меньше отступы в ячейках */
    .data-table__head,
    .data-table__cell {
        padding: 10px 10px;
    }

    /* Пагинация: фильтр и кнопки складываются */
    .pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .pagination__buttons {
        align-self: flex-end;
    }

    /* Кнопки пагинации чуть меньше */
    .button--icon {
        min-width: 30px;
        min-height: 30px;
        font-size: 0.75rem;
    }
}