/* ===============================
   TABLE SYSTEM
   =============================== */

/* Container */
.table-container {
    width: 100%;
    margin-top: 1rem;
}

/* Search Bar */
.table-search-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.table-search-wrapper svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-accent-solid);
    pointer-events: none;
    opacity: 0.7;
}

.table-search {
    width: 100%;
    padding: 0.7rem 0.75rem 0.7rem 2.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #181818;
    color: var(--color-text);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.table-search:focus {
    outline: none;
    border-color: var(--color-accent-solid);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.table-search::placeholder {
    color: #777;
}

/* Search result counter */
.table-search-count {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #777;
    pointer-events: none;
    transition: opacity 0.2s;
}

.table-search-count.hidden {
    opacity: 0;
}

/* Table Wrapper (scrollable) — .table-wrapper is legacy alias */
.table-wrapper,
.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    table-layout: auto;
}

.data-table th,
.data-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td.wrap {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: initial;
}

/* Header */
.data-table thead th {
    background: #222;
    color: var(--color-accent-solid);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid var(--color-accent-solid);
    user-select: none;
}

/* Sortable headers */
.data-table th[data-sort] {
    cursor: pointer;
    padding-right: 1.8rem;
    position: relative;
    transition: background 0.15s;
}

.data-table th[data-sort]:hover {
    background: #2a2a2a;
}

.data-table th[data-sort]::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.8rem;
}

.data-table th[data-sort].asc::after {
    content: '↑';
    opacity: 0.9;
    color: var(--color-accent-solid);
}

.data-table th[data-sort].desc::after {
    content: '↓';
    opacity: 0.9;
    color: var(--color-accent-solid);
}

/* Rows */
.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.08);
}

/* Remove left/right borders for cleaner look */
.data-table th:first-child,
.data-table td:first-child {
    border-left: none;
}

.data-table th:last-child,
.data-table td:last-child {
    border-right: none;
}

/* Column sizing hints */
.data-table .col-narrow {
    width: 80px;
    min-width: 80px;
}

.data-table .col-medium {
    width: 150px;
    min-width: 120px;
}

.data-table .col-wide {
    min-width: 200px;
}

.data-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

/* Action buttons in table */
.table-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: center;
}

.table-actions .btn-small {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    border-radius: 6px;
    white-space: nowrap;
}

/* .inline-form and badge variants defined in global.css */

/* No results row */
.table-no-results {
    text-align: center;
    padding: 2rem 1rem;
    color: #777;
    font-style: italic;
}

.table-no-results td {
    border-bottom: none;
}

/* ===============================
   PAGING BAR (neues System)
   =============================== */
.table-paging-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.5rem 0;
    user-select: none;
}

.paging-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.88rem;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.paging-btn:hover:not(:disabled) {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--color-accent-solid);
    color: var(--color-accent-solid);
}

.paging-btn.active {
    background: var(--color-accent-solid);
    border-color: var(--color-accent-solid);
    color: var(--color-bg);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.3);
}

.paging-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.paging-nav {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 32px;
}

.paging-ellipsis {
    padding: 0 0.25rem;
    color: #666;
    font-size: 0.9rem;
    line-height: 36px;
}

.paging-info {
    margin-left: 0.75rem;
    font-size: 0.8rem;
    color: #777;
    white-space: nowrap;
}

/* Legacy pagination (für htdocs-Seiten) */
.table-pagination {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    max-width: 100%;
    overflow-x: auto;
    padding: 0.5rem;
}

.table-pagination button {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    min-width: 36px;
    text-align: center;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.table-pagination button:hover {
    background: var(--color-accent-solid);
    color: var(--color-bg);
    transform: translateY(-1px);
}

.table-pagination button.active {
    background: var(--color-accent-solid);
    color: var(--color-bg);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(212, 175, 55, 0.3);
}

.table-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.table-pagination button:disabled:hover {
    background: var(--color-surface);
    color: var(--color-text);
    transform: none;
}

/* Table info (row count) */
.table-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: #777;
    padding: 0 0.25rem;
}

/* Search highlight */
.search-highlight {
    background: rgba(212, 175, 55, 0.25);
    border-radius: 2px;
    padding: 0 1px;
}

/* Grid row/col defined in global.css */

/* ===============================
   MOBILE CARD VIEW
   =============================== */
@media (max-width: 767px) {
    .table-scroll {
        border: none;
        overflow: visible;
    }

    .data-table {
        border: none;
        background: none;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .data-table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: 0.85rem;
        gap: 0.4rem;
    }

    .data-table tbody tr:nth-child(even) {
        background: var(--color-surface);
    }

    .data-table tbody tr:hover {
        border-color: var(--color-accent-solid);
        background: rgba(212, 175, 55, 0.05);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
        max-width: none;
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-top: 0.5rem;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-accent-solid);
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Actions row in card */
    .data-table td.actions {
        justify-content: flex-end;
    }

    .data-table td.actions::before {
        display: none;
    }

    .table-actions {
        width: 100%;
        justify-content: stretch;
    }

    .table-actions .btn-small {
        flex: 1;
        text-align: center;
    }

    .table-actions .inline-form {
        flex: 1;
    }

    .table-actions .inline-form .btn-small {
        width: 100%;
    }
}

/* Responsive Paging */
@media (max-width: 768px) {
    .table-paging-bar {
        gap: 0.2rem;
    }

    .paging-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .paging-nav {
        min-width: 28px;
        font-size: 0.95rem;
    }

    .paging-info {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-top: 0.35rem;
    }

    /* Legacy */
    .table-pagination {
        gap: 0.15rem;
        padding: 0.25rem;
    }

    .table-pagination button {
        padding: 0.3rem 0.5rem;
        min-width: 32px;
        font-size: 0.8rem;
    }
}
