/* =====================================================================
   Bagdar — общий современный слой стилей (2026)
   Подключается ПОСЛЕДНИМ в layout сайта (_Layout, _Layout_, _LayoutTestPage).
   Копия для админки: Bagdar.Admin.Web/Content/modern.css (+ admin-блок в конце).
   Разметку не меняет: только единые шрифты, цвета, кнопки, поля, окна и защита от "вылезающего" текста.
   ===================================================================== */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f0f4fa;
    --text: #0e1937;
    --text-muted: #5b6478;
    --border: #e1e6ef;
    --border-strong: #c9d1de;

    --primary: #2f80ed;
    --primary-hover: #1f6ad3;
    --primary-soft: #e8f1fd;
    --success: #27ae60;
    --success-hover: #1f9452;
    --danger: #e5484d;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 2px rgba(14, 25, 55, .06), 0 1px 3px rgba(14, 25, 55, .05);
    --shadow: 0 6px 20px rgba(14, 25, 55, .08);
    --shadow-lg: 0 24px 60px rgba(14, 25, 55, .22);
    --ring: 0 0 0 3px rgba(47, 128, 237, .28);

    --font: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --control-h: 44px;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- 1. База: шрифт, цвет, сглаживание ---------- */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

html,
body {
    overflow-x: hidden;   /* запасной вариант для старых браузеров */
    overflow-x: clip;     /* ничего не выезжает вбок, sticky не ломается */
    max-width: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Старые шрифты Roboto / SF Pro не загружаются (браузер показывал Times).
   Единый системный стек для всего текста; иконочные шрифты не трогаем. */
body,
body :where(*:not(.fa):not([class^="fa-"]):not([class*=" fa-"]):not(.glyphicon):not([class^="glyphicon-"]):not([class*=" glyphicon-"]):not(.k-icon):not([class*="k-i-"]):not([class^="icon-"]):not([class*=" icon-"])) {
    font-family: var(--font) !important;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
}

a {
    transition: color .15s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}

::selection {
    background: rgba(47, 128, 237, .22);
}

/* ---------- 2. Текст не вылезает ---------- */

h1, h2, h3, h4, h5, h6,
p, li, dt, dd, td, th, label, legend, blockquote, figcaption,
a, span, strong, b, em {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

h1, h2, h3, h4, h5, h6, p, li {
    -webkit-hyphens: auto;
    hyphens: auto;
}

img,
video,
svg:not(:root) {
    max-width: 100%;
}

img,
video {
    height: auto;
}

iframe,
embed,
object {
    max-width: 100%;
}

/* колонки bootstrap могут сжиматься, а не распирать строку */
.row > [class*="col"] {
    min-width: 0;
}

/* таблицы: прокрутка внутри, а не всей страницы */
table {
    max-width: 100%;
}

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

pre,
code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- 3. Кнопки ---------- */

.btn:not(.toggle):not(.toggle-on):not(.toggle-off):not(.toggle-handle),
.blue-btn,
.white-btn,
.concave-btn,
.h_search-btn,
button:not([class]),
input[type="submit"],
input[type="button"],
input[type="reset"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control-h);
    padding: 10px 22px;
    border-radius: var(--radius) !important;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none !important;
    white-space: normal;
    max-width: 100%;
    vertical-align: middle;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}

.btn:not(.toggle):not(.toggle-on):not(.toggle-off):not(.toggle-handle):hover,
.blue-btn:hover,
.white-btn:hover,
.concave-btn:hover,
.h_search-btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active,
.blue-btn:active,
.white-btn:active,
input[type="submit"]:active,
input[type="button"]:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:focus-visible,
.blue-btn:focus-visible,
.white-btn:focus-visible,
button:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: var(--ring) !important;
}

.btn:disabled,
.btn.disabled,
button:disabled,
input[type="submit"]:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ссылка-кнопка (переключатель языка и т.п.) — без "кнопочного" вида */
.btn.btn-link {
    min-height: 0;
    padding: 4px 8px;
    font-weight: 500;
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

.btn.btn-link:hover {
    text-decoration: none !important;
    opacity: .85;
}

/* основная (синяя) */
.blue-btn,
.btn-primary,
.h_search-btn {
    background: var(--primary) !important;
    border: 1px solid var(--primary) !important;
    color: #fff !important;
}

.blue-btn:hover,
.btn-primary:hover,
.h_search-btn:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: #fff !important;
}

/* вторичная (белая с рамкой) */
.white-btn,
.btn-default,
.btn-light,
.btn-secondary,
.btn-outline-primary {
    background: var(--surface) !important;
    border: 1px solid var(--border-strong) !important;
    color: var(--text) !important;
}

.white-btn:hover,
.btn-default:hover,
.btn-light:hover,
.btn-secondary:hover,
.btn-outline-primary:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: var(--primary-soft) !important;
}

.btn-success {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: #fff !important;
}

.btn-success:hover {
    background: var(--success-hover) !important;
    border-color: var(--success-hover) !important;
}

.btn-danger {
    background: var(--danger) !important;
    border-color: var(--danger) !important;
    color: #fff !important;
}

.btn-sm {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: var(--radius-sm) !important;
}

.btn-lg {
    min-height: 52px;
    padding: 12px 28px;
    font-size: 16px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* группы кнопок и поле+кнопка: скругляются только внешние углы */
.btn-group > .btn:not(:first-child),
.input-group > .btn:not(:first-child),
.input-group-append .btn,
.input-group-append > .input-group-text {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.btn-group > .btn:not(:last-child),
.input-group > .btn:not(:last-child),
.input-group-prepend .btn,
.input-group-prepend > .input-group-text {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group > .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* переключатель bootstrap-toggle — свой размер, не трогаем */
.toggle.btn {
    border-radius: 999px !important;
    overflow: hidden;
}

/* ---------- 4. Поля ввода ---------- */

.form-control:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="text"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="email"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="password"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="tel"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="number"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="search"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="url"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="date"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input[type="datetime-local"]:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
input:not([type]):where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
select:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)),
textarea:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)) {
    min-height: var(--control-h);
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
    max-width: 100%;
    box-shadow: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

select,
select.form-control {
    padding-right: 36px;
}

textarea,
textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.form-control:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):hover,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):hover,
select:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):hover,
textarea:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):hover {
    border-color: #a9b4c6;
}

.form-control:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):focus,
input:not([type="checkbox"]):not([type="radio"]):where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):focus,
select:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):focus,
textarea:where(:not(.k-input):not(.k-textbox):not(.k-widget *):not(.k-grid *):not(.select2-search__field):not(.toggle *)):focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: var(--ring) !important;
}

::placeholder {
    font-family: var(--font) !important;
    color: #98a1b3;
    opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

label {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 6px;
}

.text-danger,
.field-validation-error,
.validation-summary-errors {
    color: var(--danger) !important;
    font-size: 14px;
}

.input-validation-error {
    border-color: var(--danger) !important;
}

/* ---------- 5. Окна (bootstrap modal + окно входа #popup_bg) ---------- */

.modal-backdrop.show,
.modal-backdrop.in {
    opacity: .55;
}

.modal-backdrop {
    background: #0b1328;
}

.modal-dialog {
    max-width: min(560px, calc(100vw - 32px));
    margin-left: auto;
    margin-right: auto;
}

.modal-lg {
    max-width: min(900px, calc(100vw - 32px));
}

.modal-content {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
    background: var(--surface);
}

.modal-header,
.modal-footer {
    padding: 18px 24px;
    border-color: var(--border) !important;
}

.modal-footer {
    gap: 8px;
    flex-wrap: wrap;
}

.modal-body {
    padding: 20px 24px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-wrap: break-word;
}

.modal-title {
    font-size: 19px;
    font-weight: 700;
}

.modal .close,
.modal .btn-close {
    width: 36px;
    height: 36px;
    min-height: 0;
    padding: 0 !important;
    margin: -6px -8px -6px auto !important;
    border-radius: 50% !important;
    opacity: .6;
    transition: background-color .15s var(--ease), opacity .15s var(--ease);
}

.modal .close:hover {
    opacity: 1;
    background: var(--surface-2);
}

/* окно входа / регистрации */
#popup_bg {
    left: 0;
    background: rgba(11, 19, 40, .55) !important;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
}

#popup_bg .popup_block {
    width: min(860px, 100%) !important;
    margin: 8vh auto 16px !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

#popup_bg .popup_block .popup_block-right {
    padding: 28px 32px !important;
}

#popup_bg .pbr_close-btn {
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background-color .15s var(--ease);
}

#popup_bg .pbr_close-btn:hover {
    background: var(--surface-2);
}

#popup_bg input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
}

/* сторонние окна-уведомления */
.alertify .ajs-dialog,
.swal-modal,
.swal2-popup {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* ---------- 6. Карточки, списки, таблицы ---------- */

.card,
.panel,
.well {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
}

.card-header,
.panel-heading {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
}

.table {
    color: var(--text);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    border-color: var(--border) !important;
}

.table td {
    border-color: var(--border) !important;
    vertical-align: middle;
}

.dropdown-menu {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 6px !important;
}

.dropdown-item,
.dropdown-menu > li > a {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

.dropdown-item:hover,
.dropdown-menu > li > a:hover {
    background: var(--primary-soft) !important;
    color: var(--primary) !important;
}

.pagination .page-link,
.pagination > li > a,
.pagination > li > span {
    border-radius: var(--radius-sm) !important;
    margin: 0 3px;
    border-color: var(--border) !important;
}

.alert {
    border-radius: var(--radius) !important;
    border: 1px solid transparent;
}

.badge,
.label {
    border-radius: 999px;
    font-weight: 600;
}

/* ---------- 7. Шапка ---------- */

#hdline {
    background: var(--text) !important;
}

#header {
    background: var(--surface);
    box-shadow: 0 1px 0 var(--border);
}

#header .h_login {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 12px;
    min-width: 0;
}

#header .h_login span.h_login-in {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 6px 18px !important;
    border-radius: var(--radius) !important;
    white-space: nowrap;
}

#header .h_login span.h_login-reg {
    white-space: nowrap;
}

.h_search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.h_search-form .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

#hdline .hdline_left {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 16px;
}

#hdline .hdline_left > * {
    float: none !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    flex: 0 0 auto;
}

#header .h_login .h_login {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
}

#header .h_login {
    flex-wrap: nowrap;
}

/* при 992–1199px меню забирает ровно столько места, сколько осталось */
@media (min-width: 992px) {
    #header .container > .row > .col-md-8 {
        flex: 1 1 0;
        max-width: none;
        min-width: 0;
        padding-right: 20px;
    }

    #header .container > .row > .col-md-2.col-sm-12 {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        padding-left: 12px;
    }
}

#header .h_menu ul.h_menu-menu {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(10px, 1.15vw, 22px);
    margin: 0;
    padding-left: 0;
}

#header .h_menu ul.h_menu-menu > li {
    flex: 0 0 auto;
    margin: 0 !important;
    white-space: nowrap;
}

#header .h_menu ul li a {
    color: var(--text) !important;
    font-weight: 600;
}

#header .h_menu ul li a:hover {
    color: var(--primary) !important;
}

#header .h_menu ul li.h_menu-list {
    padding-right: 16px !important;
    background-size: 10px;
    background-position: right top 6px;
}

#header .h_menu ul li.h_menu-list:hover,
#header .h_menu ul li.h_menu-list.active {
    border-bottom-color: var(--primary) !important;
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    #header .h_menu ul.h_menu-menu {
        gap: 8px;
    }

    #header .h_menu ul li a {
        font-size: 13px !important;
    }
}

/* ---------- 8. Подвал и прочее ---------- */

footer a:hover,
#footer a:hover {
    color: var(--primary);
}

hr {
    border-color: var(--border);
    opacity: 1;
}

/* ---------- 9. Мобильные ---------- */

@media (max-width: 767.98px) {
    body {
        font-size: 15px;
    }

    h1 { font-size: clamp(24px, 6.5vw, 30px); }
    h2 { font-size: clamp(21px, 5.6vw, 26px); }
    h3 { font-size: clamp(18px, 4.8vw, 22px); }

    #popup_bg .popup_block {
        margin-top: 16px !important;
        display: block !important;
    }

    #popup_bg .popup_block .popup_block-left {
        display: none !important;
    }

    #popup_bg .popup_block .popup_block-right {
        display: block !important;
        width: 100% !important;
        padding: 24px 20px !important;
    }

    .modal-dialog {
        margin-top: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* на мобильном блок приветствия синий — ссылка должна быть видна */
    .ht_bagdar a {
        color: #fff !important;
        text-decoration: underline;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
