/* ---------- Обёртка и сообщения ---------- */
.tp-component .tp-msg {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 14px;
}
.tp-component .tp-msg-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.tp-component .tp-msg-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.tp-component .tp-admin-panel {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #28a745;
    border-radius: 6px;
}
.tp-component .tp-info-box {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 12px;
    margin-bottom: 15px;
    color: #856404;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
}

.tp-component .tp-paste-area {
    width: 100%;
    min-height: 250px;
    max-height: 500px;
    overflow-y: auto;
    padding: 12px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}
.tp-component .tp-paste-area:empty::before {
    content: attr(data-placeholder);
    color: #999;
}
.tp-component .tp-paste-area table {
    border-collapse: collapse;
}
.tp-component .tp-paste-area td,
.tp-component .tp-paste-area th {
    border: 1px solid #ddd;
    padding: 4px 6px;
}

.tp-component .tp-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    margin-right: 10px;
    margin-top: 10px;
    transition: background 0.2s;
}
.tp-component .tp-btn-save { background-color: #28a745; color: #fff; }
.tp-component .tp-btn-save:hover { background-color: #218838; }
.tp-component .tp-btn-cancel { background-color: #dc3545; color: #fff; }
.tp-component .tp-btn-cancel:hover { background-color: #c82333; }
.tp-component .tp-btn-edit { background-color: #007bff; color: #fff; margin-bottom: 15px; }
.tp-component .tp-btn-edit:hover { background-color: #0056b3; }

/* ---------- Вывод таблицы: параметры отображения ---------- */
.tp-component .tp-table-wrap {
    overflow-x: auto;
    padding: 2px;
    width: 100%;
}

/* Выравнивание и ширина таблицы */
.tp-component .tp-table-wrap.tp-align-left table {
    margin-left: 0 !important;
    margin-right: auto !important;
}
.tp-component .tp-table-wrap.tp-align-center table {
    margin-left: auto !important;
    margin-right: auto !important;
}
.tp-component .tp-table-wrap.tp-align-right table {
    margin-left: auto !important;
    margin-right: 0 !important;
}

.tp-component .tp-table-wrap.tp-width-full table {
    width: 100% !important;
}
.tp-component .tp-table-wrap.tp-width-auto table {
    width: auto !important;
    max-width: 100%;
}

/* Отступы в ячейках */
.tp-component .tp-table-wrap table td p,
.tp-component .tp-table-wrap table th p,
.tp-component .tp-table-wrap table td div,
.tp-component .tp-table-wrap table th div {
    margin: 0 !important;
    line-height: 1.35 !important;
}

/* Единый шрифт */
.tp-component .tp-table-wrap table,
.tp-component .tp-table-wrap table * {
    font-family: inherit !important;
}

/* Отступы в ячейках через CSS-переменные */
.tp-component .tp-table-wrap table td,
.tp-component .tp-table-wrap table th {
    padding: var(--tp-cell-padding-v, 8px) var(--tp-cell-padding-h, 12px);
}

/* Дополнительные улучшения для стабильной верстки */
.tp-component .tp-table-wrap table td,
.tp-component .tp-table-wrap table th {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
}

/* Ширина столбцов через colgroup в пикселях */
.tp-component .tp-table-wrap.tp-has-colgroup table {
    table-layout: fixed;
}

.tp-component .tp-table-wrap.tp-has-colgroup table col {
    display: table-column;
}

/* ---------- Изменение ширины столбцов мышью ---------- */
.tp-component .tp-resize-hint {
    font-size: 13px;
    color: #666;
    margin: 8px 0;
}
.tp-component .tp-col-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 5;
    user-select: none;
    background: transparent;
    transition: background 0.2s;
}
.tp-component .tp-col-resize-handle:hover,
.tp-component .tp-col-resize-handle.tp-resizing {
    background: rgba(0, 123, 255, 0.3);
}
.tp-component .tp-col-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    right: 2px;
    width: 2px;
    height: 100%;
    background: transparent;
    transition: background 0.2s;
}
.tp-component .tp-col-resize-handle:hover::after,
.tp-component .tp-col-resize-handle.tp-resizing::after {
    background: #007bff;
}

.tp-component .tp-col-resize-handle.tp-resizing ~ * {
    user-select: none;
}

/* Зебра */
.tp-component .tp-table-wrap.tp-striped table tr:nth-child(even) td,
.tp-component .tp-table-wrap.tp-striped table tr:nth-child(even) th {
    background-color: rgba(0, 0, 0, 0.035);
}

/* ---------- Границы таблицы ---------- */
.tp-component .tp-table-wrap table[data-has-borders="1"] td,
.tp-component .tp-table-wrap table[data-has-borders="1"] th {
    border: var(--tp-border-width, 1px) solid var(--tp-border-color, #cccccc) !important;
}

.tp-component .tp-table-wrap.tp-bordered table {
    border-collapse: collapse;
    border: var(--tp-border-width, 1px) solid var(--tp-border-color, #cccccc);
}

.tp-component .tp-table-wrap.tp-bordered table td,
.tp-component .tp-table-wrap.tp-bordered table th {
    border: var(--tp-border-width, 1px) solid var(--tp-border-color, #cccccc) !important;
}

.tp-component .tp-table-wrap.tp-bordered table[data-has-borders="1"] td,
.tp-component .tp-table-wrap.tp-bordered table[data-has-borders="1"] th {
    border: var(--tp-border-width, 1px) solid var(--tp-border-color, #cccccc) !important;
}

/* ---------- Выравнивание текста в ячейках ---------- */
.tp-component .tp-table-wrap.tp-cell-align-left table td,
.tp-component .tp-table-wrap.tp-cell-align-left table th {
    text-align: left !important;
}

.tp-component .tp-table-wrap.tp-cell-align-center table td,
.tp-component .tp-table-wrap.tp-cell-align-center table th {
    text-align: center !important;
}

.tp-component .tp-table-wrap.tp-cell-align-right table td,
.tp-component .tp-table-wrap.tp-cell-align-right table th {
    text-align: right !important;
}

/* ---------- Вертикальное выравнивание ---------- */
.tp-component .tp-table-wrap.tp-cell-valign-top table td,
.tp-component .tp-table-wrap.tp-cell-valign-top table th {
    vertical-align: top !important;
}

.tp-component .tp-table-wrap.tp-cell-valign-middle table td,
.tp-component .tp-table-wrap.tp-cell-valign-middle table th {
    vertical-align: middle !important;
}

.tp-component .tp-table-wrap.tp-cell-valign-bottom table td,
.tp-component .tp-table-wrap.tp-cell-valign-bottom table th {
    vertical-align: bottom !important;
}

/* ---------- Заголовок таблицы ---------- */
.tp-component .tp-table-wrap.tp-bold-header table tr:first-child td,
.tp-component .tp-table-wrap.tp-bold-header table tr:first-child th {
    font-weight: bold !important;
}

.tp-component .tp-table-wrap table th {
    font-weight: bold;
}

.tp-component .tp-table-wrap:not(.tp-bold-header) table th {
    font-weight: normal;
}

/* ---------- Адаптивность ---------- */
@media (max-width: 768px) {
    .tp-component .tp-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tp-component .tp-table-wrap table {
        font-size: 13px;
    }
    
    .tp-component .tp-paste-area {
        min-height: 150px;
        max-height: 300px;
        font-size: 12px;
    }
    
    .tp-component .tp-btn {
        padding: 8px 16px;
        font-size: 13px;
        width: 100%;
        margin-right: 0;
        text-align: center;
    }
    
    .tp-component .tp-btn-edit {
        width: 100%;
        text-align: center;
    }
    
    .tp-component .tp-admin-panel {
        padding: 15px;
    }
    
    .tp-component .tp-info-box {
        font-size: 12px;
        padding: 10px;
    }
}

/* ---------- Печать ---------- */
@media print {
    .tp-component .tp-admin-panel,
    .tp-component .tp-btn,
    .tp-component .tp-resize-hint,
    .tp-component .tp-col-resize-handle {
        display: none !important;
    }
    
    .tp-component .tp-table-wrap {
        overflow: visible !important;
        padding: 0 !important;
    }
    
    .tp-component .tp-table-wrap table {
        page-break-inside: avoid;
    }
}

/* ---------- Скроллбар ---------- */
.tp-component .tp-table-wrap::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.tp-component .tp-table-wrap::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tp-component .tp-table-wrap::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.tp-component .tp-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ---------- Дополнительные стили ---------- */
.tp-component .tp-table-wrap p em {
    color: #999;
    font-style: italic;
}

.tp-component .tp-paste-area:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.tp-component .tp-paste-area table {
    width: 100%;
    border-collapse: collapse;
}

.tp-component .tp-paste-area table td,
.tp-component .tp-paste-area table th {
    border: 1px solid #dee2e6;
    padding: 6px 8px;
}

.tp-component .tp-table-wrap table tbody tr:hover td,
.tp-component .tp-table-wrap table tbody tr:hover th {
    background-color: rgba(0, 123, 255, 0.04);
}

/* ---------- Ширина столбцов ---------- */
.tp-component .tp-table-wrap.tp-has-colgroup table {
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
}

.tp-component .tp-table-wrap.tp-has-colgroup table col {
    display: table-column;
}

/* Убеждаемся, что ширина таблицы не сжимается */
.tp-component .tp-table-wrap table {
    min-width: 100%;
}

/* ---------- Уведомления ---------- */
.tp-resize-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    transition: opacity 0.5s;
}
.tp-resize-notification.tp-msg-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.tp-resize-notification.tp-msg-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
/* ---------- Название таблицы ---------- */
.tp-component .tp-title-wrap {
    margin-bottom: 12px;
}

.tp-component .tp-title-wrap.tp-title-align-left {
    text-align: left;
}
.tp-component .tp-title-wrap.tp-title-align-center {
    text-align: center;
}
.tp-component .tp-title-wrap.tp-title-align-right {
    text-align: right;
}

.tp-component .tp-table-title {
    margin: 0 0 8px 0;
    padding: 8px 12px;
    font-size: 18px;
    font-weight: bold;
    color: #212529;
    line-height: 1.3;
    border-radius: 4px;
    transition: background 0.2s, outline 0.2s;
}

/* Название в режиме редактирования */
.tp-component .tp-table-title[contenteditable="true"] {
    cursor: text;
    outline: 1px dashed #ced4da;
    background: #fdfdfd;
}
.tp-component .tp-table-title[contenteditable="true"]:hover {
    background: #f5f5f5;
    outline: 1px dashed #007bff;
}
.tp-component .tp-table-title[contenteditable="true"]:focus {
    outline: 2px solid #007bff;
    background: #fff;
}

/* Пустое название */
.tp-component .tp-table-title.tp-title-empty:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    font-weight: normal;
}

.tp-component .tp-title-edit-wrap {
    display: inline-block;
    width: 100%;
}

.tp-component .tp-title-hint {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Поле ввода названия в форме редактирования */
.tp-component .tp-title-field {
    margin-bottom: 15px;
}
.tp-component .tp-title-field label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 14px;
    color: #333;
}
.tp-component .tp-title-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.tp-component .tp-title-input:focus {
    outline: 2px solid #007bff;
    outline-offset: -1px;
    border-color: #007bff;
}