/* Table Layout & Container */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    /* Allows border-radius on rows/cells if needed */
    border-spacing: 0;
    width: 100%;
}

/* Headers */
.data-table th {
    background-color: #f8fafc;
    /* Slate 50 */
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    /* Default alignment left, overridden by utility classes */
    text-align: left;
    white-space: nowrap;
}

/* Cells */
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    /* Vertical Center */
    color: var(--text-main);
    font-size: 0.9rem;
}

/* Row Hover */
.data-table tbody tr:hover {
    background-color: #f8fafc;
    transition: background-color 0.2s;
}

@media (max-width: 768px) {

    /* Responsive Data Tables (Flex-Card View) */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td {
        display: block;
        width: 100%;
    }

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

    /* Visually hide headers for screen-readers */
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .data-table tbody tr {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        /* App-like radius */
        margin-bottom: 0.75rem;
        background: #fff;
        box-shadow: var(--shadow-sm);
        padding: 1rem;
    }

    .data-table td {
        border: none;
        position: relative;
        padding: 0;
        /* Gap handles spacing */
        font-size: 1rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        /* Truncation protection */
        min-width: 0;
    }

    /* Content Truncation */
    .data-table td>span,
    .data-table td>strong,
    .data-table td>.user-info,
    .task-title,
    .task-desc {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
    }

    /* Action Buttons Mobile Container */
    .data-table td:last-child,
    .data-table td[data-label="Actions"],
    .data-table td[data-label="Action"] {
        border-top: 1px dashed var(--border-color);
        padding-top: 0.75rem;
        margin-top: auto;
        /* Push to bottom */
        display: flex;
        flex-direction: row;
        justify-content: flex-end;
        /* Align actions to right */
        width: 100%;
    }

    /* Action Buttons Mobile Sizing (WCAG 44x44 min) */
    .data-table .action-group,
    .data-table .action-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.5rem;
        width: 100%;
    }

    .data-table .btn-sm,
    .data-table .btn-icon,
    .data-table .btn-action,
    .btn-circle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
    }
}

.row-escalated {
    background-color: #fff5f5;
}

.row-escalated:hover {
    background-color: #ffecec;
}

/* --- Column Specific Styles --- */

/* Task Column (Left Aligned, Wide) */
.col-task {
    width: 40%;
    text-align: left;
}

.task-title {
    display: block;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.task-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Center Alignment Utility for Status, Date, Actions */
.text-center {
    text-align: center !important;
}

/* --- Badges (Status Pills) --- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    /* Pill shape */
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    min-width: 80px;
    /* Uniform width */
}

/* Badge Variants (Refined for Contrast) */
.badge-created {
    background-color: #e0f2fe;
    /* Sky 100 */
    color: #0369a1;
    /* Sky 700 */
}

.badge-completed {
    background-color: #dcfce7;
    /* Green 100 */
    color: #15803d;
    /* Green 700 */
}

.badge-late {
    background-color: #fee2e2;
    /* Red 100 */
    color: #b91c1c;
    /* Red 700 */
}

.badge-escalated {
    background-color: #fee2e2;
    /* Red 100 */
    color: #991b1b;
    /* Red 900 */
    border: 1px solid #ef4444;
    /* Red 500 */
}

.badge-pending {
    background-color: #fef9c3;
    /* Yellow 100 */
    color: #854d0e;
    /* Yellow 800 */
    border: 1px solid #facc15;
    /* Yellow 400 */
}

/* Task Type Badges */
.badge-type-manual {
    background-color: #fef3c7;
    /* Amber 100 */
    color: #92400e;
    /* Amber 900 */
    border: 1px solid #fcd34d;
    /* Amber 300 */
    font-weight: 600;
    text-transform: none;
    min-width: auto;
    padding: 0.3rem 0.65rem;
}

.badge-type-recurring {
    background-color: #f3e8ff;
    /* Purple 100 */
    color: #6b21a8;
    /* Purple 900 */
    border: 1px solid #e9d5ff;
    /* Purple 300 */
    font-weight: 600;
    text-transform: none;
    min-width: auto;
    padding: 0.3rem 0.65rem;
}

.badge-type-tag_based {
    background-color: #dbeafe;
    /* Blue 100 */
    color: #1e40af;
    /* Blue 900 */
    border: 1px solid #93c5fd;
    /* Blue 300 */
    font-weight: 600;
    text-transform: none;
    min-width: auto;
    padding: 0.3rem 0.65rem;
}

/* Role Badges */
.badge-role-admin {
    background-color: #fef2f2;
    /* Red 50 */
    color: #b91c1c;
    /* Red 700 */
    border: 1px solid #fecdd3;
    /* Red 200 */
    font-weight: 700;
}

.badge-role-manager {
    background-color: #eef2ff;
    /* Indigo 50 */
    color: #4338ca;
    /* Indigo 700 */
    border: 1px solid #c7d2fe;
    /* Indigo 200 */
    font-weight: 700;
}

.badge-role-staff {
    background-color: #ecfeff;
    /* Cyan 50 */
    color: #0e7490;
    /* Cyan 700 */
    border: 1px solid #a5f3fc;
    /* Cyan 200 */
    font-weight: 700;
}

/* --- Buttons --- */
.btn-sm {
    background-color: white;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.btn-sm:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background-color: #eff6ff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Action buttons layout */
.action-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--color-primary);
}

.action-icon {
    font-size: 1rem;
}

.btn-icon {
    width: 2.25rem;
    padding: 0.35rem;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.action-menu {
    position: relative;
}

.menu-dropdown {
    position: absolute;
    top: 110%;
    right: 0;
    min-width: 140px;
    background: #fff;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0;
    display: none;
    z-index: 10;
}

.menu-dropdown.is-open {
    display: block;
}

.menu-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
}

.menu-item:hover {
    background: #f1f5f9;
}