/* Wiki Article Tables - New Design from Figma */

/* ── Collapsible Table Wrapper (как Contents / new_design CollapsibleSection) ── */
.wiki-table-collapsible {
    margin-top: clamp(12px, 1vw, 20px);
    margin-bottom: clamp(12px, 1vw, 20px);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: clamp(8px, 0.6vw, 12px);
    overflow: hidden;
    background: #ffffff;
}

.wiki-table-collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: clamp(10px, 0.55vw, 14px) clamp(12px, 1vw, 18px);
    background: linear-gradient(135deg, #5b6dd3, #5b6dd3dd);
    border: none;
    color: #ffffff;
    font-size: clamp(12px, 0.82vw, 15px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.wiki-table-collapsible-header:hover {
    background: linear-gradient(135deg, #6b7de3, #6b7de3dd);
}

.wiki-table-collapsible-title {
    flex: 1;
    text-align: left;
}

.wiki-table-collapsible-icon {
    width: clamp(14px, 0.85vw, 18px) !important;
    height: clamp(14px, 0.85vw, 18px) !important;
    flex-shrink: 0;
    margin-left: 8px;
    transition: transform 0.3s ease;
}

.wiki-table-collapsible-header[aria-expanded="true"] .wiki-table-collapsible-icon {
    transform: rotate(180deg);
}

.wiki-table-collapsible--collapsed .wiki-table-collapsible-icon {
    transform: rotate(0deg);
}

.wiki-table-collapsible-body {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.wiki-table-collapsible--collapsed .wiki-table-collapsible-body {
    max-height: 0;
}

/* Table Wrapper */
.article-text .table-wrapper-content {
    margin-top: 2vw !important;
    margin-bottom: 1.5vw !important;
    position: relative !important;
    width: 100% !important;
}

/* Hide ALL editor controls - aggressive removal */
.article-text .table-wrapper-content .table-side-controls,
.article-text .table-wrapper-content .table-control-btn,
.article-text .table-wrapper-content .table-add-row-btn,
.article-text .table-wrapper-content .table-add-col-btn,
.article-text .table-wrapper-content .table-delete-btn,
.article-text .table-wrapper-content .wrapper-controls,
.article-text .table-wrapper-content .wrapper-overlay,
.article-text .table-wrapper-content button,
.article-text .table-wrapper-content .button,
.article-text .table-wrapper-content [class*="control"],
.article-text .table-wrapper-content [class*="btn"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Scroll Container with custom scrollbar — clamp для мобильных */
.article-text .table-wrapper-content .wiki-table-scroll-container,
.wiki-table-collapsible-body .wiki-table-scroll-container {
    max-height: min(40vw, 400px) !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    border-radius: clamp(4px, 0.4vw, 8px) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

@media (max-width: 639px) {
    .article-text .table-wrapper-content .wiki-table-scroll-container,
    .wiki-table-collapsible-body .wiki-table-scroll-container {
        max-height: min(60vh, 320px) !important;
    }
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table-scroll-container {
    border-color: rgba(0, 0, 0, 0.15) !important;
}

/* Custom Scrollbar Styles */
.article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar {
    width: 0.4vw !important;
    height: 0.4vw !important;
}

.article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 0.2vw !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02) !important;
}

.article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.25) !important;
    border-radius: 0.2vw !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2) !important;
}

.article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.4) !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.35) !important;
}

/* Table Styles */
.article-text .table-wrapper-content .wiki-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.9vw !important;
    margin: 0 !important;
}

/* Table Title Row - First row in table, above column headers */
.article-text .table-wrapper-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
}

/* Table title row - inside table, first row above thead (column headers) — непрозрачный фон, фиксирован */
.article-text .table-wrapper-content .wiki-table .table-title-row {
    display: table-row !important;
}

.article-text .table-wrapper-content .wiki-table .table-title-row th {
    display: table-cell !important;
    padding: 1vw 1.5vw !important;
    font-size: 1.1vw !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    letter-spacing: -0.02vw !important;
    line-height: 1.4 !important;
    color: rgba(255, 255, 255, 1) !important;
    text-align: center !important;
    background-color: #ffffff !important;
    border: none !important;
    border-bottom: 0.1vw solid rgba(0, 0, 0, 0.1) !important;
    cursor: default !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 11 !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table .table-title-row th {
    color: rgba(0, 0, 0, 1) !important;
    background-color: #ffffff !important;
    border-bottom-color: rgba(0, 0, 0, 0.1) !important;
}

/* Ensure scroll container is full width */
.article-text .table-wrapper-content .wiki-table-scroll-container {
    width: 100% !important;
    flex: 0 0 auto !important;
}

/* Hide original caption in table */
.article-text .table-wrapper-content .wiki-table caption {
    display: none !important;
}

/* Table Header — фиксирован, непрозрачный белый фон */
.article-text .table-wrapper-content .wiki-table thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

.article-text .table-wrapper-content .wiki-table thead tr {
    background-color: #ffffff !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table thead tr {
    background-color: #ffffff !important;
}

.article-text .table-wrapper-content .wiki-table thead th {
    padding: 1vw !important;
    text-align: center !important;
    vertical-align: middle !important;
    font-weight: 600 !important;
    color: rgba(0, 0, 0, 0.9) !important;
    background-color: #ffffff !important;
    border-bottom: 0.15vw solid rgba(0, 0, 0, 0.15) !important;
    border-right: 0.08vw solid rgba(0, 0, 0, 0.1) !important;
    min-width: 8vw !important;
    max-width: 20vw !important;
    white-space: nowrap !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table thead th {
    color: rgba(0, 0, 0, 0.9) !important;
    background-color: #ffffff !important;
    border-bottom-color: rgba(0, 0, 0, 0.15) !important;
    border-right-color: rgba(0, 0, 0, 0.1) !important;
}

.article-text .table-wrapper-content .wiki-table thead th:last-child {
    border-right: none !important;
}

/* Table Body */
.article-text .table-wrapper-content .wiki-table tbody tr {
    background-color: transparent !important;
    transition: background-color 0.2s ease !important;
}

.article-text .table-wrapper-content .wiki-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.01) !important;
}

.article-text .table-wrapper-content .wiki-table tbody tr:hover {
    background-color: rgba(139, 92, 246, 0.08) !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table tbody tr:hover {
    background-color: rgba(139, 92, 246, 0.05) !important;
}

/* Table Cells */
.article-text .table-wrapper-content .wiki-table tbody td,
.article-text .table-wrapper-content .wiki-table tbody th {
    padding: 1vw !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border-bottom: 0.05vw solid rgba(255, 255, 255, 0.08) !important;
    border-right: 0.08vw solid rgba(255, 255, 255, 0.08) !important;
    min-width: 8vw !important;
    max-width: 20vw !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-align: center !important;
    vertical-align: middle !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table tbody td,
[data-theme="light"] .article-text .table-wrapper-content .wiki-table tbody th {
    color: rgba(0, 0, 0, 0.8) !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
    border-right-color: rgba(0, 0, 0, 0.08) !important;
}

.article-text .table-wrapper-content .wiki-table tbody td:last-child,
.article-text .table-wrapper-content .wiki-table tbody th:last-child {
    border-right: none !important;
}

.article-text .table-wrapper-content .wiki-table tbody tr:last-child td,
.article-text .table-wrapper-content .wiki-table tbody tr:last-child th {
    border-bottom: none !important;
}

/* Row Headers (first column) */
.article-text .table-wrapper-content .wiki-table tbody th {
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="light"] .article-text .table-wrapper-content .wiki-table tbody th {
    color: rgba(0, 0, 0, 0.9) !important;
}

/* Disable editing - contenteditable is removed via JS */
.article-text .table-wrapper-content .wiki-table *[contenteditable="true"] {
    -webkit-user-select: text !important;
    user-select: text !important;
    cursor: default !important;
    outline: none !important;
}

/* Remove all hover lines and editor indicators */
.article-text .table-wrapper-content .table-hover-line,
.article-text .table-wrapper-content .hover-line,
.article-text .table-wrapper-content .resize-handle {
    display: none !important;
}

