/*
 * MPR UI Refresh
 * Ukrainian Pharmaceutical Agency
 * Version: 1.2
 * Date: 2026-11-25
 */

/* =====================================
   1. MAIN CONTENT
   ===================================== */

#main-page .content {
    width: calc(100% - 48px);
    max-width: 1320px;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-bottom: 1.5rem !important;
}

#device-page .content .content {
    width: 100%;
}

/* =====================================
   2. HEADER
   ===================================== */

.header {
    background: linear-gradient(
        97.14deg,
        #0037A3 6.92%,
        #71A1FF 97.65%
    );
    padding: 14px 0 18px;
}

.header__container {
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.header__container .main-logo {
    min-width: 220px;
    flex-shrink: 0;
    align-items: flex-start;
}

.preview {
    width: 180px;
}

.header-title {
    margin-top: 8px;
}

#title-text {
    font-size: 1.45em;
    line-height: 1.2;
}

.back {
    margin-top: 14px;
    font-size: 0.9em;
    line-height: 1.2;
}

.back a {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.95);
}

.back a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    text-decoration: none;
}

/* =====================================
   3. SEARCH FORM
   ===================================== */

#ajax_form {
    background: #ffffff;
    border: 1px solid #dfe6f2;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

.search__options {
    margin-top: 18px;
    margin-bottom: 10px;
}

.select-search-for,
#ajax_form input,
#ajax_form select,
#ajax_form .select2-selection {
    border-radius: 10px !important;
}

/* =====================================
   4. BUTTONS
   ===================================== */

.btn.btn-primary {
    border-radius: 10px !important;
    padding-left: 18px;
    padding-right: 18px;
}

#pagination-offset li button,
#limit button {
    border-radius: 10px !important;
}

/* =====================================
   5. REGISTRY TABLE CONTAINER
   ===================================== */

#result-offset-limit {
    margin-top: 0 !important;
}

#result {
    background: #ffffff;
    border: 1px solid #dfe6f2;
    border-radius: 20px 20px 0 0;
    padding: 18px 18px 0;
    margin-top: 12px !important;
    margin-bottom: 0 !important;
    overflow-x: auto;
    box-shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

#result table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* =====================================
   6. TABLE HEADER
   ===================================== */

#result th {
    background: #f7f9fc;
    color: #4b5565;
    font-weight: 600;
    font-size: 0.95em;
    padding: 12px;
    border-bottom: 1px solid #dfe6f2;
    text-align: left;
}

#result th:first-child {
    border-top-left-radius: 12px;
}

#result th:last-child {
    border-top-right-radius: 12px;
}

/* =====================================
   7. TABLE ROWS
   ===================================== */

#result td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #edf2f8;
    background: #ffffff;
    font-size: 0.95em;
}

#result tbody tr:nth-child(even) td {
    background: #fbfcfe;
}

#result tbody tr:hover td {
    background: #f3f7ff;
}

#result tbody tr:last-child td {
    border-bottom: none;
}

#result a {
    color: #1d63d8;
    font-weight: 600;
    text-decoration: none;
}

#result a:hover {
    text-decoration: underline;
}

/* MPR - Registry column proportions */
@media (min-width: 1100px) {
    #result table {
        table-layout: fixed;
    }

    #result th:nth-child(1) { width: 8%; }
    #result th:nth-child(2) { width: 24%; }
    #result th:nth-child(3) { width: 18%; }
    #result th:nth-child(4) { width: 18%; }
    #result th:nth-child(5) { width: 14%; }
    #result th:nth-child(6) { width: 11%; }
    #result th:nth-child(7) { width: 7%; }

    #result td {
        overflow-wrap: break-word;
    }
}

/* =====================================
   8. PAGINATION
   ===================================== */

#offset-limit {
    background: #ffffff;
    border: 1px solid #dfe6f2;
    border-top: none;
    border-radius: 0 0 20px 20px;
    padding: 16px 18px 24px;
    margin-top: 0;
    box-shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

/* =====================================
   9. MEDICAL DEVICE PAGE
   ===================================== */

#device-page {
    background: #f5f9ff;
    padding-top: 24px;
    padding-bottom: 40px;
}

#device-page > .content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 28px 32px;
}

#device-page h1,
#device-page h3,
#device-page h5 {
    letter-spacing: -0.02em;
}

/* =====================================
   10. DOCUMENT CARDS
   ===================================== */

#device-page .block-document {
    border: 1px solid #dce3ec;
    border-radius: 12px;
    padding: 14px;
}

/* =====================================
   11. MOBILE
   ===================================== */

@media (max-width: 768px) {

    #main-page .content {
        width: calc(100% - 24px);
    }

    .header__container {
        gap: 12px;
    }

    .header__container .main-logo {
        min-width: 0;
    }

    #ajax_form {
        padding: 16px;
    }

    #result {
        padding: 10px;
    }

    #device-page > .content {
        padding: 16px;
    }

    #device-page .block-document {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* =====================================
   12. MOBILE IMPROVEMENTS - TEST
   ===================================== */

@media (max-width: 767px) {

    /* Основной контейнер */
    #main-page .content {
        width: calc(100% - 24px);
        max-width: 100%;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Компактная шапка */
    .header {
        padding: 12px 0;
    }

    .header__container {
        flex-wrap: wrap;
        gap: 12px;
    }

    #title-text {
        font-size: 1.15em;
        line-height: 1.35;
    }

    .back {
        margin-top: 8px;
    }

    /* Форма поиска */
    #ajax_form {
        padding: 16px 14px;
        border-radius: 14px;
    }

    #ajax_form input,
    #ajax_form select,
    #ajax_form .select2-selection {
        max-width: 100%;
    }

    /* Таблица с горизонтальной прокруткой */
    #result {
        width: calc(100% - 24px);
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
        border-radius: 14px 14px 0 0;
    }

    #result table {
        min-width: 950px;
        table-layout: fixed;
    }

    /* Фиксируем размеры столбцов */
    #result th:nth-child(1) { width: 8%; }
    #result th:nth-child(2) { width: 24%; }
    #result th:nth-child(3) { width: 18%; }
    #result th:nth-child(4) { width: 18%; }
    #result th:nth-child(5) { width: 14%; }
    #result th:nth-child(6) { width: 11%; }
    #result th:nth-child(7) { width: 7%; }

    #result th,
    #result td {
        padding: 10px;
        font-size: 0.9em;
    }

    /* Пагинация */
    #offset-limit {
        width: calc(100% - 24px);
        max-width: 100%;
        padding: 12px;
        border-radius: 0 0 14px 14px;
    }

    /* Страница изделия */
    #device-page {
        padding-top: 12px;
    }

    #device-page > .content {
        padding: 16px;
        border-radius: 14px;
    }

    #device-page .block-document {
        flex: 0 0 100%;
        max-width: 100%;
    }


/* =====================================
   MPR v1.3 - Compact mobile header
   ===================================== */



    .header {
        padding: 10px 0 12px;
    }

    .header__container {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "logo title"
            "agency agency"
            "actions actions";
        gap: 8px 12px;
        align-items: center;
    }

    .header__container .preview {
        grid-area: logo;
        width: auto;
        min-width: 0;
    }

    .header__container .main-logo {
        min-width: 0;
    }

    .header__container .main-text {
        grid-area: agency;
        text-align: center;
        min-width: 0;
    }

    .header__container .herb {
        margin: 0 auto 6px;
    }

    .header__container .main-text__title {
        font-size: 20px;
        line-height: 1.25;
    }

    .header__container .back {
        margin-top: 8px;
    }

    .header__container .back a {
        padding: 5px 8px;
        font-size: 11px;
    }

    .header__container .switchers {
        grid-area: actions;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 8px 16px;
        margin: 0;
        padding: 0;
    }

    .header__container .switchers li {
        margin: 0;
    }

    .header__container .switchers .action {
        display: flex;
        align-items: center;
    }

    .header__container .switchers .btn {
        font-size: 12px;
        line-height: 1.2;
    }


/* =====================================
   MPR - Mobile header layout fix
   ===================================== */



    .header {
        padding: 10px 0 14px;
    }

    .header__container {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "logo logo"
            "agency agency"
            "actions actions";
        width: calc(100% - 24px);
        gap: 10px;
        align-items: center;
        margin: 0 auto !important;
    }

    .header__container .preview {
        grid-area: logo;
        width: 100%;
        min-width: 0;
    }

    .header__container .main-logo {
        min-width: 0;
        align-items: flex-start;
    }

    .header__container .main-logo__text {
        min-width: 0;
    }

    .header__container .gov {
        margin-bottom: 2px;
    }

    .header__container .back {
        margin-top: 8px;
    }

    .header__container .main-text {
        grid-area: agency;
        width: 100%;
        text-align: center;
    }

    .header__container .herb {
        margin: 0 auto 8px;
        width: 25px;
        height: 42px;
        background-size: contain;
    }

    .header__container .main-text__title {
        display: inline-block;
        font-size: 19px;
        line-height: 1.3;
        overflow-wrap: break-word;
    }

    .header__container .switchers {
        grid-area: actions;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
        list-style: none;
        gap: 8px;
    }

    .header__container .switchers li {
        width: auto;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .header__container .switchers .action {
        display: flex;
        align-items: center;
        min-width: 0;
    }

    .header__container .switchers .action__img {
        width: 18px;
        height: 18px;
        object-fit: contain;
        flex-shrink: 0;
    }

    .header__container .switchers .btn {
        padding: 4px;
        font-size: 11px;
        line-height: 1.3;
        white-space: normal;
        text-align: left;
    }


/* =====================================
   MPR - Mobile table scroll hint
   ===================================== */



    #result {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #result::before {
        content: "Гортайте таблицю вправо →";
        display: block;
        width: max-content;
        max-width: 100%;
        margin: 0 0 12px auto;
        padding: 6px 10px;
        border-radius: 8px;
        background: #eef4ff;
        color: #2d5ca6;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
    }

    #result table {
        min-width: 950px;
    }


/* =====================================
   MPR - Mobile medical device details
   ===================================== */



    /* Основная карточка */
    #device-page {
        padding: 12px 0 24px;
    }

    #device-page > .content {
        padding: 16px 12px;
        border-radius: 14px;
    }

    /* Убираем лишние вложенные отступы */
    #device-page .content .content {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0;
    }

    /* Bootstrap: одна колонка */
    #device-page .row > .col-3,
    #device-page .row > .col-9 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }

    /* Навигация по разделам */
    #device-page > .content > .content > .row > .col-3 {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 14px;
        padding-bottom: 16px;
    }

    #device-page > .content > .content > .row > .col-3 > .pt-2 {
        padding-top: 0 !important;
    }

    #device-page > .content > .content > .row > .col-3 a {
        font-size: 12px;
        text-decoration: none;
    }

    /* Информационная часть */
    #device-page .info {
        padding-left: 15px;
        padding-right: 15px;
    }

    #device-page .info h3 {
        font-size: 22px;
        margin-bottom: 14px;
    }

    #device-page .info h5 {
        font-size: 18px;
    }

    /* Поля: название сверху, значение снизу */
    #device-page .device-row-info {
        min-height: 0;
        margin-bottom: 12px;
        padding-top: 0 !important;
    }

    #device-page .device-row-info > .col-3 {
        color: #667085;
        font-size: 12px;
        margin-bottom: 5px;
    }

    #device-page .device-row-info > .col-9 {
        font-size: 13px;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    #device-page .device-val {
        overflow-wrap: anywhere;
    }

    /* Длинные описания без внутренней прокрутки */
    #device-page .device-description,
    #device-page .device-descriptionEn {
        max-height: none;
        overflow: visible;
    }

    /* Старый формат */
    #device-page .old-format-collapse {
        flex-wrap: wrap;
        gap: 8px;
        align-items: flex-start;
    }

    #device-page .div-warning {
        max-width: 100%;
    }

    /* Документы соответствия */
    #device-page .documents {
        margin-left: 0;
        margin-right: 0;
    }

    #device-page .block-document {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 12px;
        border-radius: 12px;
        overflow-wrap: anywhere;
    }

    /* Разделители */
    #device-page hr {
        margin: 18px 0;
        border-color: #e4eaf2;
    }


/* MPR - Mobile conformity document cards */


    #device-page .block-document {
        padding: 16px;
        border-radius: 12px;
    }

    #device-page .block-document .row {
        display: flex;
        flex-direction: column;
        margin-left: 0;
        margin-right: 0;
        gap: 4px;
        margin-bottom: 12px;
    }

    #device-page .block-document .row > [class*="col-"] {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }

    #device-page .block-document .row > [class*="col-"]:first-child {
        font-size: 12px;
        color: #667085;
    }

    #device-page .block-document .row > [class*="col-"]:last-child {
        font-size: 13px;
        color: #111827;
        font-weight: 500;
        overflow-wrap: anywhere;
    }
}

/* =====================================
   MPR UI - Desktop spacing refinement
   ===================================== */

@media (min-width: 1100px) {

    /* Область выбранных фильтров */
    #main-page > .js-tags-container {
        margin-top: 6px;
        margin-bottom: 8px !important;
    }

    /* Контейнер результатов */
    #result-offset-limit {
        margin-top: 0 !important;
    }

    /* Таблица */
    #result {
        margin-top: 8px !important;
        padding: 12px 16px 0;
    }

    /* Убираем лишний нижний отступ таблицы Bootstrap */
    #result .table {
        margin-bottom: 0;
    }

    /* Пагинация */
    #offset-limit {
        margin-top: 0 !important;
        margin-bottom: 24px !important;
        padding: 14px 18px;
    }

    #offset-limit .row {
        align-items: center;
    }

    #pagination-offset {
        margin-bottom: 0;
    }
}

/* =====================================
   MPR Desktop - Compact model column
   ===================================== */

@media (min-width: 1100px) {

    /* Ограничиваем только текст модели в шестом столбце */
    #result tbody td:nth-child(6) > span:nth-child(2) {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        line-clamp: 4;
        overflow: hidden;
        overflow-wrap: anywhere;
        line-height: 1.5;
        max-height: 6em;
    }

    /* При наведении открываем полный текст модели */
    #result tbody td:nth-child(6):hover > span:nth-child(2) {
        display: block;
        max-height: 220px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-line-clamp: unset;
        line-clamp: unset;
        background: #f3f7ff;
        border-radius: 6px;
    }

}

/* MPR Desktop - Connect table and pagination */
@media (min-width: 1100px) {
    #main-page #result {
        margin-bottom: 0 !important;
        border-bottom: none;
        border-radius: 20px 20px 0 0;
    }

    #main-page #offset-limit {
        margin-top: 0 !important;
        border-top: 1px solid #edf2f8;
        border-radius: 0 0 20px 20px;
    }
}

/* MPR Desktop - Catalogue code under device name */

.mpr-catalogue-code {
    display: none;
}

@media (min-width: 1100px) {
    #result .mpr-catalogue-code {
        display: block;
        margin-top: 7px;
        padding-top: 5px;
        border-top: 1px solid #edf2f8;
        font-size: 11px;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    #result .mpr-catalogue-label {
        color: #718096;
        font-weight: 400;
    }

    #result .mpr-catalogue-value {
        color: #2d5ca6;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }
}

/* =====================================
   MPR UI v1.5 - Desktop device details
   ===================================== */

@media (min-width: 1100px) {

    /* Основной контейнер карточки */
    #device-page {
        padding-top: 20px;
        padding-bottom: 32px;
    }

    #device-page > .content {
        padding: 28px 36px 36px;
        border-radius: 18px;
        box-shadow: 0 8px 28px rgba(24, 39, 75, 0.05);
    }

    /* Заголовки разделов */
    #device-page .info h3 {
        font-size: 24px;
        line-height: 1.35;
        margin-bottom: 18px;
    }

    #device-page .info h5 {
        font-size: 19px;
        line-height: 1.4;
        margin-top: 20px;
        margin-bottom: 12px;
    }

    /* Строки характеристик */
    #device-page .device-row-info {
        min-height: 36px;
        margin-bottom: 6px;
        align-items: start;
    }

    #device-page .device-row-info > .col-3 {
        color: #667085;
        font-size: 13px;
        line-height: 1.6;
    }

    #device-page .device-row-info > .col-9 {
        font-size: 14px;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }

    /* Разделители между блоками */
    #device-page hr {
        margin: 22px 0;
        border-color: #e4eaf2;
    }

    /* Документы соответствия */
    #device-page .block-document {
        border: 1px solid #dce3ec;
        border-radius: 14px;
        padding: 18px;
        background: #ffffff;
        margin-bottom: 14px !important;
    }

    #device-page .block-document .device-row-info {
        min-height: 32px;
        margin-bottom: 6px;
    }

    /* Переход обратно к списку */
    #device-page #go_to_list {
        display: inline-block;
        color: #2d5ca6;
        font-weight: 500;
        text-decoration: none;
    }

    #device-page #go_to_list:hover {
        text-decoration: underline;
    }
}

/* MPR Desktop - Full device description */
@media (min-width: 1100px) {

    #device-page .text-overflow {
        max-height: none;
        overflow-y: visible;
    }

    #device-page .device-description,
    #device-page .device-descriptionEn {
        max-height: none;
        overflow: visible;
        line-height: 1.65;
        overflow-wrap: anywhere;
    }

}

/* =====================================
   MPR Desktop - Hide empty device fields
   ===================================== */

@media (min-width: 1100px) {

    #device-page .device-row-info.mpr-empty-field {
        display: none !important;
    }

}

/* MPR Desktop - Hide empty classifier section */

@media (min-width: 1100px) {

    #device-page .mpr-empty-classifier {
        display: none !important;
    }

}
