/* Div Tables CSS - Professional Dark Mode Table Styles */

/* Table Container */
.base-div-table-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-small);
    margin-bottom: 2rem;
    position: relative;
}

.base-div-table {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Table Header - laut ui-widget-div-table-css.mdc Regel 005 UPPERCASE */
.base-div-table-header {
    display: flex;
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    font-size: var(--font-size-sm);
}

/* Eine Klasse pro Element (011-ui-html.mdc Regel 021): Header-Zeile = Header + Row */
.base-div-table-head-row {
    display: flex;
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border);
}

.base-div-table-head-cell {
    flex: 1;
    padding: 1rem;
    display: flex;
    align-items: center;
    font-size: var(--font-size-sm);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.base-div-table-head-cell:last-child {
    border-right: none;
}

.base-div-table-head-cell:hover {
    background: var(--color-primary-dark);
}

.base-div-table-header .base-div-table-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    /* Laut ui-widget-div-table-css.mdc Regel 006: Spaltenköpfe dürfen nicht umbrechen */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.base-div-table-header .base-div-table-cell:last-child {
    border-right: none;
}

/* Table Rows - laut ui-widget-div-table-css.mdc Regel 001 Hover-Effekt */
.base-div-table-row {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    transition: all 0.2s ease;
    background: var(--color-background);
}

.base-div-table-row:hover {
    background: var(--color-surface-hover);
}

.base-div-table-row:last-child {
    border-bottom: none;
}

/* Table Cells - laut ui-widget-div-table-css.mdc Regel 003 1px Gitternetz */
.base-div-table-cell {
    flex: 1;
    padding: 1rem;
    display: flex;
    align-items: center;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    border-right: 1px solid var(--color-border);
    /* Laut ui-widget-div-table-css.mdc Regel 004.001: white-space: normal für Textumbruch, kein horizontales Scrollen */
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary);
}

.base-div-table-cell:last-child {
    border-right: none;
}

/* First column – breit genug für Ort-Namen (z. B. berlin-content-manager), Rest für Nachbarspalte */
.base-div-table-cell.base-div-table-cell-narrow {
    flex: 0 0 auto;
    min-width: 18rem;
    max-width: 18rem;
}

/* Eine Klasse pro Element: Snippet-Zelle (align-items flex-start) in Base, Screen nutzt nur diese Klasse */
.base-div-table-cell-snippet {
    flex: 1;
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    border-right: 1px solid var(--color-border);
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary);
}

.base-div-table-cell-snippet:last-child {
    border-right: none;
}

/* Eine Klasse pro Element (011-ui-html.mdc Regel 021): schmale Zelle eigenstaendig */
.base-div-table-cell-narrow {
    flex: 0 0 auto;
    min-width: 18rem;
    max-width: 18rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    border-right: 1px solid var(--color-border);
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary);
}

/* Cell Content Alignment */
.base-div-table-cell.base-div-table-cell-left {
    justify-content: flex-start;
    text-align: left;
}

.base-div-table-cell.base-div-table-cell-center {
    justify-content: center;
    text-align: center;
}

.base-div-table-cell.base-div-table-cell-right {
    justify-content: flex-end;
    text-align: right;
}

/* Table Cell Types */
.base-div-table-cell.base-div-table-cell-number {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-medium);
}

.base-div-table-cell.base-div-table-cell-date {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.base-div-table-cell.base-div-table-cell-status {
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

/* Status Colors */
.base-div-table-cell-status-success {
    color: var(--color-success);
}

.base-div-table-cell-status-warning {
    color: var(--color-warning);
}

.base-div-table-cell-status-error {
    color: var(--color-error);
}

.base-div-table-cell-status-info {
    color: var(--color-info);
}

/* Responsive Design - 4 Breakpoints laut ui-css.mdc Regel 022 */
/* Mobile: max-width 576px - VERPFLICHTEND laut ui-widget-div-table-html.mdc Regel 009: Pro Zeile nur eine Spalte */
@media (max-width: 576px) {
    .base-div-table-container {
        /* STRENGSTENS VERBOTEN laut ui-widget-div-table-css.mdc Regel 004.001: overflow-x: auto entfernt */
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    .base-div-table {
        /* STRENGSTENS VERBOTEN laut ui-widget-div-table-css.mdc Regel 004.001: min-width entfernt, da es horizontales Scrollen verursacht */
        width: 100%;
        max-width: 100%;
    }
    
    /* VERPFLICHTEND laut ui-widget-div-table-html.mdc Regel 009: Header auf Mobile ausblenden */
    .base-div-table-header {
        display: none;
    }

    .base-div-table-head-row {
        display: none;
    }

    .base-div-table-cell-narrow {
        width: 100%;
        max-width: 100%;
        min-width: unset;
        padding: 0.5rem;
        font-size: var(--font-size-xs);
        white-space: normal;
        display: block;
        margin-bottom: 12px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    
    /* VERPFLICHTEND laut ui-widget-div-table-html.mdc Regel 009: Jede Body-Zelle volle Breite mit Spaltenname als Label */
    .base-div-table-cell {
        width: 100%;
        max-width: 100%;
        padding: 0.5rem;
        font-size: var(--font-size-xs);
        white-space: normal;
        display: block;
        margin-bottom: 12px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .base-div-table-cell[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: block;
    }

    .base-div-table-cell-narrow[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: block;
    }

    .base-div-table-cell-snippet[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: block;
    }
    
    .base-div-table-cell:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }

    .base-div-table-cell-snippet {
        width: 100%;
        max-width: 100%;
        padding: 0.5rem;
        font-size: var(--font-size-xs);
        white-space: normal;
        display: block;
        margin-bottom: 12px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .base-div-table-cell-snippet:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .base-div-table-row {
        flex-direction: column;
        border-bottom: 2px solid var(--color-border);
    }
}

/* Tablet/iPad: 600px-768px */
@media (min-width: 600px) and (max-width: 768px) {
    .base-div-table-cell {
        padding: 0.75rem;
        font-size: var(--font-size-xs);
    }
}

/* Kleiner Desktop/13-Zoll: 1024px-1366px */
@media (min-width: 1024px) and (max-width: 1366px) {
    .base-div-table-cell {
        padding: 0.75rem;
        font-size: var(--font-size-sm);
    }
}

/* Table Actions */
.base-div-table-cell .base-button-standard,
.base-div-table-cell .base-button-delete {
    margin: 0;
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-xs);
    min-height: 32px;
}

/* Table Sorting */
.base-div-table-header .base-div-table-cell {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.base-div-table-header .base-div-table-cell:hover {
    background: var(--color-primary-dark);
}

.base-div-table-header .base-div-table-cell::after {
    content: '↕';
    position: absolute;
    right: 0.5rem;
    opacity: 0.7;
    font-size: var(--font-size-xs);
}

.base-div-table-header .base-div-table-cell.base-div-table-cell-sorted-asc::after {
    content: '↑';
    opacity: 1;
}

.base-div-table-header .base-div-table-cell.base-div-table-cell-sorted-desc::after {
    content: '↓';
    opacity: 1;
}

/* Table Search */
.base-div-table-search {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.base-div-table-search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-small);
    font-family: var(--font-family-primary);
    font-size: var(--font-size-base);
}

/* Table Filters */
.base-div-table-filters {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.base-div-table-filter {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.base-div-table-filter-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.base-div-table-filter-select {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-small);
    font-family: var(--font-family-primary);
    font-size: var(--font-size-sm);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: var(--color-background);
    color: var(--color-text-primary);
    cursor: pointer;
}

/* Table Pagination */
.base-div-table-pagination {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    align-items: center;
    justify-content: center;
}

.base-text-pagination {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-left: 1rem;
}

/* Table Stats */
.base-div-table-stats {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}
