/*
 * Единый вид таблиц (opt-in).
 *
 * Файл подключается только на страницах, которым он разрешён:
 *     @section('head')
 *         @include('_system.templates.tables')
 *     @stop
 * и действует только на таблицы с классом .table-app:
 *     <table class="table table-bordered table-hover table-striped table-app">
 * Остальные таблицы проекта не затрагиваются.
 */

.table-app {
    width: 100%;
    table-layout: auto;
}

.table-app > thead > tr > th {
    text-align: center;
    vertical-align: middle;
    background-color: #f5f5f5;
}

.table-app > tbody > tr > td,
.table-app > tbody > tr > th {
    vertical-align: middle;
    text-align: center;
}

/*
 * Колонки с длинными URL/строками без пробелов (class="table-app-wrap"):
 * переносятся где угодно, а не растягивают таблицу. В остальных колонках
 * (ФИО, названия) слова не рвутся — перенос только по пробелам.
 */
.table-app > tbody > tr > td.table-app-wrap {
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Короткие значения (сокращённая ссылка, коды): в одну строку, без переноса. */
.table-app > tbody > tr > td.table-app-nowrap {
    white-space: nowrap;
}

/* Текстовые колонки (описания, названия) — по левому краю. */
.table-app > tbody > tr > td.text-left {
    text-align: left;
}

/* Кнопка «копировать» рядом со ссылкой. */
.table-app .table-app-copy {
    margin-left: 6px;
    padding: 0 4px;
    font-size: 14px;
    line-height: 1;
    color: #555;
    background: none;
    border: 0;
    cursor: pointer;
}

.table-app .table-app-copy:hover {
    color: #000;
}

.table-app .table-app-copy.is-copied {
    color: #3c763d;
}

/* Колонка действий (иконки): без переноса, одинаковые отступы. */
.table-app .table-app-actions {
    white-space: nowrap;
}

.table-app .table-app-actions > a {
    margin: 0 3px;
    font-size: 14px;
    cursor: pointer;
}

/*
 * Иконки сортировки DataTables: вместо Glyphicons — Bootstrap Icons
 * (шрифт подключается вместе с этим файлом, см. templates/tables.blade.php).
 * Селекторы с .dataTable перекрывают datatables.min.css; шапка при scrollX
 * клонируется DataTables в отдельную таблицу с теми же классами.
 */
table.table-app.dataTable thead .sorting:after,
table.table-app.dataTable thead .sorting_asc:after,
table.table-app.dataTable thead .sorting_desc:after,
table.table-app.dataTable thead .sorting_asc_disabled:after,
table.table-app.dataTable thead .sorting_desc_disabled:after {
    font-family: 'bootstrap-icons';
    font-size: 12px;
    line-height: 1;
    bottom: 50%;
    right: 8px;
    margin-bottom: -6px;
    opacity: 1;
    color: #333;
}

table.table-app.dataTable thead .sorting:after {
    content: "\f127"; /* bi-arrow-down-up */
    color: #888;
}

table.table-app.dataTable thead .sorting_asc:after {
    content: "\f148"; /* bi-arrow-up */
}

table.table-app.dataTable thead .sorting_desc:after {
    content: "\f128"; /* bi-arrow-down */
}

/*
 * Правая рамка: DataTables (scrollX) задаёт таблице inline-ширину на 1px больше
 * контейнера, и рамка обрезается overflow. Ширина по контейнеру — рамка видна.
 */
.dataTables_scrollHeadInner {
    width: 100% !important;
}

.dataTables_scrollHeadInner > table.table-app,
.dataTables_scrollBody > table.table-app {
    width: 100% !important;
}

/* Шапка страницы: заголовок слева, главное действие справа. */
.table-app-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 20px;
    padding-bottom: 15px;
}

.table-app-toolbar h1 {
    margin: 0;
    font-size: 28px;
}

/* Группа справа в шапке: поиск + главное действие. */
.table-app-toolbar-actions {
    display: flex;
    align-items: center;
}

.table-app-toolbar-actions > .btn {
    margin-left: 12px;
}

.table-app-toolbar-actions > .dataTables_filter {
    margin: 0;
}

/* Поиск DataTables: поле с лупой внутри слева. */
.dataTables_filter {
    margin-bottom: 10px;
}

.dataTables_filter label {
    position: relative;
    display: inline-block;
    margin: 0;
    font-weight: normal;
    color: #999;
}

.dataTables_filter label > .bi-search {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    pointer-events: none;
}

div.dataTables_filter label input {
    width: 260px;
    height: 34px;
    /* поле перенесено в шапку, вне .dataTables_wrapper: стили DataTables на него не действуют */
    margin-left: 0;
    padding: 6px 12px 6px 30px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
}

div.dataTables_filter label input:focus {
    border-color: #66afe9;
    outline: 0;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px rgba(102, 175, 233, .6);
}
