/* ============================================
   CENTRALIZED TABLE SYSTEM
   ============================================
   
   All tables across the application should use
   these standardized classes for consistency.
   
   DO NOT duplicate table styles in page-specific
   CSS files. Use these central definitions.
   
   Based on the Songs page table design.
   ============================================ */

/* ============================================
   TABLE CONTAINER
   ============================================ */

.table-container {
    flex: 1;
    overflow: auto;
}

/* ============================================
   BASE TABLE
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

    /* ============================================
   TABLE HEADER
   ============================================ */

    .data-table thead {
        position: sticky;
        top: 0;
        background: var(--bg-secondary, #f9fafb);
        z-index: 10;
    }

    /* Nested tables: header should be below parent table header */
    .expanded-row .data-table thead {
        top: auto;
        z-index: 5;
    }

    .data-table th {
        padding: 12px 16px;
        text-align: left;
        font-weight: 600;
        font-size: 14px;
        color: var(--text-secondary, #6b7280);
        border-bottom: 1px solid var(--border-color, #e5e7eb);
        user-select: none;
        text-transform: uppercase;
        position: relative;
    }

        /* Sortable headers */
        .data-table th.sortable {
            cursor: pointer;
        }

            .data-table th.sortable:hover {
                background: var(--bg-hover, #f3f4f6);
            }

    /* Sort icon */
    .data-table .sort-icon {
        margin-left: 4px;
        font-size: 10px;
    }

    /* ============================================
   TABLE BODY
   ============================================ */

    .data-table tbody tr {
        transition: background-color 0.15s;
        position: relative;
    }

        .data-table tbody tr:hover {
            background: var(--bg-hover, #f9fafb);
        }

        /* Clickable rows */
        .data-table tbody tr.clickable {
            cursor: pointer;
        }

        /* Selected row */
        .data-table tbody tr.selected {
            background: #eff6ff;
        }

            .data-table tbody tr.selected:hover {
                background: #dbeafe;
            }

    /* Table cells */
    .data-table td {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-color, #e5e7eb);
        font-size: 16px;
        color: var(--text-primary, #1f2937);
        position: relative;
    }

    /* Allow dropdowns to overflow from table cells */
    .data-table td:has(.planning-state-status) {
        overflow: visible !important;
    }

    /* Explicit overflow for status columns */
    .data-table .talk-status,
    .data-table .speaker-status,
    .data-table .col-status {
        overflow: visible !important;
    }

    /* ============================================
   COLUMN ALIGNMENT
   ============================================ */

    .data-table .text-left {
        text-align: left;
    }

    .data-table .text-center {
        text-align: center;
    }

    .data-table .text-right {
        text-align: right;
    }

    /* ============================================
   COMMON COLUMN TYPES
   ============================================ */

    /* Number/ID columns */
    .data-table .col-number,
    .data-table .col-id {
        width: 100px;
        font-weight: 500;
    }

    /* Name columns */
    .data-table .col-name {
        min-width: 200px;
    }

    /* Email columns */
    .data-table .col-email {
        min-width: 200px;
        color: var(--text-secondary, #6b7280);
    }

    /* Title columns */
    .data-table .col-title {
        min-width: 250px;
    }

    /* Description/Theme columns */
    .data-table .col-description,
    .data-table .col-theme {
        min-width: 200px;
    }

    /* Date/Time columns */
    .data-table .col-date,
    .data-table .col-modified,
    .data-table .col-expires {
        width: 150px;
        color: var(--text-secondary, #6b7280);
        font-size: 13px;
    }

    /* Status columns */
    .data-table .col-status {
        width: 120px;
    }

    /* Action columns */
    .data-table .col-actions {
        width: 150px;
        text-align: right;
    }

    /* Small action column (fewer buttons) */
    .data-table .col-actions-sm {
        width: 120px;
        text-align: right;
    }

    /* Roles/Tags columns */
    .data-table .col-roles,
    .data-table .col-tags {
        min-width: 250px;
    }

    /* ============================================
   ROW ACTIONS (Action Buttons in Rows)
   ============================================ */

    .data-table .row-actions {
        display: flex;
        gap: 4px;
        justify-content: flex-end;
        opacity: 0;
        transition: opacity 0.2s;
    }

    .data-table tbody tr:hover .row-actions {
        opacity: 1;
    }

/* Always show on touch devices */
@media (hover: none) {
    .data-table .row-actions {
        opacity: 1;
    }
}

/* ============================================
   TABLE STATES & VARIATIONS
   ============================================ */

/* Compact table (less padding) */
.data-table.table-compact th,
.data-table.table-compact td {
    padding: 8px 12px;
}

/* Striped rows */
.data-table.table-striped tbody tr:nth-child(even) {
    background: var(--bg-secondary, #f9fafb);
}

    .data-table.table-striped tbody tr:nth-child(even):hover {
        background: var(--bg-hover, #e5e7eb);
    }

/* Bordered table */
.data-table.table-bordered {
    border: 1px solid var(--border-color, #e5e7eb);
}

    .data-table.table-bordered th,
    .data-table.table-bordered td {
        border: 1px solid var(--border-color, #e5e7eb);
    }

/* No hover effect */
.data-table.table-no-hover tbody tr:hover {
    background: transparent;
}

/* ============================================
   SPECIAL CELL TYPES
   ============================================ */

/* User name cell with avatar */
.data-table .user-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-table .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Badge lists (roles, tags, etc.) */
.data-table .badge-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.data-table .badge {
    padding: 4px 10px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}

/* Status badges */
.data-table .status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

    .data-table .status-badge.status-pending {
        background: #fef3c7;
        color: #92400e;
    }

    .data-table .status-badge.status-accepted,
    .data-table .status-badge.status-active {
        background: #d1fae5;
        color: #065f46;
    }

    .data-table .status-badge.status-expired {
        background: #fee2e2;
        color: #991b1b;
    }

    .data-table .status-badge.status-revoked,
    .data-table .status-badge.status-inactive {
        background: #e5e7eb;
        color: #374151;
    }

/* Text muted */
.data-table .text-muted {
    color: var(--text-muted, #9ca3af);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.table-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary, #6b7280);
}

    .table-empty-state .empty-icon {
        width: 48px;
        height: 48px;
        color: var(--text-muted, #9ca3af);
        margin-bottom: 16px;
    }

    .table-empty-state p {
        font-size: 16px;
        margin: 0;
    }

/* ============================================
   LIST TOOLBAR (Search, Filters, etc.)
   ============================================ */

.list-toolbar {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
}

    /* Search box */
    .list-toolbar .search-box {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
    }

    .list-toolbar .search-icon {
        position: absolute;
        left: 12px;
        width: 20px;
        height: 20px;
        color: var(--text-muted, #9ca3af);
        pointer-events: none;
    }

    .list-toolbar .search-input {
        width: 100%;
        padding: 10px 40px;
        border: 1px solid var(--border-color, #e5e7eb);
        border-radius: 6px;
        font-size: 14px;
        background: white;
    }

        .list-toolbar .search-input:focus {
            outline: none;
            border-color: var(--primary-color, #3b82f6);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

    .list-toolbar .clear-search {
        position: absolute;
        right: 8px;
        padding: 4px;
        background: transparent;
        border: none;
        cursor: pointer;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .list-toolbar .clear-search:hover {
            background: var(--bg-hover, #f3f4f6);
        }

        .list-toolbar .clear-search svg {
            width: 20px;
            height: 20px;
            color: var(--text-muted, #9ca3af);
        }

    /* List info (count, etc.) */
    .list-toolbar .list-info {
        display: flex;
        align-items: center;
        color: var(--text-secondary, #6b7280);
        font-size: 14px;
        white-space: nowrap;
    }

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Smaller padding on mobile */
    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }

    .data-table {
        font-size: 13px;
    }

    /* Stack list toolbar on mobile */
    .list-toolbar {
        flex-direction: column;
    }

    /* Always show row actions on mobile */
    .data-table .row-actions {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    /* Even smaller padding on very small screens */
    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .data-table {
        font-size: 12px;
    }
}

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

@media print {
    .data-table .row-actions {
        display: none !important;
    }

    .data-table tbody tr {
        page-break-inside: avoid;
    }

    .list-toolbar {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
.data-table tbody tr:focus-visible {
    outline: 2px solid var(--primary-color, #3b82f6);
    outline-offset: -2px;
}

.data-table th:focus-visible {
    outline: 2px solid var(--primary-color, #3b82f6);
    outline-offset: -2px;
}

/* Screen reader only text */
.data-table .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
