/**
 * Принудительные стили для таблиц Dashplex Striped
 * Переопределяет Yii2 GridView и другие стили
 * Version: 2.0
 */

/* === ПРИНУДИТЕЛЬНОЕ ПРИМЕНЕНИЕ СТИЛЕЙ === */

/* Все таблицы получают полосатый стиль */
table.table,
.grid-view table,
.list-view table,
.table-responsive table,
.card table,
.card-body table,
div[class*="grid"] table,
div[id*="grid"] table,
table[class*="table"] {
    /* Базовые стили */
    width: 100% !important;
    margin-bottom: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/* Полосатые строки (зебра) - ПРИНУДИТЕЛЬНО */
table.table tbody tr:nth-of-type(odd),
.grid-view table tbody tr:nth-of-type(odd),
.table-striped tbody tr:nth-of-type(odd),
table tbody tr:nth-child(odd):not(.filters):not(.summary) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

table.table tbody tr:nth-of-type(even),
.grid-view table tbody tr:nth-of-type(even),
.table-striped tbody tr:nth-of-type(even),
table tbody tr:nth-child(even):not(.filters):not(.summary) {
    background-color: transparent !important;
}

/* Для темной темы */
.dark-theme table.table tbody tr:nth-of-type(odd),
.dark-theme .grid-view table tbody tr:nth-of-type(odd),
.dark-theme .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

/* Hover эффект - усиленный */
table.table tbody tr:hover,
.grid-view table tbody tr:hover,
.table-hover tbody tr:hover,
table tbody tr:hover:not(.filters):not(.summary) {
    background-color: rgba(0, 0, 0, 0.06) !important;
    transition: background-color 0.15s ease-in-out;
}

.dark-theme table.table tbody tr:hover,
.dark-theme .grid-view table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

/* Границы таблиц */
table.table,
.grid-view table,
.table-bordered,
table.border {
    border: 1px solid #e8e8f7 !important;
}

/* Границы ячеек */
table.table th,
table.table td,
.grid-view table th,
.grid-view table td {
    border: 1px solid #e8e8f7 !important;
    padding: 0.75rem !important;
    vertical-align: middle !important;
}

/* Заголовки таблиц */
table.table thead,
.grid-view table thead {
    background-color: #f8f9fa !important;
}

table.table thead th,
.grid-view table thead th {
    font-weight: 600 !important;
    color: #495057 !important;
    border-bottom: 2px solid #dee2e6 !important;
    white-space: nowrap !important;
}

.dark-theme table.table thead,
.dark-theme .grid-view table thead {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.dark-theme table.table thead th,
.dark-theme .grid-view table thead th {
    color: #e1e3e6 !important;
}

/* === СПЕЦИАЛЬНЫЕ СТИЛИ ДЛЯ YII2 GRIDVIEW === */

/* Убираем стандартные стили GridView */
.grid-view {
    padding: 0 !important;
}

.grid-view .summary {
    padding: 10px 0 !important;
    color: #6c757d !important;
}

/* Фильтры GridView */
.grid-view .filters input,
.grid-view .filters select {
    width: 100% !important;
    padding: 0.375rem 0.75rem !important;
    font-size: 0.875rem !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
}

.grid-view .filters td {
    padding: 0.5rem !important;
    background-color: #f8f9fa !important;
}

/* Пагинация */
.grid-view .pagination {
    margin-top: 1rem !important;
}

/* === RESPONSIVE ТАБЛИЦЫ === */

.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 0 !important;
}

.table-responsive table {
    min-width: 100% !important;
}

/* Предотвращение переноса текста */
.text-nowrap,
table.table td,
table.table th {
    white-space: nowrap !important;
}

@media (min-width: 768px) {
    .text-md-nowrap {
        white-space: nowrap !important;
    }
}

/* === КНОПКИ В ТАБЛИЦАХ === */

table .btn,
.grid-view .btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    margin: 0 2px !important;
}

table .btn-group,
.grid-view .btn-group {
    display: inline-flex !important;
    vertical-align: middle !important;
}

/* === СОРТИРОВКА === */

.grid-view th a,
table th[data-sort],
th.sorting,
th.sorting_asc,
th.sorting_desc {
    cursor: pointer !important;
    position: relative !important;
    user-select: none !important;
}

.grid-view th a:after,
th.sorting:after {
    content: "⇅" !important;
    position: absolute !important;
    right: 5px !important;
    opacity: 0.5 !important;
}

.grid-view th a.asc:after,
th.sorting_asc:after {
    content: "↑" !important;
    opacity: 1 !important;
}

.grid-view th a.desc:after,
th.sorting_desc:after {
    content: "↓" !important;
    opacity: 1 !important;
}

/* === ВЫБРАННЫЕ СТРОКИ === */

table tbody tr.selected,
.grid-view tbody tr.selected {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

table tbody tr.selected:hover,
.grid-view tbody tr.selected:hover {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

/* === СПЕЦИАЛЬНЫЕ КЛАССЫ === */

/* Компактные таблицы */
.table-sm th,
.table-sm td {
    padding: 0.3rem !important;
}

/* Таблицы без полос - исключение */
.table-no-stripe tbody tr,
table.table-no-stripe tbody tr {
    background-color: transparent !important;
}

/* === ПРИНУДИТЕЛЬНОЕ УДАЛЕНИЕ ОТСТУПОВ === */

.mg-b-0,
.mb-0,
table.table {
    margin-bottom: 0 !important;
}

/* === ФИКСЫ ДЛЯ КОНКРЕТНЫХ СТРАНИЦ === */

/* Domain проекты */
#domainsTable {
    width: 100% !important;
}

/* GSC проекты */
.gsc-table table,
#gsc-grid table {
    border-collapse: separate !important;
}

/* PBN Proxy */
.pbn-proxy-table {
    width: 100% !important;
}

/* === ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ === */

/* Скроллбар для таблиц */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Анимация при обновлении */
.dashplex-table tbody tr {
    transition: background-color 0.15s ease-in-out;
}

/* Badge в таблицах */
table .badge,
.grid-view .badge {
    font-size: 0.75rem !important;
    padding: 0.25em 0.4em !important;
}

/* Иконки в таблицах */
table .fe,
table .fa,
.grid-view .fe,
.grid-view .fa {
    font-size: 1rem !important;
    vertical-align: middle !important;
}

/* === ВАЖНЫЕ ПЕРЕОПРЕДЕЛЕНИЯ === */

/* Убираем конфликтующие стили */
.grid-view table.table-condensed {
    /* Переопределяем condensed */
}

.kv-table-wrap {
    /* Krajee GridView fix */
    padding: 0 !important;
}

/* DataTables совместимость */
table.dataTable {
    /* Сохраняем стили DataTables */
    border-collapse: separate !important;
}

/* === DEBUG КЛАСС === */

.dashplex-table.debug {
    border: 2px solid red !important;
}

/* === PRINT STYLES === */

@media print {
    table.table,
    .grid-view table {
        border: 1px solid #000 !important;
    }
    
    table.table th,
    table.table td {
        border: 1px solid #000 !important;
    }
    
    .table-striped tbody tr:nth-of-type(odd) {
        background-color: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

